tristandeleu / pytorch-maml-rl

Reinforcement Learning with Model-Agnostic Meta-Learning in Pytorch
MIT License
827 stars 158 forks source link

Can inner update apply Advanced optimizer such as Adam/RMSprop? #8

Closed dragen1860 closed 6 years ago

dragen1860 commented 6 years ago

Hi, I found your code is very readable and elegant, Thanks. I have a question when implementing MAML, when do inner update:

        for (name, param), grad in zip(self.named_parameters(), grads):
            updated_params[name] = param - step_size * grad

or

fast_weights = list(map(lambda p: p[1] - self.train_lr * p[0], zip(grad, fast_weights)))

While in outer update: we can use simple SGD still,

for (name, param), grad in zip(self.named_parameters(), grads):
            updated_params[name] = param - step_size * grad

Or

 meta_op.backward()
 adam_optim.step()

My question is : Can the inner update use Adam/RMSprop? why. will it corrupt computation graph?

tristandeleu commented 6 years ago

There are a couple of reasons why we don't use a more complex update in the inner loop in MAML:

That being said, this is specific to MAML where you want to compute the full update. If you are using the first-order approximation of MAML (as described in the paper), where you don't have to compute higher order derivatives, then you can perfectly use what you are describing.