shadiakiki1986 / test-ml

some testing in ml
1 stars 0 forks source link

AttributeError: can't set attribute #1

Open mischki opened 6 years ago

mischki commented 6 years ago

Hi, I'm getting this error while trying to run your code(s) (I've tried t1a_pca_ae_simple.ipynb and t1d_pca_ae_nonlinear.ipynb). Could you please help? Thanks in advance.


AttributeError Traceback (most recent call last)

in () 6 # train autoencoder 7 print("autoencoder") ----> 8 autoencoder, encoder = buildNetwork(X_norm.shape[1], encoding_dim_ae = 3) 9 N_epochs = 25 10 autoencoder.fit( ~/Dropbox/work/ML/AutoEncoders/AE_PCA_shadi/utils.py in buildNetwork(input_shape, encoding_dim_ae) 28 29 # hidden layer ---> 30 encoded = Dense( encoding_dim_ae, activation='linear' )(encoded) 31 32 # use leaky relu ~/anaconda/lib/python3.6/site-packages/keras/engine/topology.py in __call__(self, inputs, **kwargs) 573 '`layer.build(batch_input_shape)`') 574 if len(input_shapes) == 1: --> 575 self.build(input_shapes[0]) 576 else: 577 self.build(input_shapes) ~/anaconda/lib/python3.6/site-packages/keras/layers/core.py in build(self, input_shape) 826 name='kernel', 827 regularizer=self.kernel_regularizer, --> 828 constraint=self.kernel_constraint) 829 if self.use_bias: 830 self.bias = self.add_weight(shape=(self.units,), ~/anaconda/lib/python3.6/site-packages/keras/legacy/interfaces.py in wrapper(*args, **kwargs) 85 warnings.warn('Update your `' + object_name + 86 '` call to the Keras 2 API: ' + signature, stacklevel=2) ---> 87 return func(*args, **kwargs) 88 wrapper._original_function = func 89 return wrapper ~/anaconda/lib/python3.6/site-packages/keras/engine/topology.py in add_weight(self, name, shape, dtype, initializer, regularizer, trainable, constraint) 397 dtype=dtype, 398 name=name, --> 399 constraint=constraint) 400 if regularizer is not None: 401 self.add_loss(regularizer(weight)) ~/anaconda/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py in variable(value, dtype, name, constraint) 321 v._uses_learning_phase = False 322 # TODO: move to `tf.get_variable` when supported in public release. --> 323 v.constraint = constraint 324 return v 325 AttributeError: can't set attribute
shadiakiki1986 commented 6 years ago

Hey there. What keras/tensorflow version do you have installed? The error you pasted seems to stem from keras and tensorflow

On Sun, May 6, 2018, 19:28 mischki notifications@github.com wrote:

Hi, I'm getting this error while trying to run your code(s) (I've tried t1a_pca_ae_simple.ipynb and t1d_pca_ae_nonlinear.ipynb). Could you please help? Thanks in advance.

AttributeError Traceback (most recent call last) in () 6 # train autoencoder 7 print("autoencoder") ----> 8 autoencoder, encoder = buildNetwork(X_norm.shape[1], encoding_dim_ae = 3) 9 N_epochs = 25 10 autoencoder.fit(

~/Dropbox/work/ML/AutoEncoders/AE_PCA_shadi/utils.py in buildNetwork(input_shape, encoding_dim_ae) 28 29 # hidden layer ---> 30 encoded = Dense( encoding_dim_ae, activation='linear' )(encoded) 31 32 # use leaky relu

~/anaconda/lib/python3.6/site-packages/keras/engine/topology.py in call(self, inputs, **kwargs) 573 'layer.build(batch_input_shape)') 574 if len(input_shapes) == 1: --> 575 self.build(input_shapes[0]) 576 else: 577 self.build(input_shapes)

~/anaconda/lib/python3.6/site-packages/keras/layers/core.py in build(self, input_shape) 826 name='kernel', 827 regularizer=self.kernel_regularizer, --> 828 constraint=self.kernel_constraint) 829 if self.use_bias: 830 self.bias = self.add_weight(shape=(self.units,),

~/anaconda/lib/python3.6/site-packages/keras/legacy/interfaces.py in wrapper(*args, *kwargs) 85 warnings.warn('Update your ' + object_name + 86 ' call to the Keras 2 API: ' + signature, stacklevel=2) ---> 87 return func(args, **kwargs) 88 wrapper._original_function = func 89 return wrapper

~/anaconda/lib/python3.6/site-packages/keras/engine/topology.py in add_weight(self, name, shape, dtype, initializer, regularizer, trainable, constraint) 397 dtype=dtype, 398 name=name, --> 399 constraint=constraint) 400 if regularizer is not None: 401 self.add_loss(regularizer(weight))

~/anaconda/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py in variable(value, dtype, name, constraint) 321 v._uses_learning_phase = False 322 # TODO: move to tf.get_variable when supported in public release. --> 323 v.constraint = constraint 324 return v 325

AttributeError: can't set attribute

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/shadiakiki1986/test-ml/issues/1, or mute the thread https://github.com/notifications/unsubscribe-auth/AIAOhDu3EXNkoZudEvg0dIhyZA7317pgks5tvySsgaJpZM4T0GZ3 .