Skip to content

Instantly share code, notes, and snippets.

@benoitdescamps
benoitdescamps / blog-metalearning-reptile.py
Last active September 12, 2020 18:21
Pytorch implementation of Reptile as Ravi, et.al. (https://openreview.net/pdf?id=rJY0-Kcll)
class Reptile:
"""
Repile-optimization as described by Ravi,et.al. (https://openreview.net/pdf?id=rJY0-Kcl)
"""
def __init__(self,
model:torch.nn.Module,
metalearners:List[MetaLearner]):
self.n_tasks = len(metalearners)
self.model = model
self.metalearners = metalearners
class MetaLearner:
"""
This is nothing more than a regular learning flow. However, we create this
class, as we plan on using separate (meta-)learners for each task.
"""
def __init__(self,
model:torch.nn.Module,
loss_fn:Callable,
optimizer):