OverLordGoldDragon / keras-adamw

Keras/TF implementation of AdamW, SGDW, NadamW, Warm Restarts, and Learning Rate multipliers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AttributeError: can't set attribute

unnir opened this issue · comments

Hi,

I'm using keras - 2.3.1
and TF - '1.15.2-dlenv_tfe'

my code:

        model = Model(inputs=inp, outputs=out)
        
        optimizer = AdamW(model, lr=1e-4)

        model.compile(loss='mse', optimizer=optimizer)

And I'm getting:

     68         with K.name_scope(self.__class__.__name__):
     69             self.iterations = K.variable(0, dtype='int64', name='iterations')
---> 70             self.lr = K.variable(lr, name='lr')
     71             self.beta_1 = K.variable(beta_1, name='beta_1')
     72             self.beta_2 = K.variable(beta_2, name='beta_2')

AttributeError: can't set attribute

The automated import from keras_adamw import AdamW assumes TF 2+ with Keras 2.3+ for optimization, but you should be able to use from keras_adamw.optimizers import AdamW for TF 1. Let me know if it works.

This has been fixed in 1.21, now released; from keras_adamw import AdamW should work properly now. Feel free to reopen if issues persist.

thank you!