def get_graph()

in tensorflow/alexnet/alexnet.py [0:0]


def get_graph():
    
    x = tf.placeholder(tf.float32, shape=[None, 
                                            IMAGE_SIZE,
                                            IMAGE_SIZE,
                                            NUM_CHANNELS])
    
    ### First layer ###
    
    with tf.name_scope('conv1') as scope:
        # Random parameters since this is only for benchmarking
        kernel = tf.Variable(tf.truncated_normal([11, 11, 3, 64], dtype=tf.float32,
                                                 stddev=1e-1), name='weights')
        biases = tf.Variable(tf.constant(0.0, shape=[64], dtype=tf.float32),
                             trainable=True, name='biases')
        # First convolutional layer                     
        conv = tf.nn.conv2d(x, kernel, [1, 4, 4, 1], padding='SAME')
        bias = tf.nn.bias_add(conv, biases)
        # Relu
        relu = tf.nn.relu(bias, name=scope)
        radius = 2; alpha = 2e-05; beta = 0.75; bias = 1.0
        # Response normalization
        lrn = tf.nn.local_response_normalization(relu,
                                                      depth_radius=radius,
                                                      alpha=alpha,
                                                      beta=beta,
                                                      bias=bias)
        # Max pool                                              
        pool1 = tf.nn.max_pool(lrn,
                             ksize=[1, 3, 3, 1],
                             strides=[1, 2, 2, 1],
                             padding='VALID',
                             name='pool1')
    
    
    
    ### Second layer ###
    
    with tf.name_scope('conv2') as scope:
        # Random parameters for benchmarking
        kernel = tf.Variable(tf.truncated_normal([5, 5, 64, 192], dtype=tf.float32,
                                                 stddev=1e-1), name='weights')
        biases = tf.Variable(tf.constant(0.0, shape=[192], dtype=tf.float32),
                             trainable=True, name='biases')
        # Second convolutional layer                     
        conv = tf.nn.conv2d(pool1, kernel, [1, 1, 1, 1], padding='SAME')
        bias = tf.nn.bias_add(conv, biases)
        # Relu
        relu = tf.nn.relu(bias, name=scope)
        # Response normalization
        radius = 2; alpha = 2e-05; beta = 0.75; bias = 1.0
        lrn = tf.nn.local_response_normalization(relu,
                                                          depth_radius=radius,
                                                          alpha=alpha,
                                                          beta=beta,
                                                          bias=bias)
        # Max pool 
        pool2 = tf.nn.max_pool(lrn,
                             ksize=[1, 3, 3, 1],
                             strides=[1, 2, 2, 1],
                             padding='VALID',
                             name='pool2')
    
    
    
    ### Third layer ###
    with tf.name_scope('conv3') as scope:    
        # Random parameters for benchmarking
        kernel = tf.Variable(tf.truncated_normal([3, 3, 192, 384],
                                                 dtype=tf.float32,
                                                 stddev=1e-1), name='weights')
        biases = tf.Variable(tf.constant(0.0, shape=[384], dtype=tf.float32),
                             trainable=True, name='biases')
        # Third convolutional layer
        conv = tf.nn.conv2d(pool2, kernel, [1, 1, 1, 1], padding='SAME')
        bias = tf.nn.bias_add(conv, biases)
        #Relu
        relu3 = tf.nn.relu(bias, name=scope)
    
    
    
    ### Fourth layer ###
    with tf.name_scope('conv4') as scope:
        # Random parameters for benchmarking
        kernel = tf.Variable(tf.truncated_normal([3, 3, 384, 256],
                                                 dtype=tf.float32,
                                                 stddev=1e-1), name='weights')
        biases = tf.Variable(tf.constant(0.0, shape=[256], dtype=tf.float32),
                             trainable=True, name='biases')
        # Fourth convolutional layer
        conv = tf.nn.conv2d(relu3, kernel, [1, 1, 1, 1], padding='SAME')
        bias = tf.nn.bias_add(conv, biases)                                             
        # Relu
        relu4 = tf.nn.relu(bias, name=scope)
    
    
    
    ### Fifth layer ###
    with tf.name_scope('conv5') as scope:
        # Random parameters for benchmarking
        kernel = tf.Variable(tf.truncated_normal([3, 3, 256, 256],
                                                 dtype=tf.float32,
                                                 stddev=1e-1), name='weights')
        biases = tf.Variable(tf.constant(0.0, shape=[256], dtype=tf.float32),
                             trainable=True, name='biases')
        # Fifth convolutional layer
        conv = tf.nn.conv2d(relu4, kernel, [1, 1, 1, 1], padding='SAME')                                                                      
        bias = tf.nn.bias_add(conv, biases)
        # Relu
        relu = tf.nn.relu(bias, name='relu5')
        # Max pool
        # max_pool(3, 3, 2, 2, padding='VALID', name='pool5')
        k_h = 3; k_w = 3; s_h = 2; s_w = 2; padding = 'VALID'

        maxpool5 = tf.nn.max_pool(relu, ksize=[1, k_h, k_w, 1], strides=[1, s_h, s_w, 1], padding=padding)    

    
    
    ### Sixth layer. Fully connected. ###
    with tf.name_scope('fc6') as scope:
        weights = tf.Variable(tf.truncated_normal([9216, 4096], dtype=tf.float32, stddev=1e-1), name='fc6W')
        biases = tf.Variable(tf.constant(0.0, shape=[4096], dtype=tf.float32), trainable=True, name='fc6b')
        fc6 = tf.nn.relu_layer(tf.reshape(maxpool5, [-1, int(np.prod(maxpool5.get_shape()[1:]))]), weights, biases)
    
    
    ### Seventh layer. Fully connected ###
    with tf.name_scope('fc7') as scope:
        weights = tf.Variable(tf.truncated_normal([4096, 4096], dtype=tf.float32, stddev=1e-1), name='fc7W')
        biases = tf.Variable(tf.constant(0.0, shape=[4096], dtype=tf.float32), trainable=True, name='fc7b')
        fc7 = tf.nn.relu_layer(fc6, weights, biases)
    
        
    ### Eighth layer ###
    with tf.name_scope('fc8') as scope:
        weights = tf.Variable(tf.truncated_normal([4096, NUM_LABELS], dtype=tf.float32, stddev=1e-1), name='fc8W')
        biases = tf.Variable(tf.constant(0.0, shape=[NUM_LABELS], dtype=tf.float32), trainable=True, name='fc8b')
        fc8 = tf.nn.xw_plus_b(fc7, weights, biases)
    
    
    ### Probability. SoftMax ###
    prob = tf.nn.softmax(fc8)
    return prob, x