Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scheduling within models #41

Open
tomhosking opened this issue Aug 5, 2022 · 1 comment
Open

Scheduling within models #41

tomhosking opened this issue Aug 5, 2022 · 1 comment

Comments

@tomhosking
Copy link
Contributor

tomhosking commented Aug 5, 2022

Some models make use of some sort of scheduling or annealing internally (e.g. KL warmup or temperature annealing) based on the current step index - what's the correct way to implement this within pythae?

@clementchadebec
Copy link
Owner

Hi @tomhosking,

Thank you for opening this issue. Yes indeed some models may need several warmup steps during training. To allow such a behavior, the current training epoch is automatically passed to the forward method of the model in the trainers as shown below

model_output = self.model(
inputs, epoch=epoch, dataset_size=len(self.train_loader.dataset)
)

The current epoch can be retrieved in the forward method as follows

epoch = kwargs.pop("epoch")

and then passed to the loss_function. Nonetheless, this warmup setting is only supported for some models for now and you may require to make the changes in the model implementation yourself. If you do so, you will need to first clone the repo and install it in editable mode

$ git clone https://github.com/clementchadebec/benchmark_VAE.git
$ cd benchmark_VAE
$ pip install -e .

As an example, you can check the implementation of the disentangled_beta_vae that uses a specific KL scheduling procedure.

I will think of a way to include this for other models as well.

Best,

Clément

@clementchadebec clementchadebec added help wanted Extra attention is needed feature request and removed help wanted Extra attention is needed labels Aug 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants