def conv_layer(input_, filter_shape, stride_shape=[1, 1, 1, 1], padding='SAME', name=None):
"""
Args:
input_: a 4D Tensor of size [batch_size x height x width x channel]
filter_shape: desired filter size [height, width, in_ch, out_ch]
stride_shape: desired stride size [1, stride_h, stride_w, 1]
padding: "SAME" or "VALID"
"""
input_shape = input_.get_shape()
with vs.variable_scope(name or "conv"):
initializer = tf.contrib.layers.xavier_initializer_conv2d(uniform=True, seed=None, dtype=tf.float32)
W = _weight_variable(shape=filter_shape, initializer=initializer)
b = _bias_variable(shape=[filter_shape[3],])
y = tf.nn.conv2d(input_, filter=W, strides=stride_shape, padding=padding)
y = tf.nn.bias_add(y, b)
return y
评论列表
文章目录