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

Function conv

GAN/Self_attention_GAN_tensorflow/ops.py:17–40  ·  view source on GitHub ↗
(x, channels, kernel=4, stride=2, pad=0, pad_type='zero', use_bias=True, sn=False, scope='conv_0')

Source from the content-addressed store, hash-verified

15##################################################################################
16
17def conv(x, channels, kernel=4, stride=2, pad=0, pad_type='zero', use_bias=True, sn=False, scope='conv_0'):
18 with tf.variable_scope(scope):
19 if pad_type == 'zero' :
20 x = tf.pad(x, [[0, 0], [pad, pad], [pad, pad], [0, 0]])
21 if pad_type == 'reflect' :
22 x = tf.pad(x, [[0, 0], [pad, pad], [pad, pad], [0, 0]], mode='REFLECT')
23
24 if sn :
25 w = tf.get_variable("kernel", shape=[kernel, kernel, x.get_shape()[-1], channels], initializer=weight_init,
26 regularizer=weight_regularizer)
27 x = tf.nn.conv2d(input=x, filter=spectral_norm(w),
28 strides=[1, stride, stride, 1], padding='VALID')
29 if use_bias :
30 bias = tf.get_variable("bias", [channels], initializer=tf.constant_initializer(0.0))
31 x = tf.nn.bias_add(x, bias)
32
33 else :
34 x = tf.layers.conv2d(inputs=x, filters=channels,
35 kernel_size=kernel, kernel_initializer=weight_init,
36 kernel_regularizer=weight_regularizer,
37 strides=stride, use_bias=use_bias)
38
39
40 return x
41
42
43def deconv(x, channels, kernel=4, stride=2, padding='SAME', use_bias=True, sn=False, scope='deconv_0'):

Callers 4

generatorMethod · 0.70
discriminatorMethod · 0.70
attentionMethod · 0.70
resblockFunction · 0.70

Calls 1

spectral_normFunction · 0.70

Tested by

no test coverage detected