【发布时间】:2018-04-17 19:19:24
【问题描述】:
我知道偏差与1 将被添加到每一层的输入向量或就像它是一个具有1 恒定输出的神经元一样。从偏置神经元出来的权重是在训练期间训练的正常权重。
现在我正在研究 Tensorflow 中的一些神经网络代码。例如。这个(它只是 CNN (VGGnet) 的一部分,特别是 CNN 中卷积结束和全连接层开始的部分):
with tf.name_scope('conv5_3') as scope:
kernel = tf.Variable(tf.truncated_normal([3, 3, 512, 512], dtype=tf.float32,
stddev=1e-1), name='weights')
conv = tf.nn.conv2d(self.conv5_2, kernel, [1, 1, 1, 1], padding='SAME')
biases = tf.Variable(tf.constant(0.0, shape=[512], dtype=tf.float32),
trainable=True, name='biases')
out = tf.nn.bias_add(conv, biases)
self.conv5_3 = tf.nn.relu(out, name=scope)
self.parameters += [kernel, biases]
# pool5
self.pool5 = tf.nn.max_pool(self.conv5_3,
ksize=[1, 2, 2, 1],
strides=[1, 2, 2, 1],
padding='SAME',
name='pool4')
with tf.name_scope('fc1') as scope:
shape = int(np.prod(self.pool5.get_shape()[1:]))
fc1w = tf.Variable(tf.truncated_normal([shape, 4096],
dtype=tf.float32,
stddev=1e-1), name='weights')
fc1b = tf.Variable(tf.constant(1.0, shape=[4096], dtype=tf.float32),
trainable=True, name='biases')
pool5_flat = tf.reshape(self.pool5, [-1, shape])
fc1l = tf.nn.bias_add(tf.matmul(pool5_flat, fc1w), fc1b)
self.fc1 = tf.nn.relu(fc1l)
self.parameters += [fc1w, fc1b]
现在我的问题是,为什么卷积层中有偏差0 而在全连接层中它是1(该模型中的每个卷积层都有0 用于偏差,而FC 层有1)?还是我的解释仅涵盖全连接层,而与卷积层不同?
【问题讨论】:
标签: machine-learning tensorflow conv-neural-network