我试图在tensorflow中获取残差学习实现的变量(Weight)以移动一些不重要的变量,但是我不知道如何从这种苗条的包中获取变量。 这是代码:
def res_identity(input_tensor, conv_depth, kernel_shape, layer_name):
with tf.variable_scope(layer_name):
relu = tf.nn.relu(slim.conv2d(input_tensor, conv_depth, kernel_shape))
output_tensor = tf.nn.relu(slim.conv2d(relu, conv_depth, kernel_shape) + input_tensor)
return output_tensor
def inference(input_tensor): #2 layer
x_image = tf.reshape(input_tensor, [-1,28,28,1])
relu_1 = tf.nn.relu(slim.conv2d(x_image, 32, [3,3]))
pool_1 = slim.max_pool2d(relu_1, [2,2])
net = res_identity(pool_1, 32, [3,3], 'layer_2')
net = res_identity(net, 32, [3,3], 'layer_3')
net = slim.flatten(net, scope='flatten')
net = slim.fully_connected(net, 10, scope='output')
return net
如果真的需要在模型中获取变量,是否应该使用slim实现Resnet?
谢谢!!