grad_op_maker_ should not be null and GradOpMaker has not been registered??
with fluid.program_guard(d_program):
# declare_data(self)
self.inputs = fluid.layers.data(shape=image_dims, name='real_images')
self.y = fluid.layers.data(shape=[self.y_dim], name='y')
self.z = fluid.layers.data(shape=[self.z_dim], name='z')
self.unlabelled_inputs = fluid.layers.data(shape=image_dims, name='unlabelled_images')
print(self.inputs)
D_real, D_real_logits, _ = self.D(self.inputs, self.y, is_test=False)
G_train = self.G(self.z, self.y, is_test=False)
print(G_train)
D_fake, D_fake_logits, _ = self.D(G_train, self.y, is_test=False, reuse=True)
Y_c, _ = self.C(self.unlabelled_inputs, is_test=False)
D_cla, D_cla_logits, _ = self.D(self.unlabelled_inputs, Y_c, is_test=False, reuse=True)
ones_real = ones(D_real.shape)
zeros_fake = zeros(D_fake.shape)
zeros_cla = zeros(D_cla.shape)
ce_real = fluid.layers.sigmoid_cross_entropy_with_logits(x=D_real_logits, label=ones_real)
ce_fake = fluid.layers.sigmoid_cross_entropy_with_logits(x=D_fake_logits, label=zeros_fake)
ce_cla = fluid.layers.sigmoid_cross_entropy_with_logits(x=D_cla_logits, label=zeros_cla)
d_loss_real = fluid.layers.reduce_mean(ce_real)
d_loss_fake = (1 - alpha) * fluid.layers.reduce_mean(ce_fake)
d_loss_cla = alpha * fluid.layers.reduce_mean(ce_cla)
self.d_loss = d_loss_real + d_loss_fake + d_loss_cla
d_parameters = self.get_params(d_program, prefix='D')
d_opt = fluid.optimizer.Adam(learning_rate=self.gan_lr, beta1=self.GAN_beta1)
d_opt.minimize(self.d_loss, parameter_list=d_parameters)

ones and zeros is written as :
def ones(shape, dtype='float32'):
return fluid.layers.ones(shape, dtype)
def zeros(shape, dtype='float32'):
return fluid.layers.zeros(shape, dtype)
and the get_params functions is:
def get_params(self, program, prefix):
all_params = program.global_block().all_parameters()
return [t.name for t in all_params if t.name.startswith(prefix)]
Anyone has point on this problem?
Have you used fluid.layers.resize_bilinear? I had set the arg scale with 1, and it reported this error.
Have you used
fluid.layers.resize_bilinear? I had set the argscalewith 1, and it reported this error.
I had not used it, but i think there is some problem with my params define in conv2d.
It is because ones and zeros does not have gradient method, and you do not need to compute gradients of them actually.
Try to set
ones_real = ones(D_real.shape)
ones_real.stop_gradient = True
could resolve this problem
It is because
onesandzerosdoes not have gradient method, and you do not need to compute gradients of them actually.Try to set
ones_real = ones(D_real.shape) ones_real.stop_gradient = Truecould resolve this problem
not work, my paddlepaddle is 1.1.0,and it is not the version problem.
@reyoung @Superjomn When I use fluid.layers.concat([x, y], axis=1), I have this problem. If this function does not have gradient method?
def D(self, x, y_, name='D', is_test=False, reuse=False):
with fluid.unique_name.guard(name+'_'):
print("xshape: ",x.shape)
x = dropout(x, dropout_prob=0.2, is_test=is_test)
# x = reshape(x, [-1, 32, 32, 3])--->[-1,3,32,32]
y = reshape(y_, [-1, self.y_dim, 1, 1]) #ten classes
# x = conv_cond_concat(x, y)
#weight norm in paddlepaddle has finished
print("convbefore!!!!!!!:",x)
x = conv2d(x, num_filters=32, filter_size=3,
param_attr=None, act='lrelu', reuse=reuse)
# x = conv_cond_concat(x, y)
x = conv2d(x, num_filters=32, filter_size=3, stride=2,
param_attr=None, act='lrelu', reuse=reuse)
print("D,con2d_2 shape:",x.shape)
x = dropout(x, dropout_prob=0.2)
# x = conv_cond_concat(x, y)
x = conv2d(x, num_filters=64, filter_size=3, param_attr=None, act='lrelu', reuse=reuse)
# x = conv_cond_concat(x, y)
x = conv2d(x, num_filters=64, filter_size=3, stride=2, param_attr=None, act='lrelu', reuse=reuse)
x = dropout(x, dropout_prob=0.2)
# x = conv_cond_concat(x, y)
x = conv2d(x, num_filters=128, filter_size=3, param_attr=None, act='lrelu', reuse=reuse)
# x = conv_cond_concat(x, y)
x = conv2d(x, num_filters=128, filter_size=3, param_attr=None, act='lrelu', reuse=reuse)
# x = conv_cond_concat(x, y)
x = Global_Average_Pooling(x)
x = flatten(x)
x = fluid.layers.concat([x, y_], axis=1)
# x = concat(x, y_)
#IcGAN 每一层都要concat一下
# MLP??
x_logit = fc(x, 1)
out = sigmoid(x_logit)
return out, x_logit, x
This is my D model, and I note the concat op, it can run successfully.
@strawsuper
Can you paste the whole configuration?
@strawsuper
Can you paste the whole configuration?
@reyoung This is my Repositories triple_gan_paddle I think there are some wrong in the gaussian_noise_layer of C model.
.
...
├── cifar10.py # reader for cifar10 dataset
├── paddleops.py # the paddle layers and concat op wrapper
├── triple_gan.py # my triple gan for paddle
├── utils.py
I have no idea where is the issue. Thanks a lot:+1:
Hello, since this issue has been solved , we will close it today for the sake of other user’s experience. If you still need to follow up on this question after closing, please feel free to reopen it. We apologize for the inconvenience caused by the closure and thank you so much for your support of PaddlePaddle Group!