IntelLabs / IntelLabs/bayesian-torch

Inconsistent use of mean & sum when calculating KL divergence?

Open
#36 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
18
Forks
5
PR merge metrics
No merged PRs in 30d

Description

There is a mean taken inside [BaseVariationalLayer_.kl_div()](https://github.com/IntelLabs/bayesian-torch/blob/main/bayesian_torch/layers/base_variational_layer.py). But later a sum is used inside [get_kl_loss()](https://github.com/IntelLabs/bayesian-torch/blob/main/bayesian_torch/models/dnn_to_bnn.py) & when reducing the KL loss of a layer's bias & weights (e.g. inside [Conv2dReparameterization.kl_loss()](https://github.com/IntelLabs/bayesian-torch/blob/main/bayesian_torch/layers/variational_layers/conv_variational.py)).

I'm wondering if there is mathematical justification for this? Why take the mean of the individual weight KL divergences only to later sum across layers?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.