def deconv(inputs, out_num, kernel_size, scope, data_type='2D', **kws):
if data_type == '2D':
outs = tf.layers.conv2d_transpose(
inputs, out_num, kernel_size, (2, 2), padding='same', name=scope,
kernel_initializer=tf.truncated_normal_initializer)
else:
shape = list(kernel_size) + [out_num, out_num]
input_shape = inputs.shape.as_list()
out_shape = [input_shape[0]] + \
list(map(lambda x: x*2, input_shape[1:-1])) + [out_num]
weights = tf.get_variable(
scope+'/deconv/weights', shape,
initializer=tf.truncated_normal_initializer())
outs = tf.nn.conv3d_transpose(
inputs, weights, out_shape, (1, 2, 2, 2, 1), name=scope+'/deconv')
return tf.contrib.layers.batch_norm(
outs, decay=0.9, epsilon=1e-5, activation_fn=tf.nn.relu,
updates_collections=None, scope=scope+'/batch_norm')
评论列表
文章目录