def model_fc(self, z, layer=[2 * 2 * 256, 2 * 2 * 128, 2 * 2 * 64, 2 * 2 * 16, 10]): output = z layer_num = 0 with tf.name_scope('reshape'): reshape_size = 2 * 2 * 256 output = tf.reshape(output, [-1, reshape_size]) for i in range(3): layer_num += 1 with tf.variable_scope('fc' + str(layer_num)): output = NNutils.create_layer('fc', output, layer[layer_num], var_list=self.train_list, dropout=self.dropout_normal) layer_num += 1 with tf.variable_scope('fc' + str(layer_num)): output = NNutils.create_layer('fc', output, layer[layer_num], var_list=self.train_list, activation='none') y = output return y
def model_fc(self, z, layer=[7 * 7, 6 * 6, 5 * 5, 10]): output = z layer_num = 0 for i in range(2): layer_num += 1 with tf.variable_scope('fc' + str(layer_num)): output = NNutils.create_layer('fc', output, layer[layer_num], var_list=self.train_list) # output = tf.nn.dropout(output, self.dropout_conv) layer_num += 1 with tf.variable_scope('fc' + str(layer_num)): output = NNutils.create_layer('fc', output, layer[layer_num], var_list=self.train_list, activation='none') y = output return y
def model(self, x, layer): image_width = 32 output = x #first image layer_num = 0 output1 = output with tf.variable_scope('1conv' + str(layer_num)): output1 = NNutils.create_layer('conv', output1, layer[layer_num]) output1 = tf.nn.max_pool(output1, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='SAME') layer_num += 1 with tf.variable_scope('1conv' + str(layer_num)): output1 = NNutils.create_layer('conv', output1, layer[layer_num]) output1 = tf.nn.max_pool(output1, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='SAME') layer_num += 1 with tf.variable_scope('1conv' + str(layer_num)): output1 = NNutils.create_layer('conv', output1, layer[layer_num]) output1 = tf.nn.max_pool(output1, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='SAME') layer_num += 1 with tf.variable_scope('1conv' + str(layer_num)): output1 = NNutils.create_layer('conv', output1, layer[layer_num]) output1 = tf.nn.max_pool(output1, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='SAME') layer_num += 1 with tf.name_scope('reshape'): output1 = tf.reshape(output1, [-1, image_width * image_width * layer[3]]) #second image layer_num = 0 output2 = output with tf.variable_scope('2conv' + str(layer_num)): output2 = NNutils.create_layer('conv', output2, layer[layer_num]) output2 = tf.nn.max_pool(output2, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='SAME') layer_num += 1 with tf.variable_scope('2conv' + str(layer_num)): output2 = NNutils.create_layer('conv', output2, layer[layer_num]) output2 = tf.nn.max_pool(output2, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='SAME') layer_num += 1 with tf.variable_scope('2conv' + str(layer_num)): output2 = NNutils.create_layer('conv', output2, layer[layer_num]) output2 = tf.nn.max_pool(output2, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='SAME') layer_num += 1 with tf.variable_scope('2conv' + str(layer_num)): output2 = NNutils.create_layer('conv', output2, layer[layer_num]) output2 = tf.nn.max_pool(output2, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='SAME') layer_num += 1 with tf.name_scope('reshape'): output2 = tf.reshape(output2, [-1, image_width * image_width * layer[3]]) #summation layer with tf.name_scope('concat'): output = tf.concat([output1, output2], 0) with tf.variable_scope('normal' + str(layer_num)): output = NNutils.create_layer('normal', output, layer[layer_num]) layer_num += 1 with tf.variable_scope('normal' + str(layer_num)): output = NNutils.create_layer('normal', output, layer[layer_num], activation='none') layer_num += 1 y = output return y