Created
January 5, 2019 15:15
-
-
Save hadifar/0041f6d35d00124a22d02309df3e364d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def neural_net_model(inputs, mode): | |
with tf.variable_scope('ConvModel'): | |
inputs = inputs / 255 | |
input_layer = tf.reshape(inputs, [-1, 28, 28, 1]) | |
conv1 = tf.layers.conv2d( | |
inputs=input_layer, | |
filters=20, | |
kernel_size=[5, 5], | |
padding='valid', | |
activation=tf.nn.relu) | |
pool1 = tf.layers.max_pooling2d(inputs=conv1, pool_size=[2, 2], strides=2) | |
conv2 = tf.layers.conv2d( | |
inputs=pool1, | |
filters=40, | |
kernel_size=[5, 5], | |
padding='valid', | |
activation=tf.nn.relu) | |
pool2 = tf.layers.max_pooling2d(inputs=conv2, pool_size=[2, 2], strides=2) | |
flatten = tf.reshape(pool2, [-1, 4 * 4 * 40]) | |
dense1 = tf.layers.dense(inputs=flatten, units=256, activation=tf.nn.relu) | |
dropout = tf.layers.dropout( | |
inputs=dense1, rate=0.5, training=mode == tf.estimator.ModeKeys.TRAIN) | |
dense2 = tf.layers.dense(inputs=dropout, units=10) | |
return dense2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment