''

def define_graph(self):

    with self.graph.as_default():
        with tf.name_scope('inputs'):
            self.tf_train_samples = tf.placeholder(tf.float32, shape=(self.batch_size, image_size, image_size, num_channels), name='tf_train_samples')
            self.tf_train_labels = tf.placeholder(tf.float32, shape=(self.batch_size, num_labels), name='tf_train_labels')
            self.tf_test_samples = tf.placeholder(tf.float32, shape=(self.test_batch_size, image_size, image_size, num_channels), name='tf_test_samples')
        with tf.name_scope('conv1'):
            conv1_weights = tf.Variable(tf.truncated_normal([self.patch_size, self.patch_size, num_channels, self.conv1_depth], stddev=0.1))
            conv1_biases = tf.Variable(tf.zeros([self.conv1_depth]))
        with tf.name_scope('conv2'):
            conv2_weights = tf.Variable(tf.truncated_normal([self.patch_size, self.patch_size, self.conv1_depth, self.conv2_depth], stddev=0.1))
            conv2_biases = tf.Variable(tf.constant(0.1, shape=[self.conv2_depth]))
        with tf.name_scope('conv3'):
            conv3_weights = tf.Variable(tf.truncated_normal([self.patch_size, self.patch_size, self.conv2_depth, self.conv3_depth], stddev=0.1))
            conv3_biases = tf.Variable(tf.constant(0.1, shape=[self.conv3_depth]))
        with tf.name_scope('conv4'):
            conv4_weights = tf.Variable(tf.truncated_normal([self.patch_size, self.patch_size, self.conv3_depth, self.conv4_depth], stddev=0.1))
            conv4_biases = tf.Variable(tf.constant(0.1, shape=[self.conv4_depth]))
        with tf.name_scope('fc1'):
            down_scale = (self.pooling_scale ** 2)
            fc1_weights = tf.Variable(tf.truncated_normal([(((image_size // down_scale) * (image_size // down_scale)) * self.last_conv_depth), self.num_hidden], stddev=0.1))
            fc1_biases = tf.Variable(tf.constant(0.1, shape=[self.num_hidden]))
            self.train_summaries.append(tf.histogram_summary('fc1_weights', fc1_weights))
            self.train_summaries.append(tf.histogram_summary('fc1_biases', fc1_biases))
        with tf.name_scope('fc2'):
            fc2_weights = tf.Variable(tf.truncated_normal([self.num_hidden, num_labels], stddev=0.1), name='fc2_weights')
            fc2_biases = tf.Variable(tf.constant(0.1, shape=[num_labels]), name='fc2_biases')
            self.train_summaries.append(tf.histogram_summary('fc2_weights', fc2_weights))
            self.train_summaries.append(tf.histogram_summary('fc2_biases', fc2_biases))
        def model(data, train=True):
            '\n DCTB  DCTB  DCTB  DCTB @data:    original    inputs\n DCTB  DCTB  DCTB  DCTB @return:    logits\n DCTB  DCTB  DCTB  DCTB '
            with tf.name_scope('conv1_model'):
                with tf.name_scope('convolution'):
                    conv1 = tf.nn.conv2d(data, filter=conv1_weights, strides=[1, 1, 1, 1], padding='SAME')
                    addition = (conv1 + conv1_biases)
                hidden = tf.nn.relu(addition)
                if (not train):
                    filter_map = hidden[(-1)]
                    filter_map = tf.transpose(filter_map, perm=[2, 0, 1])
                    filter_map = tf.reshape(filter_map, (self.conv1_depth, 32, 32, 1))
                    self.test_summaries.append(tf.image_summary('conv1_relu', tensor=filter_map, max_images=self.conv1_depth))
            with tf.name_scope('conv2_model'):
                with tf.name_scope('convolution'):
                    conv2 = tf.nn.conv2d(hidden, filter=conv2_weights, strides=[1, 1, 1, 1], padding='SAME')
                    addition = (conv2 + conv2_biases)
                hidden = tf.nn.relu(addition)
                hidden = tf.nn.max_pool(hidden, ksize=[1, self.pooling_scale, self.pooling_scale, 1], strides=[1, self.pooling_stride, self.pooling_stride, 1], padding='SAME')
            with tf.name_scope('conv3_model'):
                with tf.name_scope('convolution'):
                    conv3 = tf.nn.conv2d(hidden, filter=conv3_weights, strides=[1, 1, 1, 1], padding='SAME')
                    addition = (conv3 + conv3_biases)
                hidden = tf.nn.relu(addition)
            with tf.name_scope('conv4_model'):
                with tf.name_scope('convolution'):
                    conv4 = tf.nn.conv2d(hidden, filter=conv4_weights, strides=[1, 1, 1, 1], padding='SAME')
                    addition = (conv4 + conv4_biases)
                hidden = tf.nn.relu(addition)
                hidden = tf.nn.max_pool(hidden, ksize=[1, self.pooling_scale, self.pooling_scale, 1], strides=[1, self.pooling_stride, self.pooling_stride, 1], padding='SAME')
            shape = hidden.get_shape().as_list()
            reshape = tf.reshape(hidden, [shape[0], ((shape[1] * shape[2]) * shape[3])])
            with tf.name_scope('fc1_model'):
                fc1_model = (tf.matmul(reshape, fc1_weights) + fc1_biases)
                hidden = tf.nn.relu(fc1_model)
            with tf.name_scope('fc2_model'):
                return (tf.matmul(hidden, fc2_weights) + fc2_biases)
        logits = model(self.tf_train_samples)
        with tf.name_scope('loss'):
            self.loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits, self.tf_train_labels))
            self.train_summaries.append(tf.scalar_summary('Loss', self.loss))
        with tf.name_scope('optimizer'):
            self.optimizer = tf.train.GradientDescentOptimizer(0.0001).minimize(self.loss)
        with tf.name_scope('train'):
            self.train_prediction = tf.nn.softmax(logits, name='train_prediction')
        with tf.name_scope('test'):
            self.test_prediction = tf.nn.softmax(model(self.tf_test_samples, train=False), name='test_prediction')
        self.merged_train_summary = tf.merge_summary(self.train_summaries)
        self.merged_test_summary = tf.merge_summary(self.test_summaries)
