Esempio n. 1
0
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)
Esempio n. 2
0
def sconvbnswish(*args, **kwargs):
    scope = kwargs.pop('scope', None)
    with tf.variable_scope(scope):
        return swish(batch_norm(sconv2d(*args, **kwargs)))
Esempio n. 3
0
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)))