fig, (ax1, ax2) = plt.subplots(1, 2, sharey=True, sharex=True, figsize=(16, 5))
nn_plot(hist[17], 200, subplot=ax1, loss=True, title="Reference: lambda = 0.01")
nn_plot(hist[22], 200, subplot=ax2, loss=True, title="lambda = 0.001")
fig, (ax1, ax2) = plt.subplots(1, 2, sharey=True, sharex=True, figsize=(16, 5))
nn_plot(hist[17], 200, subplot=ax1, acc=True, title="Reference: lambda = 0.01")
nn_plot(hist[22], 200, subplot=ax2, acc=True, title="lambda = 0.001")
Since regularization helps reduce overfitting, decreasing the $\lambda$ value makes the model more susceptible to overfitting, which is not desirable. The training accuracy approaches 100%, which indicates overfitting.
Our next step will be using $\lambda = 0.1$, ten times bigger the default value.
model.append(tf.keras.models.Sequential([
tf.keras.layers.Dense(100, kernel_regularizer=tf.keras.regularizers.l2(0.1),
activation='relu', input_shape=(784,), name='hidden_1_layer'),
tf.keras.layers.Dense(10, activation='softmax', name='output_layer')
]))
nn_compile(model[-1], params[3])