coxlab / prednet

Code and models accompanying "Deep Predictive Coding Networks for Video Prediction and Unsupervised Learning"
https://arxiv.org/abs/1605.08104
MIT License
759 stars 259 forks source link

ValueError: You are trying to load a weight file containing 3 layers into a model with 1 layers. #11

Closed guird closed 7 years ago

guird commented 7 years ago

Hello all,

I am trying to run PredNet on a cluster with keras 1.2.0 and theano 0.8.2, and when I run kitti_evaluate.py I get the message: python-2.7.9/lib/python2.7/site-packages/keras/engine/topology.py:368: UserWarning: The regularizers property of layers/models is deprecated. Regularization losses are now managed via the losses layer/model property. warnings.warn('The regularizers property of ' Traceback (most recent call last): File "kitti_evaluate.py", line 37, in train_model.load_weights(weights_file) File "python2.7/site-packages/keras/engine/topology.py", line 2701, in load_weights self.load_weights_from_hdf5_group(f) File "python-2.7.9/lib/python2.7/site-packages/keras/engine/topology.py", line 2753, in load_weights_from_hdf5_group str(len(flattened_layers)) + ' layers.') ValueError: You are trying to load a weight file containing 3 layers into a model with 1 layers.

I haven't been able to find any information as to what might be causing this.

Additionally, when I try to run kitti_train I get the following: Traceback (most recent call last): File "kitti_train.py", line 59, in errors_by_time = TimeDistributed(Dense(1, weights=[layer_loss_weights, np.zeros(1)], trainable=False), trainable=False)(errors) # calculate weighted error by layer File "python-2.7.9/lib/python2.7/site-packages/keras/engine/topology.py", line 543, in call self.build(input_shapes[0]) File "python-2.7.9/lib/python2.7/site-packages/keras/layers/wrappers.py", line 98, in build self.layer.build(child_input_shape) File "python-2.7.9/lib/python2.7/site-packages/keras/layers/core.py", line 763, in build self.set_weights(self.initial_weights) File "python-2.7.9/lib/python2.7/site-packages/keras/engine/topology.py", line 966, in set_weights str(weights)[:50] + '...') ValueError: You called set_weights(weights) on layer "dense_1" with a weight list of length 2, but the layer was expecting 0 weights. Provided weights: [array([[ 1.], [ 0.], [ 0.], ...

I haven't been able to figure out any way around these issues, the weights files I am using are downloaded with download_models.sh

bill-lotter commented 7 years ago

Hello, this issue is likely a difference in keras versions (see https://github.com/coxlab/prednet/issues/9). If you use keras 1.0.7 (or maybe 1.1.0), it should work. I'll also likely upload weights compatible with the most recent keras releases soon.