reptile_step

ivy.reptile_step(batch, cost_fn, variables, inner_grad_steps, inner_learning_rate, /, *, inner_optimization_step=<function gradient_descent_update>, batched=True, return_inner_v=False, num_tasks=None, stop_gradients=True)[source]

Perform step of Reptile.

Parameters
  • batch (Container) – The input batch

  • cost_fn (Callable) – callable for the cost function, receivng the task-specific sub-batch and variables

  • variables (Container) – Variables to be optimized

  • inner_grad_steps (int) – Number of gradient steps to perform during the inner loop.

  • inner_learning_rate (float) – The learning rate of the inner loop.

  • inner_optimization_step (Callable) – The function used for the inner loop optimization. (default: <function gradient_descent_update at 0x7fa231f7b940>) Default is ivy.gradient_descent_update.

  • batched (bool) – Whether to batch along the time dimension, and run the meta steps in batch. (default: True) Default is True.

  • return_inner_v (Union[str, bool]) – Either ‘first’, ‘all’, or False. ‘first’ means the variables for the first task (default: False) inner loop will also be returned. variables for all tasks will be returned with ‘all’. Default is False.

  • num_tasks (Optional[int]) – Number of unique tasks to inner-loop optimize for the meta step. Determined from (default: None) batch by default.

  • stop_gradients (bool) – Whether to stop the gradients of the cost. Default is True. (default: True)

Return type

Tuple[Array, Container, Any]

Returns

ret – The cost and the gradients with respect to the outer loop variables.

Device Support

Device

JAX

NumPy

TensorFlow

PyTorch

CPU

GPU


Supported Frameworks: