def fc_layer(self, bottom, out_size, name):
with tf.variable_scope(name):
_, _height, _width, _channel = bottom.get_shape().as_list()
size = _height*_width*_channel
weights = tf.get_variable(name=name + "_weights", shape = [size, out_size], initializer=init_ops.random_normal_initializer(stddev=0.01))
biases = tf.get_variable(name=name + "_biases", shape=[out_size], initializer=init_ops.random_normal_initializer(stddev=0.01))
print weights
x = tf.reshape(bottom, [-1, size])
fc = tf.nn.bias_add(tf.matmul(x, weights), biases)
return fc
评论列表
文章目录