fig, (ax1, ax2) = plt.subplots(1, 2, sharey=True, figsize=(16, 5))
nn_plot(hist[1], 50, subplot=ax1, loss=True, title="Reference: eta 0.5")
nn_plot(hist[2], 50, subplot=ax2, loss=True, title="eta 1")
fig, (ax1, ax2) = plt.subplots(1, 2, sharey=True, figsize=(16, 5))
nn_plot(hist[1], 50, subplot=ax1, acc=True, title="Reference: eta 0.5")
nn_plot(hist[2], 50, subplot=ax2, acc=True, title="eta 1")
If we lower $\eta$ value, the model learns slowlier but is able to converge to optimal value. Now we try $\eta = 0.01$.
model.append(tf.keras.models.Sequential([
tf.keras.layers.Dense(30, kernel_regularizer=tf.keras.regularizers.l2(0.01),
activation=tf.nn.sigmoid, input_shape=(784,), name='hidden_1_layer'),
tf.keras.layers.Dense(10, activation='softmax', name='output_layer')
]))
params.append([tf.keras.losses.SparseCategoricalCrossentropy(),
tf.optimizers.SGD(learning_rate=0.01),
tf.keras.metrics.SparseCategoricalAccuracy()])
nn_compile(model[-1], params[-1])