TransWikia.com

How to see/change learning rate in Keras LSTM?

Data Science Asked on July 13, 2021

I see in some question/answers that ask to decrease the learning rate. But I don’t know how can I see and change the learning rate of LSTM model in Keras library?

One Answer

In Keras, you can set the learning rate as a parameter for the optimization method, the piece of code below is an example from Keras documentation:

    from keras import optimizers

   model = Sequential()
   model.add(Dense(64, kernel_initializer='uniform', input_shape=(10,)))
   model.add(Activation('softmax'))

   sgd = optimizers.SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True)
   model.compile(loss='mean_squared_error', optimizer=sgd)

In the above code, the fifth line lr is learning rate, which in this code is set to 0.01. You change it to whatever you want.

For further detail, see this link.

Please tell me if this helped to solve your problem.

Correct answer by Hunar on July 13, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP