Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 8646210

Browse files
committed
+ Comments for mnist example
1 parent 8e34153 commit 8646210

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

examples/mnist.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,26 @@ def max_pool_2x2(tensor_in):
4545
padding='SAME')
4646

4747
def conv_model(X, y):
48+
# reshape X to 4d tensor with 2nd and 3rd dimensions being image width and height
49+
# final dimension being the number of color channels
4850
X = tf.reshape(X, [-1, 28, 28, 1])
51+
# first conv layer will compute 32 features for each 5x5 patch
4952
with tf.variable_scope('conv_layer1'):
5053
h_conv1 = skflow.ops.conv2d(X, n_filters=32, filter_shape=[5, 5],
5154
bias=True, activation=tf.nn.relu)
5255
h_pool1 = max_pool_2x2(h_conv1)
56+
# second conv layer will compute 64 features for each 5x5 patch
5357
with tf.variable_scope('conv_layer2'):
5458
h_conv2 = skflow.ops.conv2d(h_pool1, n_filters=64, filter_shape=[5, 5],
5559
bias=True, activation=tf.nn.relu)
5660
h_pool2 = max_pool_2x2(h_conv2)
61+
# reshape tensor into a batch of vectors
5762
h_pool2_flat = tf.reshape(h_pool2, [-1, 7 * 7 * 64])
63+
# densely connected layer with 1024 neurons
5864
h_fc1 = skflow.ops.dnn(h_pool2_flat, [1024], activation=tf.nn.relu, keep_prob=0.5)
5965
return skflow.models.logistic_regression(h_fc1, y)
6066

67+
# Training and predicting
6168
classifier = skflow.TensorFlowEstimator(
6269
model_fn=conv_model, n_classes=10, batch_size=100, steps=20000,
6370
learning_rate=0.001)

0 commit comments

Comments
 (0)