|
8 | 8 | }, |
9 | 9 | "outputs": [], |
10 | 10 | "source": [ |
11 | | - "# A Multilayer Perceptron implementation example using TensorFlow library.\n", |
12 | | - "# This example is using the MNIST database of handwritten digits (http://yann.lecun.com/exdb/mnist/)\n", |
| 11 | + "# A Convolutional Networ implementation example using TensorFlow library.\n", |
| 12 | + "# This example is using the MNIST database of handwritten digits\n", |
| 13 | + "# (http://yann.lecun.com/exdb/mnist/)\n", |
13 | 14 | "\n", |
14 | 15 | "# Author: Aymeric Damien\n", |
15 | 16 | "# Project: https://github.com/aymericdamien/TensorFlow-Examples/" |
|
103 | 104 | "source": [ |
104 | 105 | "# Create model\n", |
105 | 106 | "def conv2d(img, w, b):\n", |
106 | | - " return tf.nn.relu(tf.nn.bias_add(tf.nn.conv2d(img, w, strides=[1, 1, 1, 1], padding='SAME'),b))\n", |
| 107 | + " return tf.nn.relu(tf.nn.bias_add(tf.nn.conv2d(img, w, strides=[1, 1, 1, 1], \n", |
| 108 | + " padding='SAME'),b))\n", |
107 | 109 | "\n", |
108 | 110 | "def max_pool(img, k):\n", |
109 | 111 | " return tf.nn.max_pool(img, ksize=[1, k, k, 1], strides=[1, k, k, 1], padding='SAME')\n", |
|
149 | 151 | "source": [ |
150 | 152 | "# Store layers weight & bias\n", |
151 | 153 | "weights = {\n", |
152 | | - " 'wc1': tf.Variable(tf.random_normal([5, 5, 1, 32])), # 5x5 conv, 1 input, 32 outputs\n", |
153 | | - " 'wc2': tf.Variable(tf.random_normal([5, 5, 32, 64])), # 5x5 conv, 32 inputs, 64 outputs\n", |
154 | | - " 'wd1': tf.Variable(tf.random_normal([7*7*64, 1024])), # fully connected, 7*7*64 inputs, 1024 outputs\n", |
155 | | - " 'out': tf.Variable(tf.random_normal([1024, n_classes])) # 1024 inputs, 10 outputs (class prediction)\n", |
| 154 | + " # 5x5 conv, 1 input, 32 outputs\n", |
| 155 | + " 'wc1': tf.Variable(tf.random_normal([5, 5, 1, 32])), \n", |
| 156 | + " # 5x5 conv, 32 inputs, 64 outputs\n", |
| 157 | + " 'wc2': tf.Variable(tf.random_normal([5, 5, 32, 64])), \n", |
| 158 | + " # fully connected, 7*7*64 inputs, 1024 outputs\n", |
| 159 | + " 'wd1': tf.Variable(tf.random_normal([7*7*64, 1024])), \n", |
| 160 | + " # 1024 inputs, 10 outputs (class prediction)\n", |
| 161 | + " 'out': tf.Variable(tf.random_normal([1024, n_classes])) \n", |
156 | 162 | "}\n", |
157 | 163 | "\n", |
158 | 164 | "biases = {\n", |
|
0 commit comments