Get learning rate of keras model
Use eval()
from keras.backend
:
import keras.backend as K
from keras.models import Sequential
from keras.layers import Dense
model = Sequential()
model.add(Dense(1, input_shape=(1,)))
model.add(Dense(1))
model.compile(loss='mse', optimizer='adam')
print(K.eval(model.optimizer.lr))
Output:
0.001
The best way to get all information related to the optimizer would be with .get_config()
.
Example:
model.compile(optimizer=optimizerF,
loss=lossF,
metrics=['accuracy'])
model.optimizer.get_config()
>>> {'name': 'Adam', 'learning_rate': 0.001, 'decay': 0.0, 'beta_1': 0.9, 'beta_2': 0.999, 'epsilon': 1e-07, 'amsgrad': False}
It returns a dict with all information.