def run_benchmark():
 with tf.Graph().as_default():
  image_size = 224
  images = tf.Variable(tf.random_normal([FLAGS.batch_size, image_size, image_size, 3], dtype=tf.float32, stddev=0.1))
  (pool5, parameters) = inference(images)
  init = tf.global_variables_initializer()
  config = tf.ConfigProto()
  config.gpu_options.allocator_type = 'BFC'
  sess = tf.Session(config=config)
  sess.run(init)
  time_tensorflow_run(sess, pool5, 'Forward')
  objective = tf.nn.l2_loss(pool5)
  grad = tf.gradients(objective, parameters)
  time_tensorflow_run(sess, grad, 'Forward-backward')

def run_benchmark ( ) : with tf . Graph ( ) . as_default ( ) : image_size = 224 images = tf . Variable ( tf . random_normal ( [ FLAGS . batch_size , image_size , image_size , 3 ] , dtype = tf . float32 , stddev = 0.1 ) ) ( pool5 , parameters ) = inference ( images ) init = tf . global_variables_initializer ( ) config = tf . ConfigProto ( ) config . gpu_options . allocator_type = 'BFC' sess = tf . Session ( config = config ) sess . run ( init ) time_tensorflow_run ( sess , pool5 , 'Forward' ) objective = tf . nn . l2_loss ( pool5 ) grad = tf . gradients ( objective , parameters ) time_tensorflow_run ( sess , grad , 'Forward-backward' )
run the benchmark on alexnet .