Meta-SGD

Now, we define a class called MetaSGD where we implement the Meta-SGD algorithm. In the __init__ method, we'll initialize all the necessary variables. Then, we define our sigmoid activation function. After this, we define our train function:

class MetaSGD(object):

We define the __init__ method and initialize all necessary variables:

    def __init__(self):                #initialize number of tasks i.e number of tasks we need in each batch of tasks        self.num_tasks = 2                #number of samples i.e number of shots -number of data points (k) we need to have in each task        self.num_samples = 10        #number of epochs i.e training iterations        self.epochs = 10000                #hyperparameter for the outer loop (outer gradient update) i.e meta optimization        self.beta = 0.0001         #randomly ...

Get Hands-On Meta Learning with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.