MCPcopy Create free account
hub / github.com/OUCMachineLearning/OUCML / deconv

Function deconv

GAN/Self_attention_GAN_tensorflow/ops.py:43–66  ·  view source on GitHub ↗
(x, channels, kernel=4, stride=2, padding='SAME', use_bias=True, sn=False, scope='deconv_0')

Source from the content-addressed store, hash-verified

41
42
43def deconv(x, channels, kernel=4, stride=2, padding='SAME', use_bias=True, sn=False, scope='deconv_0'):
44 with tf.variable_scope(scope):
45 x_shape = x.get_shape().as_list()
46
47 if padding == 'SAME':
48 output_shape = [x_shape[0], x_shape[1] * stride, x_shape[2] * stride, channels]
49
50 else:
51 output_shape =[x_shape[0], x_shape[1] * stride + max(kernel - stride, 0), x_shape[2] * stride + max(kernel - stride, 0), channels]
52
53 if sn :
54 w = tf.get_variable("kernel", shape=[kernel, kernel, channels, x.get_shape()[-1]], initializer=weight_init, regularizer=weight_regularizer)
55 x = tf.nn.conv2d_transpose(x, filter=spectral_norm(w), output_shape=output_shape, strides=[1, stride, stride, 1], padding=padding)
56
57 if use_bias :
58 bias = tf.get_variable("bias", [channels], initializer=tf.constant_initializer(0.0))
59 x = tf.nn.bias_add(x, bias)
60
61 else :
62 x = tf.layers.conv2d_transpose(inputs=x, filters=channels,
63 kernel_size=kernel, kernel_initializer=weight_init, kernel_regularizer=weight_regularizer,
64 strides=stride, padding=padding, use_bias=use_bias)
65
66 return x
67
68def fully_conneted(x, units, use_bias=True, sn=False, scope='fully_0'):
69 with tf.variable_scope(scope):

Callers 1

generatorMethod · 0.70

Calls 1

spectral_normFunction · 0.70

Tested by

no test coverage detected