Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about local_group_norm function #8

Open
kooweat opened this issue Jun 3, 2020 · 0 comments
Open

Question about local_group_norm function #8

kooweat opened this issue Jun 3, 2020 · 0 comments
Assignees

Comments

@kooweat
Copy link

kooweat commented Jun 3, 2020

Hello,
Thank you for your sharing your wonderful work.

Besides, I have two questions regarding a function,
local_group_norm function defined in ops.py (starting from line 47), which I think
is not explained in your paper.
It's some how different from the usual group norm layer that I know of.

  1. To condition the generated output with the artistic style, you applied local group norm.
    In the local_group_norm function, mean of inputs(N,H,W,C//G,G) over each group is estimated
    (i.e., N,H,W,C//G,G -> 1,1,1,G)
    then, you apply separable_conv2d to the estimated means to learn "new mean" value.
    What does it mean? What's your intention doing this?
    and how does it different from the usual group norm?

  2. Also, have you tried applying the usual group norm?
    How would the result be different if we apply the usual group norm with the condition of
    offset and scale learned from style?

To be specific, what would it be like to change the local group norm function as follows,

    def local_group_norm(input, style=None, name="local_group_norm", G=32, window_size=32):
        epsilon = 1e-5
        with tf.variable_scope(name):
            N, H, W, C = tf.shape(input)[0], tf.shape(input)[1], tf.shape(input)[2], tf.shape(input)[3]

            depth = input.get_shape()[3]
            if style is None:
                scale = tf.get_variable("scale",
                                        [depth],
                                        initializer=tf.random_normal_initializer(1.0, 0.02, dtype=tf.float32))
                offset = tf.get_variable("offset",
                                         [depth],
                                         initializer=tf.constant_initializer(0.0))
            else:
                scale = \
                    tf.layers.dense(inputs=style,
                                    units=depth,
                                    activation=lrelu,
                                    name='scale_1')
                offset = tf.layers.dense(inputs=style,
                                         units=depth,
                                         activation=lrelu,
                                         name='offset_1')
                scale = tf.expand_dims(scale, axis=1)
                scale = tf.expand_dims(scale, axis=2)
                offset = tf.expand_dims(offset, axis=1)
                offset = tf.expand_dims(offset, axis=2)

            input = tf.reshape(input, [N, H, W, C // G, G])
            mean, var = tf.nn.moments(input, [1, 2, 3], keep_dims=True)
            input = (input - mean) / tf.sqrt(var + epsilon)
            input = tf.reshape(input, [N, H, W, C])
            return tf.multiply(input, scale) + offset

Thanks in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants