taki0112 / UGATIT

Official Tensorflow implementation of U-GAT-IT: Unsupervised Generative Attentional Networks with Adaptive Layer-Instance Normalization for Image-to-Image Translation (ICLR 2020)
MIT License
6.17k stars 1.04k forks source link

A problem in function fully_connected_with_w() #53

Closed zjuzxd94 closed 5 years ago

zjuzxd94 commented 5 years ago

In function fully_connected_with_w(), if parameter 'sn' is False, the else branch will get a variable 'w' with code w = tf.get_variable('kernel', shape=[channels, 1]). Is the purpose of this to get the weights in above dense layer? If so, shouldn't it be coded as w = tf.get_variable('dense/kernel', shape=[channels, 1])? https://github.com/taki0112/UGATIT/blob/master/ops.py#L74

taki0112 commented 5 years ago

In tf.layers.dense, This uses the weight name as the kernel.

zjuzxd94 commented 5 years ago

But I have tried with code like this:

import tensorflow as tf
with tf.variable_scope('scope', reuse=tf.AUTO_REUSE):
    x = tf.get_variable('x', shape=[6,10])
    y = tf.layers.dense(x, units=1)
    w = tf.get_variable('kernel', shape=[10, 1])
for item in tf.trainable_variables():
    print(item)

The result is:

<tf.Variable 'scope/x:0' shape=(6, 10) dtype=float32_ref> <tf.Variable 'scope/dense/kernel:0' shape=(10, 1) dtype=float32_ref> <tf.Variable 'scope/dense/bias:0' shape=(1,) dtype=float32_ref> <tf.Variable 'scope/kernel:0' shape=(10, 1) dtype=float32_ref>

Obviously, there are two kernel variables: 'scope/dense/kernel:0' and 'scope/kernel:0'

taki0112 commented 5 years ago

In cleaning up the code, we changed it to high-level API. We've now modified it to the code of the paper. Thank you for the information.