You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using your package and get negative KLDiv when training. I am not sure as to why. I saw #29 but I suspect that solution is not applicable in my case.
As evident in the loss graph, the loss values are also not stable being negative - although when overlooking the sign, the graph does look like a normal training graph.
I would appreciate any help!
The text was updated successfully, but these errors were encountered:
the forward KL divergence is given by $\text{KL}(p||q)=\mathbf{E}_p[\log\frac{p(x)}{q(x)}]=\mathbf{E}_p[\log p(x)]-\mathbf{E}_p[\log q(x)]$, where $p$ is the target and $q$ is the model. Since the target distribution is often unknown, as seems to be the case for your problem, the expectations are estimated with samples from the target, i.e. data. $\mathbf{E}_p[\log p(x)]$ still cannot be estimated in this case, but since it does not contain any model parameters, it is just a constant and is left out when computing the forward KL divergence. Hence, your loss is not literally the forward KL divergence, but the forward KL divergence minus an unknown constant shift, and, therefore, can become negative.
Yes, since the constant does not depend on the model's parameters, so it will disappear anyway when computing the gradient with respect to the parameters for the optimizer.
Moreover, in this case you are essentially minimizing $-\mathbf{E}_p[\log q(x)]$, so minimizing the forward KL divergence corresponds to maximizing the model's likelihood of the samples from the target, which itself is a common way to train machine learning models.
Hi!
I am using your package and get negative KLDiv when training. I am not sure as to why. I saw #29 but I suspect that solution is not applicable in my case.
Here is how the model is made:
And here is the training loop:
Where
latent[-1]
is an intermediate output of a given network (before the classifier).The loss that comes out is negative whereas if
sklearn
methodmutual_info_score
i get a positive number:As evident in the loss graph, the loss values are also not stable being negative - although when overlooking the sign, the graph does look like a normal training graph.
I would appreciate any help!
The text was updated successfully, but these errors were encountered: