def conv_2d_drop_bn_relu(inp, inp_chan, out_chan, kernel, stride=1, prob=1.0, name="", is_train=True):
weights = tf.Variable(tf.truncated_normal(
shape=[kernel, kernel, inp_chan, out_chan],
mean=0.0,
stddev=0.3),
name=name+"_weights")
bias = tf.Variable(tf.constant(
shape=[out_chan],
value=0.0),
name=name+"_bias")
conv = tf.nn.conv2d(input=inp,
filter=weights,
strides=[1, stride, stride, 1],
padding='VALID',
name=name+"_conv")
drop = tf.nn.dropout(conv, prob, name=name+"_drop")
out = tf.nn.relu(tf.contrib.layers.batch_norm(drop + bias, is_training=is_train))
return out, weights, bias
评论列表
文章目录