tdeboissiere / DeepLearningImplementations

Implementation of recent Deep Learning papers
MIT License
1.81k stars 650 forks source link

dcgan error #24

Closed yoookoo closed 7 years ago

yoookoo commented 7 years ago

Something is wrong when running ./pix2pix/src/model/ function DCGAN DCGAN_output = discriminator_model(list_gen_patch)

Traceback (most recent call last):

  File "<ipython-input-110-8d91cd362eab>", line 2, in <module>
    patch_size=64, image_dim_ordering='th')

  File "<ipython-input-109-a71e3069eff8>", line 25, in DCGAN
    DCGAN_output = discriminator_model(list_gen_patch)

  File "/home/yuankun/anaconda2/lib/python2.7/site-packages/keras/engine/topology.py", line 572, in __call__
    self.add_inbound_node(inbound_layers, node_indices, tensor_indices)

  File "/home/yuankun/anaconda2/lib/python2.7/site-packages/keras/engine/topology.py", line 635, in add_inbound_node
    Node.create_node(self, inbound_layers, node_indices, tensor_indices)

  File "/home/yuankun/anaconda2/lib/python2.7/site-packages/keras/engine/topology.py", line 172, in create_node
    output_tensors = to_list(outbound_layer.call(input_tensors, mask=input_masks))

  File "/home/yuankun/anaconda2/lib/python2.7/site-packages/keras/engine/topology.py", line 2247, in call
    output_tensors, output_masks, output_shapes = self.run_internal_graph(inputs, masks)

  File "/home/yuankun/anaconda2/lib/python2.7/site-packages/keras/engine/topology.py", line 2390, in run_internal_graph
    computed_mask))

  File "/home/yuankun/anaconda2/lib/python2.7/site-packages/keras/engine/topology.py", line 2247, in call
    output_tensors, output_masks, output_shapes = self.run_internal_graph(inputs, masks)

  File "/home/yuankun/anaconda2/lib/python2.7/site-packages/keras/engine/topology.py", line 2420, in run_internal_graph
    shapes = to_list(layer.get_output_shape_for(computed_tensors[0]._keras_shape))

  File "/home/yuankun/anaconda2/lib/python2.7/site-packages/keras/layers/core.py", line 821, in get_output_shape_for
    assert input_shape[-1] and input_shape[-1] == self.input_dim

AssertionError
tdeboissiere commented 7 years ago

Which version of Keras are you using ? Which para,eters did you select to run it with ?

If using keras 2.0, it's likely there will be bugs as I have not yet ported the code

yoookoo commented 7 years ago

Thanks for your reply. The version of my Keras is 1.2.2 using theano backend. Errors happened when trying to joint training D with G. img_dim = (3,256,256) nb_patch = 16 img_dim_disc = 64

discriminator_model.summary()
Layer (type)                     Output Shape          Param #     Connected to                     
disc_input_0 (InputLayer)        (None, 3, 64, 64)     0                                      
disc_input_1 (InputLayer)        (None, 3, 64, 64)     0                                            
disc_input_2 (InputLayer)        (None, 3, 64, 64)     0                                            
disc_input_3 (InputLayer)        (None, 3, 64, 64)     0                                            
disc_input_4 (InputLayer)        (None, 3, 64, 64)     0                                            
disc_input_5 (InputLayer)        (None, 3, 64, 64)     0                                            
disc_input_6 (InputLayer)        (None, 3, 64, 64)     0                                            
disc_input_7 (InputLayer)        (None, 3, 64, 64)     0                                            
disc_input_8 (InputLayer)        (None, 3, 64, 64)     0                                            
disc_input_9 (InputLayer)        (None, 3, 64, 64)     0                                            
disc_input_10 (InputLayer)       (None, 3, 64, 64)     0                                            
disc_input_11 (InputLayer)       (None, 3, 64, 64)     0                                            
disc_input_12 (InputLayer)       (None, 3, 64, 64)     0                                            
disc_input_13 (InputLayer)       (None, 3, 64, 64)     0                                            
disc_input_14 (InputLayer)       (None, 3, 64, 64)     0                                            
disc_input_15 (InputLayer)       (None, 3, 64, 64)     0                                            
PatchGAN (Model)                 [(None, 2), (None, 51 6279554     disc_input_0[0][0]               
                                                                   disc_input_1[0][0]               
                                                                   disc_input_2[0][0]               
                                                                   disc_input_3[0][0]               
                                                                   disc_input_4[0][0]               
                                                                   disc_input_5[0][0]               
                                                                   disc_input_6[0][0]               
                                                                   disc_input_7[0][0]               
                                                                   disc_input_8[0][0]               
                                                                   disc_input_9[0][0]               
                                                                   disc_input_10[0][0]              
                                                                   disc_input_11[0][0]              
                                                                   disc_input_12[0][0]              
                                                                   disc_input_13[0][0]              
                                                                   disc_input_14[0][0]              
                                                                   disc_input_15[0][0]              
merge_feat (Merge)               (None, 32)            0           PatchGAN[17][0]                  
                                                                   PatchGAN[18][0]                  
                                                                   PatchGAN[19][0]                  
                                                                   PatchGAN[20][0]                  
                                                                   PatchGAN[21][0]                  
                                                                   PatchGAN[22][0]                  
                                                                   PatchGAN[23][0]                  
                                                                   PatchGAN[24][0]                  
                                                                   PatchGAN[25][0]                  
                                                                   PatchGAN[26][0]                  
                                                                   PatchGAN[27][0]                  
                                                                   PatchGAN[28][0]                  
                                                                   PatchGAN[29][0]                  
                                                                   PatchGAN[30][0]                  
                                                                   PatchGAN[31][0]                  
                                                                   PatchGAN[32][0]                  
disc_output (Dense)              (None, 2)             66          merge_feat[0][0]                 
Total params: 6,279,620
Trainable params: 6,275,652
Non-trainable params: 3,968
tdeboissiere commented 7 years ago

Which generator do you use ? deconv or upsampling ?

yoookoo commented 7 years ago

Upsampling is used for generator. For python main.py 64 64 Same error happens:

Traceback (most recent call last):
  File "main.py", line 71, in <module>
    launch_training(**d_params)
  File "main.py", line 8, in launch_training
    train.train(**kwargs)
  File "/home/yuankun/DeepLearningImplementations/pix2pix/src/model/train.py", line 84, in train
    image_dim_ordering)
  File "/home/yuankun/DeepLearningImplementations/pix2pix/src/model/models.py", line 298, in DCGAN
    DCGAN_output = discriminator_model(list_gen_patch)
  File "/home/yuankun/anaconda2/lib/python2.7/site-packages/keras/engine/topology.py", line 572, in __call__
    self.add_inbound_node(inbound_layers, node_indices, tensor_indices)
  File "/home/yuankun/anaconda2/lib/python2.7/site-packages/keras/engine/topology.py", line 635, in add_inbound_node
    Node.create_node(self, inbound_layers, node_indices, tensor_indices)
  File "/home/yuankun/anaconda2/lib/python2.7/site-packages/keras/engine/topology.py", line 172, in create_node
    output_tensors = to_list(outbound_layer.call(input_tensors, mask=input_masks))
  File "/home/yuankun/anaconda2/lib/python2.7/site-packages/keras/engine/topology.py", line 2247, in call
    output_tensors, output_masks, output_shapes = self.run_internal_graph(inputs, masks)
  File "/home/yuankun/anaconda2/lib/python2.7/site-packages/keras/engine/topology.py", line 2390, in run_internal_graph
    computed_mask))
  File "/home/yuankun/anaconda2/lib/python2.7/site-packages/keras/engine/topology.py", line 2247, in call
    output_tensors, output_masks, output_shapes = self.run_internal_graph(inputs, masks)
  File "/home/yuankun/anaconda2/lib/python2.7/site-packages/keras/engine/topology.py", line 2420, in run_internal_graph
    shapes = to_list(layer.get_output_shape_for(computed_tensors[0]._keras_shape))
  File "/home/yuankun/anaconda2/lib/python2.7/site-packages/keras/layers/core.py", line 821, in get_output_shape_for
    assert input_shape[-1] and input_shape[-1] == self.input_dim
AssertionError
tdeboissiere commented 7 years ago

I'll look into it when I get the time. You can try to debug it by varying the patch size and inspecting inputs and outputs in the meantime

yoookoo commented 7 years ago

I have debugged by defining inputs and outputs but still not work. Which version of Keras are you using ? Version may be a problem. And which backend have you choosed? Theano or Tensorflow? It would be grateful if you can help solve this issue.

yoookoo commented 7 years ago

Everything is OK if I turn the backend into 'tensorflow'. So I still don't know what's wrong with 'theano'.