Different Sized Input Image Error
Closed this issue · 1 comments
uzborg950 commented
I used the default set image size (576x160) with batch size = 10 with my own dataset to compensate for my hardware and it trained fine.
But when i set my own image size, for e.g.(206x 293), i get the following error:
InvalidArgumentError (see above for traceback): Incompatible shapes: [10,304,208,2] vs. [10,320,224,2]
Traceback (most recent call last):
File "C:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py", line 1323, in _do_call
return fn(*args)
File "C:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py", line 1302, in _run_fn
status, run_metadata)
File "C:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 473, in __exit__
c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: Incompatible shapes: [10,304,208,2] vs. [10,320,224,2]
[[Node: sum/Add = Add[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:GPU:0"](sum/mul, sum/mul_1)]]
[[Node: reshape/Mean/_311 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_1596_reshape/Mean", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "train.py", line 132, in <module>
loss_batch, _ = sess.run([loss, optimizer], feed_dict=feed)
File "C:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py", line 889, in run
run_metadata_ptr)
File "C:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py", line 1120, in _run
feed_dict_tensor, options, run_metadata)
File "C:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py", line 1317, in _do_run
options, run_metadata)
File "C:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py", line 1336, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Incompatible shapes: [10,304,208,2] vs. [10,320,224,2]
[[Node: sum/Add = Add[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:GPU:0"](sum/mul, sum/mul_1)]]
[[Node: reshape/Mean/_311 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_1596_reshape/Mean", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]
Caused by op 'sum/Add', defined at:
File "train.py", line 84, in <module>
net.build_from_vgg(args.vgg_dir, source.num_classes, progress_hook='tqdm')
File "H:\Documents (H-drive)\FAST\FYP\image-segmentation-fcn-master\fcnvgg.py", line 68, in build_from_vgg
self.__make_result_tensors()
File "H:\Documents (H-drive)\FAST\FYP\image-segmentation-fcn-master\fcnvgg.py", line 143, in __make_result_tensors
tf.add(2*vgg4_reshaped, 4*vgg7_reshaped))
File "C:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\ops\gen_math_ops.py", line 182, in add
"Add", x=x, y=y, name=name)
File "C:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 787, in _apply_op_helper
op_def=op_def)
File "C:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\ops.py", line 2956, in create_op
op_def=op_def)
File "C:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\ops.py", line 1470, in __init__
self._traceback = self._graph._extract_stack() # pylint: disable=protected-access
InvalidArgumentError (see above for traceback): Incompatible shapes: [10,304,208,2] vs. [10,320,224,2]
[[Node: sum/Add = Add[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:GPU:0"](sum/mul, sum/mul_1)]]
[[Node: reshape/Mean/_311 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_1596_reshape/Mean", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]
Is there something in the code that i am forgetting to change?
uzborg950 commented
Nevermind, my apologies, forgot to make the dimensions divisible by 32.