print("Execution time to fit 50 epochs: %s minutes" % ((end_time[1] - start_time[1])/60))
Execution time to fit 50 epochs: 8.164830807844798 minutes
nn_plot(hist[1], 50, loss=True, merge=False)
nn_plot(hist[1], 50, acc=True)
By evaluating the metrics we can see that this problem is still very simple to this model, it is still reaching overfitting. This is a good sign, it means that convolutionary neural networks are capable of solving more complex problems.
We will proceed and apply the same model structure to the entire training set, with all 10 digits.
# One hot encoding
y_train_label = tf.keras.utils.to_categorical(y_train)
y_test_label = tf.keras.utils.to_categorical(y_test)
model.append(tf.keras.models.Sequential([
tf.keras.layers.Conv2D(16, (3, 3), input_shape=(28, 28, 1)),
tf.keras.layers.MaxPooling2D(pool_size=(2, 2)),
tf.keras.layers.Conv2D(32, (3, 3)),
tf.keras.layers.MaxPooling2D(pool_size=(2, 2)),
tf.keras.layers.Conv2D(32, (3, 3)),
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(32, activation='relu'),
tf.keras.layers.Dense(10, activation='softmax')
]))
params.append([tf.keras.losses.CategoricalCrossentropy(),
tf.keras.optimizers.Adam(),
tf.keras.metrics.CategoricalAccuracy()])
nn_compile(model[-1], params[-1])