in tfops.py [0:0]
def conv2d(name, x, width, filter_size=[3, 3], stride=[1, 1], pad="SAME", do_weightnorm=False, do_actnorm=True, context1d=None, skip=1, edge_bias=True):
with tf.variable_scope(name):
if edge_bias and pad == "SAME":
x = add_edge_padding(x, filter_size)
pad = 'VALID'
n_in = int(x.get_shape()[3])
stride_shape = [1] + stride + [1]
filter_shape = filter_size + [n_in, width]
w = tf.get_variable("W", filter_shape, tf.float32,
initializer=default_initializer())
if do_weightnorm:
w = tf.nn.l2_normalize(w, [0, 1, 2])
if skip == 1:
x = tf.nn.conv2d(x, w, stride_shape, pad, data_format='NHWC')
else:
assert stride[0] == 1 and stride[1] == 1
x = tf.nn.atrous_conv2d(x, w, skip, pad)
if do_actnorm:
x = actnorm("actnorm", x)
else:
x += tf.get_variable("b", [1, 1, 1, width],
initializer=tf.zeros_initializer())
if context1d != None:
x += tf.reshape(linear("context", context1d,
width), [-1, 1, 1, width])
return x