paarthneekhara / text-to-image

Text to image synthesis using thought vectors
MIT License
2.17k stars 398 forks source link

ValueError: Dimension 1 in both shapes must be equal, but are 100 and 256. Shapes are [64,100] and [64,256]. #50

Open AnwarUllahKhan opened 6 years ago

AnwarUllahKhan commented 6 years ago

Traceback (most recent call last): File "train.py", line 241, in main() File "train.py", line 79, in main input_tensors, variables, loss, outputs, checks = gan.build_model() File "C:\Users\anwar\Downloads\Documents\text-to-image-master\model.py", line 37, in build_model fake_image = self.generator(t_z, t_real_caption) File "C:\Users\anwar\Downloads\Documents\text-to-image-master\model.py", line 137, in generator z_concat = tf.concat(1, [t_z, reduced_text_embedding]) File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\ops\array_ops.py", line 1121, in concat dtype=dtypes.int32).get_shape().assert_is_compatible_with( File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 1048, in convert_to_tensor as_ref=False) File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 1144, in internal_convert_to_tensor ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref) File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\ops\array_ops.py", line 971, in _autopacking_conversion_function return _autopacking_helper(v, dtype, name or "packed") File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\ops\array_ops.py", line 923, in _autopacking_helper return gen_array_ops.pack(elems_as_tensors, name=scope) File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\ops\gen_array_ops.py", line 5644, in pack "Pack", values=values, axis=axis, name=name) File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 787, in _apply_op_helper op_def=op_def) File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\util\deprecation.py", line 488, in new_func return func(*args, **kwargs) File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 3272, in create_op op_def=op_def) File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 1790, in init control_input_ops) File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 1629, in _create_c_op raise ValueError(str(e)) ValueError: Dimension 1 in both shapes must be equal, but are 100 and 256. Shapes are [64,100] and [64,256]. From merging shape 0 with other shapes. for 'concat/concat_dim' (op: 'Pack') with input shapes: [64,100], [64,256].

AnwarUllahKhan commented 6 years ago

@neilsh @paarthneekhara @gitter-badger @AbhishekNarayanan, sir please see the above error and inform me what's wrong with this....

Thanks

prophet009 commented 5 years ago

for the line z_concat = tf.concat(1, [t_z, reduced_text_embedding]) use this instead z_concat = tf.concat([t_z, reduced_text_embedding],1)

remyavijeesh22 commented 5 years ago

when use the above "code" for correcting this error occured..what will do

WARNING:tensorflow:From /home/hp/anaconda3/lib/python3.7/site-packages/tensorflow/python/framework/op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version. Instructions for updating: Colocations handled automatically by placer. Traceback (most recent call last): File "/home/hp/anaconda3/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 1659, in _create_c_op c_op = c_api.TF_FinishOperation(op_desc) tensorflow.python.framework.errors_impl.InvalidArgumentError: Dimension 3 in both shapes must be equal, but are 512 and 256. Shapes are [64,4,4,512] and [64,4,4,256]. From merging shape 0 with other shapes. for 'h3_concat/concat_dim' (op: 'Pack') with input shapes: [64,4,4,512], [64,4,4,256].

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "train.py", line 238, in main() File "train.py", line 76, in main input_tensors, variables, loss, outputs, checks = gan.build_model() File "/home/hp/Gan_project_main/text_image_gan/model.py", line 39, in build_model disc_real_image, disc_real_image_logits = self.discriminator(t_real_image, t_real_caption) File "/home/hp/Gan_project_main/text_image_gan/model.py", line 173, in discriminator h3_concat = tf.concat( 3, [h3, tiled_embeddings], name='h3_concat') File "/home/hp/anaconda3/lib/python3.7/site-packages/tensorflow/python/util/dispatch.py", line 180, in wrapper return target(*args, *kwargs) File "/home/hp/anaconda3/lib/python3.7/site-packages/tensorflow/python/ops/array_ops.py", line 1253, in concat dtype=dtypes.int32).get_shape().assert_is_compatible_with( File "/home/hp/anaconda3/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 1039, in convert_to_tensor return convert_to_tensor_v2(value, dtype, preferred_dtype, name) File "/home/hp/anaconda3/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 1097, in convert_to_tensor_v2 as_ref=False) File "/home/hp/anaconda3/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 1175, in internal_convert_to_tensor ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref) File "/home/hp/anaconda3/lib/python3.7/site-packages/tensorflow/python/ops/array_ops.py", line 1102, in _autopacking_conversion_function return _autopacking_helper(v, dtype, name or "packed") File "/home/hp/anaconda3/lib/python3.7/site-packages/tensorflow/python/ops/array_ops.py", line 1054, in _autopacking_helper return gen_array_ops.pack(elems_as_tensors, name=scope) File "/home/hp/anaconda3/lib/python3.7/site-packages/tensorflow/python/ops/gen_array_ops.py", line 5448, in pack "Pack", values=values, axis=axis, name=name) File "/home/hp/anaconda3/lib/python3.7/site-packages/tensorflow/python/framework/op_def_library.py", line 788, in _apply_op_helper op_def=op_def) File "/home/hp/anaconda3/lib/python3.7/site-packages/tensorflow/python/util/deprecation.py", line 507, in new_func return func(args, **kwargs) File "/home/hp/anaconda3/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 3300, in create_op op_def=op_def) File "/home/hp/anaconda3/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 1823, in init control_input_ops) File "/home/hp/anaconda3/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 1662, in _create_c_op raise ValueError(str(e)) ValueError: Dimension 3 in both shapes must be equal, but are 512 and 256. Shapes are [64,4,4,512] and [64,4,4,256]. From merging shape 0 with other shapes. for 'h3_concat/concat_dim' (op: 'Pack') with input shapes: [64,4,4,512], [64,4,4,256].

PragyanSubedi commented 5 years ago

Please write all tf.concat as follows:

z_concat = tf.concat(axis=1, values=[t_z, reduced_text_embedding]) instead of z_concat = tf.concat(1, t_z, reduced_text_embedding)

The parameter placement has changed hence specifying the parameters will help. @remyavijeesh22 @AnwarUllahKhan