Path: blob/master/notebooks/book1/14/cnn_mnist_tf.ipynb
1192 views
Kernel: Python 3 (ipykernel)
CNN on (Fashion) MNIST using TF 2.0
In [1]:
In [2]:
Out[2]:
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
|████████████████████████████████| 272 kB 4.1 MB/s
|████████████████████████████████| 119 kB 65.4 MB/s
|████████████████████████████████| 88 kB 8.7 MB/s
|████████████████████████████████| 72 kB 575 kB/s
|████████████████████████████████| 1.1 MB 82.7 MB/s
Building wheel for probml-utils (PEP 517) ... done
Building wheel for TexSoup (setup.py) ... done
Building wheel for umap-learn (setup.py) ... done
Building wheel for pynndescent (setup.py) ... done
In [3]:
In [4]:
Out[4]:
Downloading data from https://storage.googleapis.com/tensorflow/tf-keras-datasets/mnist.npz
11493376/11490434 [==============================] - 0s 0us/step
11501568/11490434 [==============================] - 0s 0us/step
(60000, 28, 28)
In [5]:
Out[5]:
Model: "sequential"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
conv2d (Conv2D) (None, 26, 26, 32) 320
max_pooling2d (MaxPooling2D (None, 13, 13, 32) 0
)
conv2d_1 (Conv2D) (None, 11, 11, 64) 18496
max_pooling2d_1 (MaxPooling (None, 5, 5, 64) 0
2D)
conv2d_2 (Conv2D) (None, 3, 3, 64) 36928
flatten (Flatten) (None, 576) 0
dense (Dense) (None, 64) 36928
dense_1 (Dense) (None, 10) 650
=================================================================
Total params: 93,322
Trainable params: 93,322
Non-trainable params: 0
_________________________________________________________________
In [6]:
In [7]:
Out[7]:
epoch 0
1875/1875 [==============================] - 18s 3ms/step - loss: 0.1502 - accuracy: 0.9532
time spent training 18.256
1875/1875 [==============================] - 4s 2ms/step - loss: 0.0429 - accuracy: 0.9870
Train accuracy: 0.9870333075523376
313/313 [==============================] - 1s 3ms/step - loss: 0.0411 - accuracy: 0.9871
Test accuracy: 0.9871000051498413
(129,)
epoch 1
1875/1875 [==============================] - 6s 3ms/step - loss: 0.0470 - accuracy: 0.9852
time spent training 10.507
1875/1875 [==============================] - 4s 2ms/step - loss: 0.0439 - accuracy: 0.9859
Train accuracy: 0.9859166741371155
313/313 [==============================] - 1s 3ms/step - loss: 0.0466 - accuracy: 0.9846
Test accuracy: 0.9846000075340271
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
In [7]: