def _upscore_layer(self, bottom, shape, params):
strides = [1, params["stride"], params["stride"], 1]
with tf.variable_scope(params["name"]):
in_features = bottom.get_shape()[3].value
if shape is None:
in_shape = tf.shape(bottom)
h = ((in_shape[1] - 1) * params["stride"]) + 1
w = ((in_shape[2] - 1) * params["stride"]) + 1
new_shape = [in_shape[0], h, w, params["outputChannels"]]
else:
new_shape = [shape[0], shape[1], shape[2], params["outputChannels"]]
output_shape = tf.pack(new_shape)
f_shape = [params["ksize"], params["ksize"], params["outputChannels"], in_features]
weights = self.get_deconv_filter(f_shape, params)
deconv = tf.nn.conv2d_transpose(bottom, weights, output_shape,
strides=strides, padding='SAME')
return deconv
评论列表
文章目录