Kyle Dampier commited on
Commit
1bd7363
1 Parent(s): a11556c

Updated model training and running to CPU

Browse files
Files changed (2) hide show
  1. Week1.ipynb +33 -21
  2. mnist.h5 +1 -1
Week1.ipynb CHANGED
@@ -25,8 +25,12 @@
25
  "outputs": [],
26
  "source": [
27
  "import numpy as np\n",
 
28
  "from tensorflow import keras\n",
29
- "from tensorflow.keras import layers"
 
 
 
30
  ]
31
  },
32
  {
@@ -73,7 +77,8 @@
73
  "\n",
74
  "# convert class vectors to binary class matrices\n",
75
  "y_train = keras.utils.to_categorical(y_train, num_classes)\n",
76
- "y_test = keras.utils.to_categorical(y_test, num_classes)"
 
77
  ]
78
  },
79
  {
@@ -166,41 +171,41 @@
166
  "output_type": "stream",
167
  "text": [
168
  "Epoch 1/15\n",
169
- "422/422 [==============================] - 4s 3ms/step - loss: 0.3724 - accuracy: 0.8837 - val_loss: 0.0810 - val_accuracy: 0.9785\n",
170
  "Epoch 2/15\n",
171
- "422/422 [==============================] - 1s 3ms/step - loss: 0.1118 - accuracy: 0.9671 - val_loss: 0.0562 - val_accuracy: 0.9852\n",
172
  "Epoch 3/15\n",
173
- "422/422 [==============================] - 1s 2ms/step - loss: 0.0835 - accuracy: 0.9739 - val_loss: 0.0481 - val_accuracy: 0.9872\n",
174
  "Epoch 4/15\n",
175
- "422/422 [==============================] - 1s 2ms/step - loss: 0.0700 - accuracy: 0.9787 - val_loss: 0.0404 - val_accuracy: 0.9898\n",
176
  "Epoch 5/15\n",
177
- "422/422 [==============================] - 1s 3ms/step - loss: 0.0604 - accuracy: 0.9815 - val_loss: 0.0381 - val_accuracy: 0.9910\n",
178
  "Epoch 6/15\n",
179
- "422/422 [==============================] - 1s 2ms/step - loss: 0.0559 - accuracy: 0.9826 - val_loss: 0.0354 - val_accuracy: 0.9903\n",
180
  "Epoch 7/15\n",
181
- "422/422 [==============================] - 1s 2ms/step - loss: 0.0505 - accuracy: 0.9829 - val_loss: 0.0338 - val_accuracy: 0.9903\n",
182
  "Epoch 8/15\n",
183
- "422/422 [==============================] - 1s 2ms/step - loss: 0.0484 - accuracy: 0.9847 - val_loss: 0.0296 - val_accuracy: 0.9923\n",
184
  "Epoch 9/15\n",
185
- "422/422 [==============================] - 1s 2ms/step - loss: 0.0443 - accuracy: 0.9860 - val_loss: 0.0333 - val_accuracy: 0.9912\n",
186
  "Epoch 10/15\n",
187
- "422/422 [==============================] - 1s 2ms/step - loss: 0.0422 - accuracy: 0.9869 - val_loss: 0.0308 - val_accuracy: 0.9927\n",
188
  "Epoch 11/15\n",
189
- "422/422 [==============================] - 1s 2ms/step - loss: 0.0397 - accuracy: 0.9874 - val_loss: 0.0321 - val_accuracy: 0.9922\n",
190
  "Epoch 12/15\n",
191
- "422/422 [==============================] - 1s 2ms/step - loss: 0.0375 - accuracy: 0.9875 - val_loss: 0.0269 - val_accuracy: 0.9928\n",
192
  "Epoch 13/15\n",
193
- "422/422 [==============================] - 1s 2ms/step - loss: 0.0355 - accuracy: 0.9886 - val_loss: 0.0296 - val_accuracy: 0.9925\n",
194
  "Epoch 14/15\n",
195
- "422/422 [==============================] - 1s 2ms/step - loss: 0.0340 - accuracy: 0.9888 - val_loss: 0.0291 - val_accuracy: 0.9928\n",
196
  "Epoch 15/15\n",
197
- "422/422 [==============================] - 1s 3ms/step - loss: 0.0321 - accuracy: 0.9894 - val_loss: 0.0277 - val_accuracy: 0.9927\n"
198
  ]
199
  },
200
  {
201
  "data": {
202
  "text/plain": [
203
- "<keras.callbacks.History at 0x14a08dfc3d0>"
204
  ]
205
  },
206
  "execution_count": 5,
@@ -230,8 +235,8 @@
230
  "name": "stdout",
231
  "output_type": "stream",
232
  "text": [
233
- "Test loss: 0.02324853651225567\n",
234
- "Test accuracy: 0.9922000169754028\n"
235
  ]
236
  }
237
  ],
@@ -250,12 +255,19 @@
250
  },
251
  {
252
  "cell_type": "code",
253
- "execution_count": 7,
254
  "metadata": {},
255
  "outputs": [],
256
  "source": [
257
  "model.save(\"mnist.h5\")"
258
  ]
 
 
 
 
 
 
 
259
  }
260
  ],
261
  "metadata": {
 
25
  "outputs": [],
26
  "source": [
27
  "import numpy as np\n",
28
+ "import tensorflow as tf\n",
29
  "from tensorflow import keras\n",
30
+ "from tensorflow.keras import layers\n",
31
+ "\n",
32
+ "# Hide GPU from visible devices\n",
33
+ "tf.config.set_visible_devices([], 'GPU')"
34
  ]
35
  },
36
  {
 
77
  "\n",
78
  "# convert class vectors to binary class matrices\n",
79
  "y_train = keras.utils.to_categorical(y_train, num_classes)\n",
80
+ "y_test = keras.utils.to_categorical(y_test, num_classes)\n",
81
+ "# [1, 2, 3, 4] -> [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]\n"
82
  ]
83
  },
84
  {
 
171
  "output_type": "stream",
172
  "text": [
173
  "Epoch 1/15\n",
174
+ "422/422 [==============================] - 9s 20ms/step - loss: 0.3573 - accuracy: 0.8919 - val_loss: 0.0857 - val_accuracy: 0.9777\n",
175
  "Epoch 2/15\n",
176
+ "422/422 [==============================] - 8s 19ms/step - loss: 0.1184 - accuracy: 0.9636 - val_loss: 0.0608 - val_accuracy: 0.9825\n",
177
  "Epoch 3/15\n",
178
+ "422/422 [==============================] - 8s 19ms/step - loss: 0.0862 - accuracy: 0.9733 - val_loss: 0.0496 - val_accuracy: 0.9868\n",
179
  "Epoch 4/15\n",
180
+ "422/422 [==============================] - 8s 20ms/step - loss: 0.0724 - accuracy: 0.9778 - val_loss: 0.0424 - val_accuracy: 0.9883\n",
181
  "Epoch 5/15\n",
182
+ "422/422 [==============================] - 8s 19ms/step - loss: 0.0656 - accuracy: 0.9793 - val_loss: 0.0398 - val_accuracy: 0.9895\n",
183
  "Epoch 6/15\n",
184
+ "422/422 [==============================] - 8s 20ms/step - loss: 0.0591 - accuracy: 0.9816 - val_loss: 0.0361 - val_accuracy: 0.9912\n",
185
  "Epoch 7/15\n",
186
+ "422/422 [==============================] - 8s 20ms/step - loss: 0.0522 - accuracy: 0.9833 - val_loss: 0.0315 - val_accuracy: 0.9922\n",
187
  "Epoch 8/15\n",
188
+ "422/422 [==============================] - 8s 20ms/step - loss: 0.0485 - accuracy: 0.9846 - val_loss: 0.0319 - val_accuracy: 0.9910\n",
189
  "Epoch 9/15\n",
190
+ "422/422 [==============================] - 9s 20ms/step - loss: 0.0447 - accuracy: 0.9858 - val_loss: 0.0331 - val_accuracy: 0.9917\n",
191
  "Epoch 10/15\n",
192
+ "422/422 [==============================] - 9s 21ms/step - loss: 0.0416 - accuracy: 0.9871 - val_loss: 0.0309 - val_accuracy: 0.9922\n",
193
  "Epoch 11/15\n",
194
+ "422/422 [==============================] - 8s 20ms/step - loss: 0.0397 - accuracy: 0.9877 - val_loss: 0.0281 - val_accuracy: 0.9932\n",
195
  "Epoch 12/15\n",
196
+ "422/422 [==============================] - 9s 20ms/step - loss: 0.0393 - accuracy: 0.9874 - val_loss: 0.0308 - val_accuracy: 0.9908\n",
197
  "Epoch 13/15\n",
198
+ "422/422 [==============================] - 8s 20ms/step - loss: 0.0373 - accuracy: 0.9882 - val_loss: 0.0276 - val_accuracy: 0.9928\n",
199
  "Epoch 14/15\n",
200
+ "422/422 [==============================] - 8s 19ms/step - loss: 0.0357 - accuracy: 0.9879 - val_loss: 0.0265 - val_accuracy: 0.9935\n",
201
  "Epoch 15/15\n",
202
+ "422/422 [==============================] - 8s 19ms/step - loss: 0.0334 - accuracy: 0.9886 - val_loss: 0.0298 - val_accuracy: 0.9927\n"
203
  ]
204
  },
205
  {
206
  "data": {
207
  "text/plain": [
208
+ "<keras.callbacks.History at 0x2242fa4c220>"
209
  ]
210
  },
211
  "execution_count": 5,
 
235
  "name": "stdout",
236
  "output_type": "stream",
237
  "text": [
238
+ "Test loss: 0.02596166729927063\n",
239
+ "Test accuracy: 0.9919000267982483\n"
240
  ]
241
  }
242
  ],
 
255
  },
256
  {
257
  "cell_type": "code",
258
+ "execution_count": 13,
259
  "metadata": {},
260
  "outputs": [],
261
  "source": [
262
  "model.save(\"mnist.h5\")"
263
  ]
264
+ },
265
+ {
266
+ "cell_type": "code",
267
+ "execution_count": null,
268
+ "metadata": {},
269
+ "outputs": [],
270
+ "source": []
271
  }
272
  ],
273
  "metadata": {
mnist.h5 CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:6b9d7830249bb932ad3715ba3d277c9415cd8a8a4c6d100eb6a1f8568f58fa8f
3
  size 455304
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f86dd360a2a044d621faffa7d748a1a8154395656af6b76b7b687272c04cac35
3
  size 455304