titu1994 / Super-Resolution-using-Generative-Adversarial-Networks

An implementation of SRGAN model in Keras
283 stars 85 forks source link

ValueError: "concat" mode can only merge layers with matching output shapes except for the concat axis. #26

Closed doantientai closed 7 years ago

doantientai commented 7 years ago

I passed all the problem about packages. But when I come to the line of building the model. I got and error about the size of matrices. Please help.

Thank you very much!

`ValueError Traceback (most recent call last)

in () 17 srgan_network = SRGANNetwork(img_width=32, img_height=32, batch_size=1) 18 # srgan_network.build_srgan_model() ---> 19 srgan_network.build_srgan_pretrain_model() 20 21 # plot(srgan_network.srgan_model_, 'SRGAN.png', show_shapes=True) in build_srgan_pretrain_model(self, use_small_srgan) 322 self.generative_model_ = Model(ip, sr_output) 323 --> 324 vgg_output = self.vgg_network.append_vgg_network(sr_output, ip_vgg, pre_train=True) 325 326 self.srgan_model_ = Model(input=[ip, ip_vgg], in append_vgg_network(self, x_in, true_X_input, pre_train) 30 31 # Append the initial inputs to the outputs of the SRResNet ---> 32 x = merge([x_in, true_X_input], mode='concat', concat_axis=0) 33 34 # Normalize the inputs via custom VGG Normalization layer /users/taitien.doan/anaconda3/envs/TheanoKerasPy27/lib/python2.7/site-packages/keras/engine/topology.pyc in merge(inputs, mode, concat_axis, dot_axes, output_shape, output_mask, arguments, name) 1672 node_indices=node_indices, 1673 tensor_indices=tensor_indices, -> 1674 name=name) 1675 return merge_layer.inbound_nodes[0].output_tensors[0] 1676 else: /users/taitien.doan/anaconda3/envs/TheanoKerasPy27/lib/python2.7/site-packages/keras/engine/topology.pyc in __init__(self, layers, mode, concat_axis, dot_axes, output_shape, output_mask, arguments, node_indices, tensor_indices, name) 1291 self._arguments_validation(layers, mode, 1292 concat_axis, dot_axes, -> 1293 node_indices, tensor_indices) 1294 self.built = True 1295 self.add_inbound_node(layers, node_indices, tensor_indices) /users/taitien.doan/anaconda3/envs/TheanoKerasPy27/lib/python2.7/site-packages/keras/engine/topology.pyc in _arguments_validation(self, layers, mode, concat_axis, dot_axes, node_indices, tensor_indices) 1363 'layers with matching ' 1364 'output shapes except for the concat axis. ' -> 1365 'Layer shapes: %s' % (input_shapes)) 1366 1367 def call(self, inputs, mask=None): ValueError: "concat" mode can only merge layers with matching output shapes except for the concat axis. Layer shapes: [(None, 12, 128, 3), (None, 3, 128, 128)]`
titu1994 commented 7 years ago

Use image data format channels_first in keras.json file.

doantientai commented 7 years ago

Thank you! But I think it does't work out. I'm using Keras in Anaconda, and run the code via Jupyter Notebook. Is there another keras.json that I need to look for?

UPDATE: don't worry I changed it manually by K.set_image_dim_ordering('th')