class_docstr: Implements the Model-Agnostic Meta-Learning algorithm for low data learning.
  
  The algorithm is described in Finn et al., "Model-Agnostic Meta-Learning for Fast
  Adaptation of Deep Networks" (https://arxiv.org/abs/1703.03400).  It is used for
  training models that can perform a variety of tasks, depending on what data they
  are trained on.  It assumes you have training data for many tasks, but only a small
  amount for each one.  It performs "meta-learning" by looping over tasks and trying
  to minimize the loss on each one *after* one or a few steps of gradient descent.
  That is, it does not try to create a model that can directly solve the tasks, but
  rather tries to create a model that is very easy to train.
  
  To use this class, create a subclass of MetaLearner that encapsulates the model
  and data for your learning problem.  Pass it to a MAML object and call fit().
  You can then use train_on_current_task() to fine tune the model for a particular
  task.
class_docstr_tok: ["Implements","the","Model-Agnostic","Meta-Learning","algorithm","for","low","data","learning",".","The","algorithm","is","described","in","Finn","et","al.",",","``","Model-Agnostic","Meta-Learning","for","Fast","Adaptation","of","Deep","Networks","''","(","https",":","\/\/arxiv.org\/abs\/1703.03400",")",".","It","is","used","for","training","models","that","can","perform","a","variety","of","tasks",",","depending","on","what","data","they","are","trained","on",".","It","assumes","you","have","training","data","for","many","tasks",",","but","only","a","small","amount","for","each","one",".","It","performs","``","meta-learning","''","by","looping","over","tasks","and","trying","to","minimize","the","loss","on","each","one","*","after","*","one","or","a","few","steps","of","gradient","descent",".","That","is",",","it","does","not","try","to","create","a","model","that","can","directly","solve","the","tasks",",","but","rather","tries","to","create","a","model","that","is","very","easy","to","train",".","To","use","this","class",",","create","a","subclass","of","MetaLearner","that","encapsulates","the","model","and","data","for","your","learning","problem",".","Pass","it","to","a","MAML","object","and","call","fit","(",")",".","You","can","then","use","train_on_current_task","(",")","to","fine","tune","the","model","for","a","particular","task","."]
docstr: Perform a few steps of gradient descent to fine tune the model on the current task.
  
  Parameters
  ----------
  optimization_steps: int
      the number of steps of gradient descent to perform
  restore: bool
      if True, restore the model from the most recent checkpoint before optimizing
docstr_tok: ["Perform","a","few","steps","of","gradient","descent","to","fine","tune","the","model","on","the","current","task",".","Parameters","--","--","--","--","--","optimization_steps",":","int","the","number","of","steps","of","gradient","descent","to","perform","restore",":","bool","if","True",",","restore","the","model","from","the","most","recent","checkpoint","before","optimizing"]
code: def train_on_current_task(self, optimization_steps=1, restore=True):
      """Perform a few steps of gradient descent to fine tune the model on the current task.
  
      Parameters
      ----------
      optimization_steps: int
          the number of steps of gradient descent to perform
      restore: bool
          if True, restore the model from the most recent checkpoint before optimizing
      """
      if restore:
          self.restore()
      variables = self.learner.variables
      for i in range(optimization_steps):
          inputs = self.learner.get_batch()
          with tf.GradientTape() as tape:
              loss, _ = self.learner.compute_model(
                  inputs, variables, True
              )
          gradients = tape.gradient(loss, variables)
          self._tf_task_optimizer.apply_gradients(
              zip(gradients, variables)
          )
  
file_path: deepchem/deepchem/metalearning/maml.py
imports: import os
  import shutil
  import tempfile
  import time
  import tensorflow
  from deepchem.models.optimizers import Adam, GradientDescent
label_desc: Use image node_id 6 for calling the MAML obj's underlying member method code with example usage: obj.train_on_current_task(optimization_steps, restore) without return types