def _conv_layer(self, bottom, filter_size, filter_num, scope_name, bottom_channel=None, padding='SAME'):
if not bottom_channel:
_, _, _, bottom_channel = bottom.get_shape().as_list()
with tf.variable_scope(scope_name):
kernel = tf.Variable(
tf.truncated_normal([*filter_size, bottom_channel, filter_num], dtype=tf.float32, stddev=1e-1),
trainable=False,
name='weights'
)
conv = tf.nn.conv2d(bottom, kernel, [1, 1, 1, 1], padding=padding)
biases = tf.Variable(
tf.constant(0.0, shape=[filter_num], dtype=tf.float32),
trainable=True,
name='bias'
)
out = tf.nn.bias_add(conv, biases)
return out
评论列表
文章目录