snakeztc / NeuralDialog-CVAE

Tensorflow Implementation of Knowledge-Guided CVAE for dialog generation ACL 2017. It is released by Tiancheng Zhao (Tony) from Dialog Research Center, LTI, CMU
https://www.cs.cmu.edu/~tianchez/
Apache License 2.0
309 stars 85 forks source link

bow loss #8

Closed raphael-sch closed 6 years ago

raphael-sch commented 6 years ago

Why do you calculate the the bow loss similar to a sequence (tile bow logits to max_out_len and compare it to labels) instead of forming a single one hot vector out of the labels and compare it to the predicted bow vector?

raphael-sch commented 6 years ago
bow_target = tf.one_hot(target, vocab_size)
bow_target = tf.minimum(tf.reduce_sum(bow_target, 1), 1)
bow_loss = tf.nn.sigmoid_cross_entropy_with_logits(labels=bow_target, logits=bow_logits)
bow_loss = tf.reduce_mean(tf.reduce_sum(bow_loss, -1))`

this should be a lot faster and serves the same purpose

snakeztc commented 6 years ago

You can do that too. But the problem is then BOW loss is not in the scale of RNN loss.

Also, in the BOW setting, log(P(w1, w2... wT|z)) = log(P(w1|z)) + log(P(w2|z)) .. + log(P(wT|z))

Dikea commented 5 years ago

You can do that too. But the problem is then BOW loss is not in the scale of RNN loss.

Also, in the BOW setting, log(P(w1, w2... wT|z)) = log(P(w1|z)) + log(P(w2|z)) .. + log(P(wT|z))

hi, I can not understand what do you mean in "But the problem is then BOW loss is not in the scale of RNN loss". The code supplied by raphael-sch can get same computing result as your codes. Can you explain it in detail?