abdulfatir / abdulfatir/IWAE-tensorflow

Loss function seems to be miscalculated

Abierto
#2 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Python
Estrellas
4
Forks
3
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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.

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.