Skip to content

Commit 0ac2e6d

Browse files
author
Ryo Miyajima
committed
define functions for expert example
1 parent 4a5d592 commit 0ac2e6d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

mnist.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@
2929
IMAGE_SIZE = 28
3030
IMAGE_PIXELS = IMAGE_SIZE * IMAGE_SIZE
3131

32+
def weight_variable(shape):
33+
initial = tf.truncated_normal(shape, stddev=0.1)
34+
return tf.Variable(initial)
35+
36+
def bias_variable(shape):
37+
initial = tf.constant(0.1, shape=shape)
38+
return tf.Variable(initial)
39+
40+
def conv2d(x, W):
41+
return tf.nn.conv2d(x, W, strides=[1,1,1,1], padding='SAME')
42+
43+
def max_pool_2x2(x):
44+
return tf.nn.max_pool(x, ksize=[1, 2, 2, 1], strides=[1,2,2,1], padding='SAME')
3245

3346
def inference(images, hidden1_units, hidden2_units):
3447
"""Build the MNIST model up to where it may be used for inference.

0 commit comments

Comments
 (0)