|
243 | 243 | " # SOLUTION: Pooling. Input = 10x10x16. Output = 5x5x16.\n",
|
244 | 244 | " conv2 = tf.nn.max_pool(conv2, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='VALID')\n",
|
245 | 245 | "\n",
|
246 |
| - " # SOLUTION: Flatten.\n", |
| 246 | + " # SOLUTION: Flatten. Input = 5x5x16. Output = 400.\n", |
247 | 247 | " fc0 = flatten(conv2)\n",
|
248 | 248 | " \n",
|
249 |
| - " # SOLUTION: Layer 3: Fully Connected. Input = 400 (5x5x16). Output = 120.\n", |
| 249 | + " # SOLUTION: Layer 3: Fully Connected. Input = 400. Output = 120.\n", |
250 | 250 | " fc1_W = tf.Variable(tf.truncated_normal(shape=(400, 120), mean = mu, stddev = sigma))\n",
|
251 | 251 | " fc1_b = tf.Variable(tf.zeros(120))\n",
|
252 | 252 | " fc1 = tf.matmul(fc0, fc1_W) + fc1_b\n",
|
|
350 | 350 | " sess = tf.get_default_session()\n",
|
351 | 351 | " for offset in range(0, num_examples, BATCH_SIZE):\n",
|
352 | 352 | " batch_x, batch_y = X_data[offset:offset+BATCH_SIZE], y_data[offset:offset+BATCH_SIZE]\n",
|
353 |
| - " accuracy = sess.run(accuracy_operation, feed_dict={x: batch_x, y: batch_y})\n", |
| 353 | + " accuracy = sess.run(accuracy_operation, feed_dict={x: batch_x, y: batch_y})\n", |
354 | 354 | " total_accuracy += (accuracy * len(batch_x))\n",
|
355 | 355 | " return total_accuracy / num_examples"
|
356 | 356 | ]
|
|
390 | 390 | " for offset in range(0, num_examples, BATCH_SIZE):\n",
|
391 | 391 | " end = offset + BATCH_SIZE\n",
|
392 | 392 | " batch_x, batch_y = X_train[offset:end], y_train[offset:end]\n",
|
393 |
| - " loss = sess.run(training_operation, feed_dict={x: batch_x, y: batch_y})\n", |
| 393 | + " sess.run(training_operation, feed_dict={x: batch_x, y: batch_y})\n", |
394 | 394 | " \n",
|
395 | 395 | " validation_accuracy = evaluate(X_validation, y_validation)\n",
|
396 | 396 | " print(\"EPOCH {} ...\".format(i+1))\n",
|
|
0 commit comments