carpedm20 / DCGAN-tensorflow

A tensorflow implementation of "Deep Convolutional Generative Adversarial Networks"
http://carpedm20.github.io/faces/
MIT License
7.14k stars 2.63k forks source link

TypeError and ValueError during training with downloaded dataset and my own dataset #91

Open SimpleXP opened 7 years ago

SimpleXP commented 7 years ago

Hi,

I want to try this DC_GAN code to train my own model with my own dataset. The image size in my dataset is 256x256x3, format is *.jpg. I use the command "python main.py --dataset mydata --is_train" and got this error message:

ValueError: Trying to share variable discriminator/d_h3_lin/Matrix, but specified shape (8192, 1) and found shape (131072, 1).

Then I conduct another experiment with the downloaded data (mnist and celebA) I use the command "python main.py --dataset mnist --input_height=28 --output_height=28 --c_dim=1 --is_train" and "python main.py --dataset celebA --input_height=108 --is_train --is_crop True" both return me this error message:

TypeError: sigmoid_cross_entropy_with_logits() got an unexpected keyword argument 'labels'

Anyone has any idea how to solve this issue?

Thanks in advance!

ianni67 commented 7 years ago

I confirm the TypeError. I tried to run the command:

python main.py --dataset celebA --input_height=108 --is_crop True

but received the message:

WARNING:tensorflow:From /home/ianni/PROGRAMMING/DCGAN/DCGAN-tensorflow/model.py:92 in build_model.: histogram_summary (from tensorflow.python.ops.logging_ops) is deprecated and will be removed after 2016-11-30. Instructions for updating: Please switch to tf.summary.histogram. Note that tf.summary.histogram uses the node name instead of the tag. This means that TensorFlow will automatically de-duplicate summary names based on their scope. WARNING:tensorflow:From /home/ianni/PROGRAMMING/DCGAN/DCGAN-tensorflow/model.py:109 in build_model.: histogram_summary (from tensorflow.python.ops.logging_ops) is deprecated and will be removed after 2016-11-30. Instructions for updating: Please switch to tf.summary.histogram. Note that tf.summary.histogram uses the node name instead of the tag. This means that TensorFlow will automatically de-duplicate summary names based on their scope. WARNING:tensorflow:From /home/ianni/PROGRAMMING/DCGAN/DCGAN-tensorflow/model.py:110 in build_model.: histogram_summary (from tensorflow.python.ops.logging_ops) is deprecated and will be removed after 2016-11-30. Instructions for updating: Please switch to tf.summary.histogram. Note that tf.summary.histogram uses the node name instead of the tag. This means that TensorFlow will automatically de-duplicate summary names based on their scope. WARNING:tensorflow:From /home/ianni/PROGRAMMING/DCGAN/DCGAN-tensorflow/model.py:111 in build_model.: image_summary (from tensorflow.python.ops.logging_ops) is deprecated and will be removed after 2016-11-30. Instructions for updating: Please switch to tf.summary.image. Note that tf.summary.histogram uses the node name instead of the tag. This means that TensorFlow will automatically de-duplicate summary names based on the scope they are created in. Also, the max_images argument was renamed to max_outputs. Traceback (most recent call last): File "main.py", line 96, in <module> tf.app.run() File "/home/ianni/PROGRAMMING/TENSORFLOW/local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 43, in run sys.exit(main(sys.argv[:1] + flags_passthrough)) File "main.py", line 76, in main sample_dir=FLAGS.sample_dir) File "/home/ianni/PROGRAMMING/DCGAN/DCGAN-tensorflow/model.py", line 71, in __init__ self.build_model() File "/home/ianni/PROGRAMMING/DCGAN/DCGAN-tensorflow/model.py", line 115, in build_model logits=self.D_logits, labels=tf.ones_like(self.D))) TypeError: sigmoid_cross_entropy_with_logits() got an unexpected keyword argument 'labels'

I'm running last updated version of tensorflow.

ageitgey commented 7 years ago

For the first error (ValueError: Trying to share variable discriminator/d_h3_lin/Matrix, but specified shape (8192, 1) and found shape (131072, 1)), you need to tell the code what size your images are in.

Just update these four lines of code in your local copy to the height and widths of your training images:

https://github.com/carpedm20/DCGAN-tensorflow/blob/15ef89f0067afd98d0ab4cf8b6ff7e65951c8443/main.py#L16-L19

For the second error (TypeError: sigmoid_cross_entropy_with_logits() got an unexpected keyword argument 'labels'), Tensorflow appears to have changed the naming of those parameters.

Just rename labels to targets on those function calls in model.py where you get that error.

ianni67 commented 7 years ago

Thank you very much ageitgey, your explaination is perfectly fitting. I'm still learning TF and got easily confused by the error.

dopetard commented 7 years ago

I'm trying to get it running with mnist data set and I'm getting the same error, https://github.com/carpedm20/DCGAN-tensorflow/issues/116

Can you please help?

ianni67 commented 7 years ago

please, read and follow the comment above by ageitgey. is solved the issue.

ArghyaPal commented 7 years ago

I have issued the following, and, the code is working fine:

python main.py --dataset /path/to/your/dataset/ --input_height=XYZ --output_height=PQR --c_dim=DIM --is_train

XYZ=input dimension PQR= output dimension DIM= #of channels (MNIST=1, RGB=3)

datatales2017 commented 7 years ago

Hi Adam and All, I am getting the same error when I run the below code: from keras.models import Sequential from keras.layers.convolutional import Conv2D from keras.layers import MaxPooling2D from keras.layers import Flatten from keras.layers.core import Dense

classifier = Sequential()

Step 1 - Convolution

classifier.add(Conv2D(filters=32, kernel_size = (3, 3), strides = 1, input_shape = (64, 64, 3), activation = 'relu'))

Step 2 - MaxPooling

classifier.add(MaxPooling2D(pool_size=(2,2)))

Adding a second convolutional layer

classifier.add(Conv2D(filters = 32, kernel_size = (3, 3), strides = 1, activation = 'relu')) classifier.add(MaxPooling2D(pool_size = (2, 2)))

Step 3 - Flattening

classifier.add(Flatten())

Step 4 - Full connection

classifier.add(Dense(units = 128, activation = 'relu')) classifier.add(Dense(units = 1, activation = 'sigmoid'))

Step 5 - Compile

classifier.compile(optimizer ='adam', loss = 'binary_crossentropy', metrics=['accuracy'])

I read the answer -Just rename labels to targets on those function calls in model.py where you get that error.- but I did not get where to change it. I am using tensorflow 0.12.1 is this the problem???

ageitgey commented 7 years ago

@datatales2017 I don't see how your question is related to DCGAN-tensorflow (this project). Your code is written using Keras, not TensorFlow directly so nothing here relates at all to what you are doing. So this issue/project isn't really the right place to ask this question.

But yes, your (unrelated) issue is the version of TensorFlow you are using is too old for your version of Keras you are using.

tall-josh commented 6 years ago

Hi I got a similar error. Ubuntu 16.04 Python 2.7 tensorflow=0.10.0rc0 keras=2.1.3

I changed to keras=1.1.1

and I was good to go :-)