abdulfatir / abdulfatir/IWAE-tensorflow

Loss function seems to be miscalculated

Aperta
#2 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Python
Stelle
4
Fork
3
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Thank you for your implementation of IWAE. Although I have one remark and one question about it:
### The remark:
Your training loss function in ```iwae.py``` lines 71-73 seems miscalculated to me:
```python
loss = - \
tf.reduce_mean(tf.reduce_sum(
normalized_weights * log_weights, 0))
```
There seems to be a confusion between the loss function and the gradient estimate given in the paper. You seem to be trying to apply the trick in the paper that uses the normalization weights to keep gradient calculations parallel w.r.t the k samples of z despite the log. However, if so, you should stop the gradient at ```normalized_weights``` because they are only meant to weight the gradients, and not to be differentiated. Here is the gradient estimate I am referring to :
![image](https://user-images.githubusercontent.com/25091538/71582542-fc40e480-2b0a-11ea-994a-788029fc6f81.png)

### The question :
I can see that, while calculating the weights you substract the maximum weight w.r.t the k samples of z as follows:
```python
weights = tf.exp(log_weights - tf.reduce_max(log_weights, 0))
```
I can also see that you somehow "put them back" after applying the average log when testing. I have seen a similar trick in the original implementation. I tried googling for the reason behind this trick using various keywords but I can't seem to find it. Could you please give me a quick explanation for this or direct me towards a resource that explains it.

Thanks again for your hard work on this implementation, as well as for your answers to my questions.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.