LynnHo / AttGAN-Tensorflow

AttGAN: Facial Attribute Editing by Only Changing What You Want (IEEE TIP 2019)
MIT License
605 stars 135 forks source link

values for the labels #8

Closed ifangcheng closed 6 years ago

ifangcheng commented 6 years ago

got confused about the following codes (line 107 -113) in train.py :

_a = (tf.to_float(a) 2 - 1) thres_int if b_distribution == 'none': _b = (tf.to_float(b) 2 - 1) thres_int elif b_distribution == 'uniform': _b = (tf.to_float(b) 2 - 1) tf.random_uniform(tf.shape(b)) (2 thres_int) elif b_distribution == 'truncated_normal': _b = (tf.to_float(b) 2 - 1) (tf.truncated_normal(tf.shape(b)) + 2) / 4.0 (2 thres_int)

what ‘s the variable “thres_int” is used for? why do we need these codes to do value range adjustment, since the value have been set to 0 or 1 ?

LynnHo commented 6 years ago

@ifangcheng Actually, we can use a continuous b value to indicate the attribute intensity, and I set these codes for training the network by the continuous b value. However, it doesn't improve the performance, so the default b_distribution is 'none'. thres_int affects the range of the distribution, just use the default value.

ifangcheng commented 6 years ago

@LynnHo thanks for the reply! however, still not quite clear:

  1. although the default b_distribution is 'none', the _b variable is not binary variable: _b = (tf.to_float(b) 2 - 1) thres_int _b is -0.5 or 0.5, as the default value for thres_int =0.5 it seems not consist with the paper , it seems that the label should a binary variable (0 or 1), so why do we need this range adjustment, why not just set: _b = tf.to_float(b) ?

  2. can we set _b to any vector we want? e.g. set b or _b= [0, 2, 0, 1, 3, ,6, 0, 1, 1 ....] or be any continuous vector?

LynnHo commented 6 years ago

@ifangcheng

  1. _b = (tf.to_float(b) * 2 - 1) * thres_int is set to be consistent with other choices of b_distribution. Yes you are right, _b = tf.to_float(b) is also ok, {-0.5, 0.5} and {0, 1} have no difference here.

  2. _b can be other vectors according to your dataset. If there are three values for one attribute, _b can be chosen in {0, 1, 2}. If the attributes are continuous, _b can be continuous. However, this code only supports binary value.