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

AttributeError: 'Tensor' object has no attribute 'assign' #2

Closed
SergeKrier opened this issue Apr 25, 2017 · 4 comments
Closed

AttributeError: 'Tensor' object has no attribute 'assign' #2

SergeKrier opened this issue Apr 25, 2017 · 4 comments

Comments

@SergeKrier
Copy link

Hi Felix, thanks for providing the resnet152 model in keras + weights.
However I have the following error when trying to run it :

File "resnet_152.py", line 252, in
model = resnet152_model(img_rows, img_cols, channel, num_class)
File "resnet_152.py", line 222, in resnet152_model
model.load_weights(weights_path)
File "/usr/local/lib/python3.4/dist-packages/keras/engine/topology.py", line 2500, in load_weights
load_weights_from_hdf5_group(f, self.layers)
File "/usr/local/lib/python3.4/dist-packages/keras/engine/topology.py", line 2913, in load_weights_from_hdf5_group
K.batch_set_value(weight_value_tuples)
File "/usr/local/lib/python3.4/dist-packages/keras/backend/tensorflow_backend.py", line 2022, in batch_set_value
assign_op = x.assign(assign_placeholder)
AttributeError: 'Tensor' object has no attribute 'assign'

tensorflow: 1.0.1
keras: 2.0.3

thanks

@flyyufelix
Copy link
Owner

Right now ResNet-152 supports Keras 1.2.2 and Tensorflow 0.12.0. The error you are seeing should be related to Tensorflow versioning. I will try to get the models work for the latest versions as soon as possible.

@SergeKrier
Copy link
Author

Hi Felix, I see it closed don't see any recent commit for this.thanks

@flyyufelix flyyufelix reopened this Apr 29, 2017
@lef-fan
Copy link

lef-fan commented May 23, 2017

Hello, same issue here for Keras 2.0.3 and Tensorflow 1.1.0
Couldn't wait for it so I gave it a try.

At scale_layer.py change:

self.gamma = self.gamma_init(shape, name='{}_gamma'.format(self.name))
self.beta = self.beta_init(shape, name='{}_beta'.format(self.name))

to:

self.gamma = K.variable(self.gamma_init(shape), name='{}_gamma'.format(self.name))
self.beta = K.variable(self.beta_init(shape), name='{}_beta'.format(self.name))

"edited"
Check my repo here for an update to Keras 2.0.3 and Tensorflow 1.1.0, without the Cifar10 example.

@flyyufelix
Copy link
Owner

Thanks @lef-fan for the suggested patch, and apologize for the delay @SergeKrier . I've already made the necessary changes to get the code to work with the latest versions of Keras (2.0.5) and TensorFlow (1.2.1)

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

3 participants