def fc_layer(self, bottom, name):
with tf.variable_scope(name) as scope:
shape = bottom.get_shape().as_list()
dim = 1
for d in shape[1:]:
dim *= d
x = tf.reshape(bottom, [-1, dim])
with tf.device('/cpu:0'):
weights = self.get_fc_weight(name)
biases = self.get_fc_bias(name)
# Fully connected layer. Note that the '+' operation automatically
# broadcasts the biases.
fc = tf.nn.bias_add(tf.matmul(x, weights), biases)
#tf.histogram_summary('adascan/'+name+'_activations', fc)
#tf.histogram_summary('adascan/'+name+'_weights', weights)
scope.reuse_variables()
return fc
评论列表
文章目录