keras-segnet icon indicating copy to clipboard operation
keras-segnet copied to clipboard

ValueError: total size of new array must be unchanged when loading model

Open ChuanWang90 opened this issue 8 years ago • 3 comments

Hi, I get the following error when loading the json model. I have tried in both Keras vs 1 and 2 and I run with Theano as backend.

File "", line 1, in File "/chuan/virtualEnvironments/Keras/keras-env/local/lib/python2.7/site-packages/keras/models.py", line 345, in model_from_json return layer_module.deserialize(config, custom_objects=custom_objects) File "/chuan/virtualEnvironments/Keras/keras-env/local/lib/python2.7/site-packages/keras/layers/init.py", line 54, in deserialize printable_module_name='layer') File "/chuan/virtualEnvironments/Keras/keras-env/local/lib/python2.7/site-packages/keras/utils/generic_utils.py", line 139, in deserialize_keras_object list(custom_objects.items()))) File "/chuan/virtualEnvironments/Keras/keras-env/local/lib/python2.7/site-packages/keras/models.py", line 1214, in from_config model.add(layer) File "/chuan/virtualEnvironments/Keras/keras-env/local/lib/python2.7/site-packages/keras/models.py", line 475, in add output_tensor = layer(self.outputs[0]) File "/chuan/virtualEnvironments/Keras/keras-env/local/lib/python2.7/site-packages/keras/engine/topology.py", line 621, in call output_shape = self.compute_output_shape(input_shape) File "/chuan/virtualEnvironments/Keras/keras-env/local/lib/python2.7/site-packages/keras/layers/core.py", line 376, in compute_output_shape input_shape[1:], self.target_shape) File "/chuan/virtualEnvironments/Keras/keras-env/local/lib/python2.7/site-packages/keras/layers/core.py", line 370, in _fix_unknown_dimension raise ValueError(msg) ValueError: total size of new array must be unchanged

ChuanWang90 avatar Nov 15 '17 02:11 ChuanWang90

Update: If I run the build_model.py script I get the same error.

build_model.py:17: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(64, (3, 3), padding="same", input_shape=(1, 256, 2...) Convolution2D(64, kernel, kernel, border_mode='same', input_shape=(1, img_h, img_w)), build_model.py:20: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(64, (3, 3), padding="same") Convolution2D(64, kernel, kernel, border_mode='same'), build_model.py:25: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(128, (3, 3), padding="same") Convolution2D(128, kernel, kernel, border_mode='same'), build_model.py:28: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(128, (3, 3), padding="same") Convolution2D(128, kernel, kernel, border_mode='same'), build_model.py:33: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(256, (3, 3), padding="same") Convolution2D(256, kernel, kernel, border_mode='same'), build_model.py:36: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(256, (3, 3), padding="same") Convolution2D(256, kernel, kernel, border_mode='same'), build_model.py:39: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(256, (3, 3), padding="same") Convolution2D(256, kernel, kernel, border_mode='same'), build_model.py:44: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(512, (3, 3), padding="same") Convolution2D(512, kernel, kernel, border_mode='same'), build_model.py:47: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(512, (3, 3), padding="same") Convolution2D(512, kernel, kernel, border_mode='same'), build_model.py:50: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(512, (3, 3), padding="same") Convolution2D(512, kernel, kernel, border_mode='same'), build_model.py:55: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(512, (3, 3), padding="same") Convolution2D(512, kernel, kernel, border_mode='same'), build_model.py:58: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(512, (3, 3), padding="same") Convolution2D(512, kernel, kernel, border_mode='same'), build_model.py:61: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(512, (3, 3), padding="same") Convolution2D(512, kernel, kernel, border_mode='same'), build_model.py:75: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(512, (3, 3), padding="same") Convolution2D(512, kernel, kernel, border_mode='same'), build_model.py:78: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(512, (3, 3), padding="same") Convolution2D(512, kernel, kernel, border_mode='same'), build_model.py:81: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(512, (3, 3), padding="same") Convolution2D(512, kernel, kernel, border_mode='same'), build_model.py:86: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(512, (3, 3), padding="same") Convolution2D(512, kernel, kernel, border_mode='same'), build_model.py:89: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(512, (3, 3), padding="same") Convolution2D(512, kernel, kernel, border_mode='same'), build_model.py:92: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(256, (3, 3), padding="same") Convolution2D(256, kernel, kernel, border_mode='same'), build_model.py:97: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(256, (3, 3), padding="same") Convolution2D(256, kernel, kernel, border_mode='same'), build_model.py:100: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(256, (3, 3), padding="same") Convolution2D(256, kernel, kernel, border_mode='same'), build_model.py:103: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(128, (3, 3), padding="same") Convolution2D(128, kernel, kernel, border_mode='same'), build_model.py:108: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(128, (3, 3), padding="same") Convolution2D(128, kernel, kernel, border_mode='same'), build_model.py:111: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(64, (3, 3), padding="same") Convolution2D(64, kernel, kernel, border_mode='same'), build_model.py:116: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(64, (3, 3), padding="same") Convolution2D(64, kernel, kernel, border_mode='same'), build_model.py:119: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(2, (1, 1), padding="valid") Convolution2D(n_labels, 1, 1, border_mode='valid'),

.....virtualenvironments/Keras/keras-env/local/lib/python2.7/site-packages/keras/layers/core.py", line 378, in _fix_unknown_dimension raise ValueError(msg) ValueError: total size of new array must be unchanged

ChuanWang90 avatar Nov 15 '17 02:11 ChuanWang90

Same issue. Any solution?

Metal-joker avatar Feb 25 '18 07:02 Metal-joker

Okay, I saw the solution in #7 issue.

Metal-joker avatar Feb 25 '18 07:02 Metal-joker