Machine-learning-Course

CNN on MNIST and SigmoidNeuron re-runs, 2026-10-14

CNN_Identify_the_Digits_(MNIST).ipynb was executed top to bottom on a CPU with its original training settings, unreduced. An earlier audit judged it too slow for the 20-minute limit; timing it showed otherwise (about 13 ms per training step at batch size 10), so no reduction was needed.

Settings (as written in the notebook’s training cell)

Item Value
Data MNIST via keras.datasets.mnist: 60,000 training images, 10,000 test images, pixels scaled to 0..1
Architecture (unchanged) Conv2D 32 (3x3) - Conv2D 64 (3x3) - MaxPool 2x2 - Dropout 0.25 - Flatten - Dense 256 - Dropout 0.5 - Dense 10 softmax; 2,380,938 parameters
Optimiser, loss Adam (defaults), categorical cross-entropy
Training epochs=5, batch_size=10 (6,000 steps per epoch, 30,000 in total), validation_data=(x_test, y_test)
Seeds none (the notebook sets none), PYTHONHASHSEED=0 only

Hardware and software

AMD Ryzen 7 5800X (8 cores, 16 threads), 32 GB RAM, Windows 11, no GPU used. Python 3.11.9, TensorFlow 2.15.1, Keras 2.15.0, NumPy 1.26.4, scikit-learn 1.5.2, matplotlib 3.9.2, nbconvert 7.16.4 (versions as in requirements.txt).

Command

KERAS_HOME=<local cache> PYTHONHASHSEED=0 timeout 1200 python -m jupyter nbconvert --to notebook --execute --inplace \
  --ExecutePreprocessor.timeout=1200 --ExecutePreprocessor.kernel_name=python3 CNN_mnist.ipynb

The run was made on a copy in a scratch folder so that mnist.h5 (git-ignored) and model_plot.png were not written into the repository.

Result

Measure Value
Wall time of the whole notebook 708 s (11.8 min), under the 20-minute limit
Training time (sum of the 5 epochs) 577 s
Final training accuracy (epoch 5) 0.9894
Final test accuracy 0.9905 (0.9904999732971191); test loss 0.02974; 9,905 of 10,000 correct, 95 wrong
Errors in stored outputs 0 (35 of 41 code cells have output)
Epoch Time Train loss Train acc Val (= test) loss Val (= test) acc
1 85 s 0.1420 0.9558 0.0445 0.9849
2 117 s 0.0668 0.9799 0.0373 0.9879
3 130 s 0.0517 0.9844 0.0376 0.9890
4 116 s 0.0421 0.9873 0.0335 0.9896
5 129 s 0.0340 0.9894 0.0297 0.9905

The test set also served as the validation set during training, as in the original notebook. No settings were chosen using it, but it is not an independent hold-out beyond that. The numbers are unseeded and will differ a little in a new run. They replace the earlier stored output (test accuracy 0.8815), which came from an earlier, different run (its stored training log stops mid-epoch) and was not produced by these settings.

Changes made to the notebook so that it runs here

Edits to the stored outputs after the run

SigmoidNeuron

The notebook is self-contained (synthetic data). It was executed with the same command in 56 s with 0 errors; 13 of 26 code cells have output. It needed one change: from tqdm import tqdm_notebook (a widget progress bar that fails without ipywidgets) became tqdm; tqdm==4.70.1 was added to requirements.txt. Its data is random and unseeded, so the printed values differ from the earlier stored ones. The grid search recovered weight 0.5 and bias 0.24 (true values 0.5 and 0.25). A temporary-folder path in one warning was replaced by ...\Temp.

Not re-run (reasons unchanged)

ANN_using_pytorch (PyTorch not installed or pinned), ANN_using_tensorflow (ann_visualizer and Graphviz), Natural_Language_Processing_with_Disaster_Tweets and titanic-tutorial (Kaggle data needs a login), diabetes, tip_amount_tensorflow and world_alcohol_pandas_revision (data not in the repository).