def build_deconv(self, layer_name, input_layer, shape, strides,
padding='VALID'):
weight_name = layer_name + '_weight'
weight = tf.get_variable(weight_name, shape=shape)
self.net[weight_name] = weight
b = tf.shape(input_layer)[0]
h = tf.shape(input_layer)[1]
w = tf.shape(input_layer)[2]
d = tf.shape(input_layer)[3]
_, sh, sw, _ = strides
kh, kw, _, _ = shape
output_shape = tf.pack([b, sh * (h - 1) + kh, sw * (w - 1) + kw, d])
self.net[layer_name] = tf.nn.conv2d_transpose(
input_layer, weight, output_shape, strides=strides,
padding=padding, name=layer_name)
评论列表
文章目录