Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

How to Update/Optimize subset of params #130

Open
blake-camp opened this issue Mar 11, 2022 · 2 comments
Open

How to Update/Optimize subset of params #130

blake-camp opened this issue Mar 11, 2022 · 2 comments

Comments

@blake-camp
Copy link

Hi, first of all thanks for providing this library.

This might be clear to everyone else, but it's not clear to me. Suppose I have 2 groups of params distributed throughout a single model, i.e. my model has some fast weights, and some slow (meta) weights, but they cannot be easily separated into 2 distinct models, i.e. they are interleaved. My use case is this:

  1. pass full model, fast_weight_optimizer to Higher
  2. Update fast weights with Higher (e.g. diffoft.step(loss)), keep slow weights fixed
  3. compute meta-loss, update slow (meta) weights w.r.t updated fast weights
  4. retain the updated fast weights, i.e. the full model has been updated after a single step.

It doesnt seem like this should be too much different from the use case in the Meta-Learning via Learned Loss code, but it's not working for me yet. The issue seems to be that the fast weight update is not being retained after I exit the Higher block, i.e. when i check the fast weights, they don't seem to have been updated. Do I need to do this manually? What am I missing? Many thanks.

@HamedHemati
Copy link

@bbc1183 The inner-loop context manager higher.innerloop_ctx(model, opt) creates a stateless copy of the model, and the changes in the inner updates do not affect the original model. Therefore, if you need to retain the final state of the fast model in the inner loop you need to manually copy it.

@blake-camp
Copy link
Author

Yes, eventually figured it out. Many thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants