1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| x = tf.placeholder(tf.float32, [None, 3072]) y = tf.placeholder(tf.int64, [None])
x_image = tf.reshape(x, [-1, 3, 32, 32]) x_image = tf.transpose(x_image, perm=[0, 2, 3, 1])
conv1 = tf.layers.conv2d( x_image, 32, (3, 3), padding='same', activation=tf.nn.relu, name='conv1' )
polling1 = tf.layers.max_pooling2d( conv1, (2, 2), (2, 2), name='pool1' ) conv2 = tf.layers.conv2d( polling1, 32, (3, 3), padding='same', activation=tf.nn.relu, name='conv2' )
polling2 = tf.layers.max_pooling2d( conv2, (2, 2), (2, 2), name='pool2' ) conv3 = tf.layers.conv2d( polling2, 32, (3, 3), padding='same', activation=tf.nn.relu, name='conv3' )
polling3 = tf.layers.max_pooling2d( conv3, (2, 2), (2, 2), name='pool3' )
flatten = tf.layers.flatten(polling3) y_ = tf.layers.dense(flatten, 10)
|