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

kitti_train.py cannot initialize weights from downloaded data #18

Closed
arvoelke opened this issue Apr 6, 2017 · 5 comments
Closed

kitti_train.py cannot initialize weights from downloaded data #18

arvoelke opened this issue Apr 6, 2017 · 5 comments

Comments

@arvoelke
Copy link

arvoelke commented Apr 6, 2017

Hi, I am currently trying to run your model using Python 2.7 and Theano==0.9.0 (using a GPU with pygpu==0.6.2). I am skipping the first step (by executing download_data.sh) and going straight to training (python kitti_train.py).

I initially tried using keras==2.0.2, but saw this error:

Traceback (most recent call last):
  File "kitti_train.py", line 59, in <module>
    errors = prednet(inputs)  # errors will be (batch_size, nt, nb_layers)
  File "/home/arvoelke/.virtualenvs/CTN/local/lib/python2.7/site-packages/keras/layers/recurrent.py", line 252, in __call__
    return super(Recurrent, self).__call__(inputs, **kwargs)
  File "/home/arvoelke/.virtualenvs/CTN/local/lib/python2.7/site-packages/keras/engine/topology.py", line 528, in __call__
    self.build(input_shapes[0])
  File "/home/arvoelke/prednet/prednet.py", line 216, in build
    if self.initial_weights is not None:
AttributeError: 'PredNet' object has no attribute 'initial_weights'

Then I noticed you suggest keras==1.2.0, so I downgraded, and retried, but saw a different error:

python kitti_train.py
Using Theano backend.
Can not use cuDNN on context None: Device not supported
Mapped name None to device cuda: Tesla C2075 (0000:02:00.0)
Traceback (most recent call last):
  File "kitti_train.py", line 60, in <module>
    errors_by_time = TimeDistributed(Dense(1, weights=[layer_loss_weights, np.zeros(1)], trainable=False), trainable=False)(errors)  # calculate weighted error by layer
  File "/home/arvoelke/.virtualenvs/CTN/local/lib/python2.7/site-packages/keras/engine/topology.py", line 543, in __call__
    self.build(input_shapes[0])
  File "/home/arvoelke/.virtualenvs/CTN/local/lib/python2.7/site-packages/keras/layers/wrappers.py", line 98, in build
    self.layer.build(child_input_shape)
  File "/home/arvoelke/.virtualenvs/CTN/local/lib/python2.7/site-packages/keras/layers/core.py", line 763, in build
    self.set_weights(self.initial_weights)
  File "/home/arvoelke/.virtualenvs/CTN/local/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.],
       ...

Any tips for things I could try? Thanks, Aaron

@arvoelke
Copy link
Author

arvoelke commented Apr 6, 2017

I downgraded even further to keras==1.0.8, and now it seems to be working. This version should probably be suggested in the README?

@bill-lotter
Copy link
Contributor

Hi, sorry about the versioning trouble. I'm going to try to make it compatible with Keras 2.0 now, so all of this might be moot point, but it looks like I was using Keras 1.2.0 a few commits ahead of the official 1.2.0 release (specifically I was on 3a7cd05b488e327c1adccaaff10c78390d53b5a8) and it worked on that commit and 1.0.8 but not on the official 1.2.0 commit in-between. Sorry about that! Keras 2.0 is supposed to be stable release, so hopefully there won't be these issues in the future once I finish the upgrade.

@dendisuhubdy
Copy link

@arvoelke got the same error here, I'm trying your solution to downgrade Keras

(lisa) suhubdyd@grok-machine:~/research/prednet$ python kitti_train.py 
Using Theano backend.
Using cuDNN version 5105 on context None
Mapped name None to device cuda: GeForce GTX 750 (0000:01:00.0)
/u/suhubdyd/research/prednet/prednet.py:187: UserWarning: Update your `Conv2D` call to the Keras 2 API: `Conv2D(3, (3, 3), padding="same", activation=<function ..., data_format="channels_last")`
  self.conv_layers[c].append(Convolution2D(self.R_stack_sizes[l], self.R_filt_sizes[l], self.R_filt_sizes[l], border_mode='same', activation=act, dim_ordering=self.dim_ordering))
/u/suhubdyd/research/prednet/prednet.py:190: UserWarning: Update your `Conv2D` call to the Keras 2 API: `Conv2D(3, (3, 3), padding="same", activation="relu", data_format="channels_last")`
  self.conv_layers['ahat'].append(Convolution2D(self.stack_sizes[l], self.Ahat_filt_sizes[l], self.Ahat_filt_sizes[l], border_mode='same', activation=act, dim_ordering=self.dim_ordering))
/u/suhubdyd/research/prednet/prednet.py:193: UserWarning: Update your `Conv2D` call to the Keras 2 API: `Conv2D(48, (3, 3), padding="same", activation=<function ..., data_format="channels_last")`
  self.conv_layers['a'].append(Convolution2D(self.stack_sizes[l+1], self.A_filt_sizes[l], self.A_filt_sizes[l], border_mode='same', activation=self.A_activation, dim_ordering=self.dim_ordering))
/u/suhubdyd/research/prednet/prednet.py:187: UserWarning: Update your `Conv2D` call to the Keras 2 API: `Conv2D(48, (3, 3), padding="same", activation=<function ..., data_format="channels_last")`
  self.conv_layers[c].append(Convolution2D(self.R_stack_sizes[l], self.R_filt_sizes[l], self.R_filt_sizes[l], border_mode='same', activation=act, dim_ordering=self.dim_ordering))
/u/suhubdyd/research/prednet/prednet.py:190: UserWarning: Update your `Conv2D` call to the Keras 2 API: `Conv2D(48, (3, 3), padding="same", activation=<function ..., data_format="channels_last")`
  self.conv_layers['ahat'].append(Convolution2D(self.stack_sizes[l], self.Ahat_filt_sizes[l], self.Ahat_filt_sizes[l], border_mode='same', activation=act, dim_ordering=self.dim_ordering))
/u/suhubdyd/research/prednet/prednet.py:193: UserWarning: Update your `Conv2D` call to the Keras 2 API: `Conv2D(96, (3, 3), padding="same", activation=<function ..., data_format="channels_last")`
  self.conv_layers['a'].append(Convolution2D(self.stack_sizes[l+1], self.A_filt_sizes[l], self.A_filt_sizes[l], border_mode='same', activation=self.A_activation, dim_ordering=self.dim_ordering))
/u/suhubdyd/research/prednet/prednet.py:187: UserWarning: Update your `Conv2D` call to the Keras 2 API: `Conv2D(96, (3, 3), padding="same", activation=<function ..., data_format="channels_last")`
  self.conv_layers[c].append(Convolution2D(self.R_stack_sizes[l], self.R_filt_sizes[l], self.R_filt_sizes[l], border_mode='same', activation=act, dim_ordering=self.dim_ordering))
/u/suhubdyd/research/prednet/prednet.py:190: UserWarning: Update your `Conv2D` call to the Keras 2 API: `Conv2D(96, (3, 3), padding="same", activation=<function ..., data_format="channels_last")`
  self.conv_layers['ahat'].append(Convolution2D(self.stack_sizes[l], self.Ahat_filt_sizes[l], self.Ahat_filt_sizes[l], border_mode='same', activation=act, dim_ordering=self.dim_ordering))
/u/suhubdyd/research/prednet/prednet.py:193: UserWarning: Update your `Conv2D` call to the Keras 2 API: `Conv2D(192, (3, 3), padding="same", activation=<function ..., data_format="channels_last")`
  self.conv_layers['a'].append(Convolution2D(self.stack_sizes[l+1], self.A_filt_sizes[l], self.A_filt_sizes[l], border_mode='same', activation=self.A_activation, dim_ordering=self.dim_ordering))
/u/suhubdyd/research/prednet/prednet.py:187: UserWarning: Update your `Conv2D` call to the Keras 2 API: `Conv2D(192, (3, 3), padding="same", activation=<function ..., data_format="channels_last")`
  self.conv_layers[c].append(Convolution2D(self.R_stack_sizes[l], self.R_filt_sizes[l], self.R_filt_sizes[l], border_mode='same', activation=act, dim_ordering=self.dim_ordering))
/u/suhubdyd/research/prednet/prednet.py:190: UserWarning: Update your `Conv2D` call to the Keras 2 API: `Conv2D(192, (3, 3), padding="same", activation=<function ..., data_format="channels_last")`
  self.conv_layers['ahat'].append(Convolution2D(self.stack_sizes[l], self.Ahat_filt_sizes[l], self.Ahat_filt_sizes[l], border_mode='same', activation=act, dim_ordering=self.dim_ordering))
/u/suhubdyd/research/prednet/prednet.py:195: UserWarning: Update your `UpSampling2D` call to the Keras 2 API: `UpSampling2D(data_format="channels_last")`
  self.upsample = UpSampling2D(dim_ordering=self.dim_ordering)
/u/suhubdyd/research/prednet/prednet.py:196: UserWarning: Update your `MaxPooling2D` call to the Keras 2 API: `MaxPooling2D(data_format="channels_last")`
  self.pool = MaxPooling2D(dim_ordering=self.dim_ordering)
Traceback (most recent call last):
  File "kitti_train.py", line 59, in <module>
    errors = prednet(inputs)  # errors will be (batch_size, nt, nb_layers)
  File "/u/suhubdyd/.conda/envs/lisa/lib/python2.7/site-packages/keras/layers/recurrent.py", line 243, in __call__
    return super(Recurrent, self).__call__(inputs, **kwargs)
  File "/u/suhubdyd/.conda/envs/lisa/lib/python2.7/site-packages/keras/engine/topology.py", line 558, in __call__
    self.build(input_shapes[0])
  File "/u/suhubdyd/research/prednet/prednet.py", line 216, in build
    if self.initial_weights is not None:
AttributeError: 'PredNet' object has no attribute 'initial_weights'

@xukai8
Copy link

xukai8 commented Aug 15, 2017

@bill-lotter @arvoelke
I got the same problem, I use the keras==2.0.6 and the tensorflow backend.

Traceback (most recent call last): File "/home/xk/PycharmProjects/prednet/kitti_train.py", line 59, in <module> errors = prednet(inputs) # errors will be (batch_size, nt, nb_layers) File "/home/xk/anaconda3/envs/tf2/lib/python2.7/site-packages/keras/layers/recurrent.py", line 262, in __call__ return super(Recurrent, self).__call__(inputs, **kwargs) File "/home/xk/anaconda3/envs/tf2/lib/python2.7/site-packages/keras/engine/topology.py", line 569, in __call__ self.build(input_shapes[0]) File "/home/xk/PycharmProjects/prednet/prednet.py", line 216, in build if self.initial_weights is not None: AttributeError: 'PredNet' object has no attribute 'initial_weights'

@bill-lotter
Copy link
Contributor

See cc76248 for downloading weights that are compatible with Keras 2.0. You can also convert old PredNet weights for Keras 2.0 by using convert_model_to_keras2 in keras_utils.py.

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

4 participants