AttributeError: can't set attribute
See original GitHub issueI updated my keras from 2.0.6 to 2.0.7. Then the following code (works fine with 2.0.6) produces strange errors:
>>> import keras as K
Using TensorFlow backend.
>>> model = K.models.Sequential()
>>> l1 = K.layers.Conv2D(1, 1, input_shape=(2, 2, 2))
>>> model.add(l1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/jet/anaconda3/lib/python3.6/site-packages/keras/models.py", line 442, in add
layer(x)
File "/home/jet/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py", line 575, in __call__
self.build(input_shapes[0])
File "/home/jet/anaconda3/lib/python3.6/site-packages/keras/layers/convolutional.py", line 134, in build
constraint=self.kernel_constraint)
File "/home/jet/anaconda3/lib/python3.6/site-packages/keras/legacy/interfaces.py", line 87, in wrapper
return func(*args, **kwargs)
File "/home/jet/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py", line 399, in add_weight
constraint=constraint)
File "/home/jet/anaconda3/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py", line 323, in variable
v.constraint = constraint
AttributeError: can't set attribute
The backend is tensorflow 1.3 compiled with CUDA (it works fine with keras-2.0.6).
Issue Analytics
- State:
- Created 6 years ago
- Reactions:9
- Comments:9 (2 by maintainers)
Top Results From Across the Web
python - AttributeError: can't set attribute - Stack Overflow
This specific exception "AttributeError: can't set attribute" is raised (see source) when the attribute you're attempting to change is ...
Read more >[Solved] AttributeError: can't set attribute in python - Finxter
The easiest way to fix the AttributeError:can't set attribute is to create a new namedtuple object with the namedtuple._replace() method.
Read more >Python error saying \"AttributeError: can\'t set attribute\". How is ...
The explanation you are getting this error is that you are naming the setter method mistakenly. You have named the setter method as...
Read more >Python error saying "AttributeError: can't set attribute" - Intellipaat
The reason you are getting this error is because you are naming the setter method incorrectly. You have named the setter method as...
Read more >AttributeError: can't set attribute in example/basic.py #256
Code copied verbatim from example/basic.py; python version is 3.9.6; oddly I don't see the error in my actual work, but I needed to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Don’t override
self.weights
; call yoursself.attention_weights
.I get the same error from the following code: model_1 = Sequential([Dense(units=hidden_1_num_units, input_dim=g_input_shape, activation=‘relu’, kernel_regularizer=L1L2(l1=1e-5, l2=1e-5)), Dense(units=hidden_2_num_units, activation=‘relu’, kernel_regularizer=L1L2(l1=1e-5, l2=1e-5)), Dense(units=g_output_num_units, activation=‘sigmoid’, kernel_regularizer=L1L2(l1=1e-5, l2=1e-5)), Reshape(d_input_shape)]) model_2 = Sequential([InputLayer(input_shape=d_input_shape), Flatten(), Dense(units=hidden_1_num_units, activation=‘relu’, kernel_regularizer=L1L2(l1=1e-5, l2=1e-5)), Dense(units=hidden_2_num_units, activation=‘relu’, kernel_regularizer=L1L2(l1=1e-5, l2=1e-5)), Dense(units=d_output_num_units, activation=‘sigmoid’, kernel_regularizer=L1L2(l1=1e-5, l2=1e-5))])
model_1.summary() model_2.summary()
ganModel = simple_gan(model_1, model_2, normal_latent_sampling((100,))) model = AdversarialModel(base_model=ganModel, player_params=[model_1.trainable_weights, model_2.trainable_weights])
Traceback (most recent call last): File “C:/Users/NAYAKAB/Desktop/Personal/PycharmProjects/KF/gan.py”, line 60, in <module> model = AdversarialModel(base_model=ganModel, player_params=[model_1.trainable_weights, model_2.trainable_weights]) File “C:\Softwares\Python3\lib\site-packages\keras_adversarial\adversarial_model.py”, line 44, in init self.layers = [] File “C:\Softwares\Python3\lib\site-packages\keras\engine\network.py”, line 316, in setattr super(Network, self).setattr(name, value) AttributeError: can’t set attribute
Any Help?