Zardinality / WGAN-tensorflow

a tensorflow implementation of WGAN
579 stars 201 forks source link

Does the value of theta_c really change after clip? #3

Closed lhao0301 closed 7 years ago

lhao0301 commented 7 years ago

I was confused about this line clipped_var_c = [tf.assign(var, tf.clip_by_value(var, clamp_lower, clamp_upper)) for var in theta_c]. clipped_var_c is one copy of 'theta_c' and it is clipped. However I think that the value of theta_c actually was not clipped during training.

Zardinality commented 7 years ago

tf.assign does return a assigned Tensor whose value is what we want to assign, but it is not a variable, though it has same value as the changed variable. Evaling the returned tensor will change the variable's value directly, tf.assign doesn't change variable's value by returning a new variable and substitute it. In this case, evaling tf.tuple(clipped_var_c) will run all assign_op clipped_var_c consists of, thus change the values of theta_c.

lhao0301 commented 7 years ago

I got it. Thank you very much!