fregu856 / segmentation

TensorFlow implementation of ENet, trained on the Cityscapes dataset.
http://www.fregu856.com/
MIT License
244 stars 73 forks source link

Dimention error #8

Closed Saif-03 closed 5 years ago

Saif-03 commented 6 years ago

Hello,

When i try to compile the code (Python3.6.4 & TensorFlow 1.8.0) during training i get the following error.


C:/Users/s01syed/PycharmProjects/ENet/train.py [4, 256, 512, 16] [4, 128, 256, 64] [4, 128, 256, 64] [4, 128, 256, 64] [4, 128, 256, 64] [4, 128, 256, 64] [4, 64, 128, 128] [4, 64, 128, 128] [4, 64, 128, 128] [4, 64, 128, 128] [4, 64, 128, 128] [4, 64, 128, 128] [4, 64, 128, 128] [4, 64, 128, 128] [4, 64, 128, 128] [4, 64, 128, 128] [4, 64, 128, 128] [4, 64, 128, 128] [4, 64, 128, 128] [4, 64, 128, 128] [4, 64, 128, 128] [4, 64, 128, 128] [4, 64, 128, 128] [4, 128, 256, 64] [4, 128, 256, 64] [4, 128, 256, 64] [4, 256, 512, 16] [4, 256, 512, 16] [4, 512, 1024, 20] Traceback (most recent call last): File "C:\Users\s01syed\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 1567, in _create_c_op c_op = c_api.TF_FinishOperation(op_desc) tensorflow.python.framework.errors_impl.InvalidArgumentError: Dimensions must be equal, but are 20 and 3 for 'mul_254' (op: 'Mul') with input shapes: [4,512,1024,20], [3].

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:/Users/s01syed/PycharmProjects/ENet/train.py", line 27, in batch_size=batch_size) File "C:\Users\s01syed\PycharmProjects\ENet\model.py", line 42, in init self.add_loss_op() File "C:\Users\s01syed\PycharmProjects\ENet\model.py", line 237, in add_loss_op weights = self.onehot_labels_ph*self.class_weights File "C:\Users\s01syed\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\ops\math_ops.py", line 979, in binary_op_wrapper return func(x, y, name=name) File "C:\Users\s01syed\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\ops\math_ops.py", line 1211, in _mul_dispatch return gen_math_ops.mul(x, y, name=name) File "C:\Users\s01syed\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\ops\gen_math_ops.py", line 5066, in mul "Mul", x=x, y=y, name=name) File "C:\Users\s01syed\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 787, in _apply_op_helper op_def=op_def) File "C:\Users\s01syed\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 3392, in create_op op_def=op_def) File "C:\Users\s01syed\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 1734, in init control_input_ops) File "C:\Users\s01syed\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 1570, in _create_c_op raise ValueError(str(e)) ValueError: Dimensions must be equal, but are 20 and 3 for 'mul_254' (op: 'Mul') with input shapes: [4,512,1024,20], [3].

Process finished with exit code 1


I saw a similar error for Keras, which was caused due to the version upgrade https://github.com/datalogue/keras-attention/issues/1. I really want to implement this code but im stuck, could you please have a look.

Thanks :)

UPDATE: Solved the Error, it was due to passing a wrong input to class_weights