Gradient agreement in MAML

Now, we'll define a class called GradientAgreement_MAML, where we'll implement the gradient agreement MAML algorithm. In the __init__ method, we'll initialize all of the necessary variables. Then, we'll define our sigmoid activation function. Following this, we'll define our train function.

Let's see this step by step and we'll see the overall code:

class GradientAgreement_MAML(object):

We define the __init__ method and initialize all 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 ...

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.