ndrplz/surround_vehicles_awareness

ValueError: total size of new array must be unchanged

danfouer opened this issue · 2 comments

Ubuntu 16.04

home/danfouer/.conda/envs/keras/bin/python /home/danfouer/Documents/pycharm/Project/SVA/main.py
Using Theano backend.
Traceback (most recent call last):
File "/home/danfouer/Documents/pycharm/Project/SVA/main.py", line 16, in
model = SDPN(summary=True)
File "/home/danfouer/Documents/pycharm/Project/SVA/model.py", line 30, in SDPN
crop_encoded = Reshape(target_shape=(2048,))(crop_encoded)
File "/home/danfouer/.conda/envs/keras/lib/python2.7/site-packages/keras/engine/base_layer.py", line 480, in call
output_shape = self.compute_output_shape(input_shape)
File "/home/danfouer/.conda/envs/keras/lib/python2.7/site-packages/keras/layers/core.py", line 404, in compute_output_shape
input_shape[1:], self.target_shape)
File "/home/danfouer/.conda/envs/keras/lib/python2.7/site-packages/keras/layers/core.py", line 392, in _fix_unknown_dimension
raise ValueError(msg)
ValueError: total size of new array must be unchanged

Well, the output stack looks clear to me. What is the size of crop_encoded that you feed to the Reshape layer?
Unfortunately some time has passed and frameworks have changed quite a lot, starting from Theano that is completely dead.
PS: did you take a look to #2 ? May be related.

Just in case this comes in handy for anyone in the future, I believe the solution to this problem is to change the value of _IMAGE_DIM_ORDERING to 'th' from the default 'tf' in common.py in the Keras backend. This is because the ResNet50 implementation in the Keras version used imports this image_dim_ordering to decide the axis used for Batch Normalization. The value should be 1 for Theano(channels first) and 3 for Tensorflow(channels last) but it get set to 3 even if you set the backend to be Theano since the default value is 'tf' in the common.py.