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

Function fully_conneted

GAN/Self_attention_GAN_tensorflow/ops.py:68–88  ·  view source on GitHub ↗
(x, units, use_bias=True, sn=False, scope='fully_0')

Source from the content-addressed store, hash-verified

66 return x
67
68def fully_conneted(x, units, use_bias=True, sn=False, scope='fully_0'):
69 with tf.variable_scope(scope):
70 x = flatten(x)
71 shape = x.get_shape().as_list()
72 channels = shape[-1]
73
74 if sn :
75 w = tf.get_variable("kernel", [channels, units], tf.float32,
76 initializer=weight_init, regularizer=weight_regularizer)
77 if use_bias :
78 bias = tf.get_variable("bias", [units],
79 initializer=tf.constant_initializer(0.0))
80
81 x = tf.matmul(x, spectral_norm(w)) + bias
82 else :
83 x = tf.matmul(x, spectral_norm(w))
84
85 else :
86 x = tf.layers.dense(x, units=units, kernel_initializer=weight_init, kernel_regularizer=weight_regularizer, use_bias=use_bias)
87
88 return x
89
90def flatten(x) :
91 return tf.layers.flatten(x)

Callers

nothing calls this directly

Calls 2

flattenFunction · 0.85
spectral_normFunction · 0.70

Tested by

no test coverage detected