AyushP123

tensorflow_dropout

Apr 9th, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.50 KB | None | 0 0
  1. isTraining = tf.placeholder(tf.bool, name='isTraining')
  2. images_placeholder = tf.placeholder(tf.float32, [None, training_images.shape[1], training_images.shape[2], 1], name = "input_node")
  3.  
  4. with tf.name_scope('Conv1'):
  5.     conv1 = convolution_layer( images_placeholder, 5, 2, 6, 0.001, 1 )
  6.     dropout_layer_1 = tf.layers.dropout(conv1, rate= 0.5, training = isTraining, name = "drop1")
  7.     pool1 = tf.nn.max_pool(dropout_layer_1, [1,2,2,1], [1,2,2,1], 'SAME', data_format='NHWC', name = "pooling_1")
  8. #   pool1 = tf.nn.max_pool(conv1, [1,2,2,1], [1,2,2,1], 'SAME', data_format='NHWC', name = "pooling_1")
  9. with tf.name_scope('Conv2'):
  10.     conv2 = convolution_layer( pool1, 5, 2, 6, 0.001, 2 )
  11.     dropout_layer_2 = tf.layers.dropout(conv2, rate= 0.5, training = isTraining, name = "drop2")
  12.     pool2 = tf.nn.max_pool(dropout_layer_2, [1,2,2,1], [1,2,2,1], 'SAME', data_format='NHWC', name = "pooling_2")
  13. #   pool2 = tf.nn.max_pool(conv2, [1,2,2,1], [1,2,2,1], 'SAME', data_format='NHWC', name = "pooling_2")
  14. with tf.name_scope('Conv3'):
  15.     conv3 = convolution_layer( pool2, 5, 2, 6, 0.001, 3 )
  16.     flatten = tf.reshape( conv3, [ -1, 216 ] )
  17. with tf.name_scope('Dense1'):
  18.     dense1 = fully_connected_layers( flatten, 40, 5, 0.01 )
  19. with tf.name_scope('Dense2'):
  20.     dense2 = fully_connected_layers( dense1, 4, 6, 0.001 )
  21.     features_output = tf.nn.relu( dense2, "output_node" )
  22.  
  23. with tf.Session() as sess:
  24.     saver = tf.train.Saver()
  25.     #tf.train.write_graph(sess.graph.as_graph_def(), "", "input_graph.pb")
  26.     saver.save(sess, './with_dropout.ckpt')
Add Comment
Please, Sign In to add comment