Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ChuanWang90 opened this issue Nov 15, 2017 · 3 comments

Comments

@ChuanWang90
Copy link

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
Copy link
Author

ChuanWang90 commented Nov 15, 2017

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

@Metal-joker
Copy link

Same issue. Any solution?

@Metal-joker
Copy link

Okay, I saw the solution in #7 issue.

eclique pushed a commit that referenced this issue Mar 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants