Finding the best learning rate
#model
tf.random.set_seed(42) model_7 = tf.keras.Sequential([ tf.keras.layers.Dense(4, activation='relu'), tf.keras.layers.Dense(4, activation='relu'), tf.keras.layers.Dense(1, activation='sigmoid')
]) model_7.compile(optimizer=tf.keras.optimizers.Adam(), loss='binary_crossentropy', metrics=['accuracy']) # callback
lr_scheduler = tf.keras.callbacks.LearningRateScheduler(lambda epoch: 1e-4 * 10**(epoch/20)) history_7 = model_7.fit(X_train, y_train, epochs=100, callbacks=[lr_scheduler]) # plot learning rate vs the loss
plt.figure(figsize=(10, 7))
plt.semilogx(history_7.history['lr'], history_7.history['loss'])
plt.xlabel('Learning Rate')
plt.ylabel('Loss')
plt.title('Learning Rate vs Loss');