Code Monkey home page Code Monkey logo

Comments (2)

arash-vahdat avatar arash-vahdat commented on August 18, 2024

Please check section H in DVAE++: https://arxiv.org/pdf/1802.04920.pdf and also section A in NVAE.

The basic idea is to multiply the KL term for each group with a scalar coefficient such that groups that have low KL are encouraged to use more latent variables (hence increase their KL) and groups that have high KL are encouraged to reduce it. We set this coefficient proportional to the average KL per group in a batch divided by the dimension of each group.

The problem with this coefficient is that we cannot just set it to any value and we need to normalize it such that it sums to N (N=number of groups). This way our KL term is scaled properly compared to the reconstruction term. When all the groups are used equally kl_coeff_i becomes ~1 for each group.

The operations you noted are redundant indeed. We just basically need to do:

kl_coeff_i = kl_coeff_i / feature_resolution                    # division by latent resolution
kl_coeff_i = num_group * kl_coeff_i / torch.sum(kl_coeff_i, dim=1, keepdim=True)  # normalization such that sum = num_group
kl = torch.sum(kl_all * kl_coeff_i.detach(), dim=1)

I also noticed that in the paper we say that we set the coefficient proportional to the size of each group on page 14 which is a typo and it should have been reverse proportional to the size of each group.

from nvae.

bfs18 avatar bfs18 commented on August 18, 2024

Thanks a lot for your detailed explanation. It is really helpful.

from nvae.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.