def gconvbn(*args, **kwargs): scope = kwargs.pop('scope', None) with tf.variable_scope(scope): x = sconv2d(*args, **kwargs) c = args[-1] f = x.shape[-1].value // c g = f // c kernel = np.zeros((1, 1, f * c, f), np.float32) for i in range(f): start = (i // c) * c * c + i % c end = start + c * c kernel[:, :, start:end:c, i] = 1. x = conv2d_primitive(x, tf.constant(kernel), strides=[1, 1, 1, 1], padding='VALID', name='gconv') return batch_norm(x)
def sconvbnswish(*args, **kwargs): scope = kwargs.pop('scope', None) with tf.variable_scope(scope): return swish(batch_norm(sconv2d(*args, **kwargs)))
def sconvbnact(*args, **kwargs): scope = kwargs.pop('scope', None) activation_fn = kwargs.pop('activation_fn', None) with tf.variable_scope(scope): return activation_fn(batch_norm(sconv2d(*args, **kwargs)))