|
@@ -8,8 +8,9 @@
|
|
|
},
|
|
|
"outputs": [],
|
|
|
"source": [
|
|
|
- "# A Multilayer Perceptron implementation example using TensorFlow library.\n",
|
|
|
- "# This example is using the MNIST database of handwritten digits (http://yann.lecun.com/exdb/mnist/)\n",
|
|
|
+ "# A Convolutional Networ implementation example using TensorFlow library.\n",
|
|
|
+ "# This example is using the MNIST database of handwritten digits\n",
|
|
|
+ "# (http://yann.lecun.com/exdb/mnist/)\n",
|
|
|
"\n",
|
|
|
"# Author: Aymeric Damien\n",
|
|
|
"# Project: https://github.com/aymericdamien/TensorFlow-Examples/"
|
|
@@ -103,7 +104,8 @@
|
|
|
"source": [
|
|
|
"# Create model\n",
|
|
|
"def conv2d(img, w, b):\n",
|
|
|
- " return tf.nn.relu(tf.nn.bias_add(tf.nn.conv2d(img, w, strides=[1, 1, 1, 1], padding='SAME'),b))\n",
|
|
|
+ " return tf.nn.relu(tf.nn.bias_add(tf.nn.conv2d(img, w, strides=[1, 1, 1, 1], \n",
|
|
|
+ " padding='SAME'),b))\n",
|
|
|
"\n",
|
|
|
"def max_pool(img, k):\n",
|
|
|
" return tf.nn.max_pool(img, ksize=[1, k, k, 1], strides=[1, k, k, 1], padding='SAME')\n",
|
|
@@ -149,10 +151,14 @@
|
|
|
"source": [
|
|
|
"# Store layers weight & bias\n",
|
|
|
"weights = {\n",
|
|
|
- " 'wc1': tf.Variable(tf.random_normal([5, 5, 1, 32])), # 5x5 conv, 1 input, 32 outputs\n",
|
|
|
- " 'wc2': tf.Variable(tf.random_normal([5, 5, 32, 64])), # 5x5 conv, 32 inputs, 64 outputs\n",
|
|
|
- " 'wd1': tf.Variable(tf.random_normal([7*7*64, 1024])), # fully connected, 7*7*64 inputs, 1024 outputs\n",
|
|
|
- " 'out': tf.Variable(tf.random_normal([1024, n_classes])) # 1024 inputs, 10 outputs (class prediction)\n",
|
|
|
+ " # 5x5 conv, 1 input, 32 outputs\n",
|
|
|
+ " 'wc1': tf.Variable(tf.random_normal([5, 5, 1, 32])), \n",
|
|
|
+ " # 5x5 conv, 32 inputs, 64 outputs\n",
|
|
|
+ " 'wc2': tf.Variable(tf.random_normal([5, 5, 32, 64])), \n",
|
|
|
+ " # fully connected, 7*7*64 inputs, 1024 outputs\n",
|
|
|
+ " 'wd1': tf.Variable(tf.random_normal([7*7*64, 1024])), \n",
|
|
|
+ " # 1024 inputs, 10 outputs (class prediction)\n",
|
|
|
+ " 'out': tf.Variable(tf.random_normal([1024, n_classes])) \n",
|
|
|
"}\n",
|
|
|
"\n",
|
|
|
"biases = {\n",
|