Implementation of NTM

As discussed, an NTM is composed of two important components:

  • A neural network, also known as the controller
  • A two-dimensional matrix called memory

In this tutorial, we will implement a simplistic version of both and try to showcase the copy tasks.

The task objective is as follows:

  • The NTM model is shown a random k-dimensional vector for T time steps.
  • The job of the network is to output these T k-dimensional random vectors from zero vectors at each time step.

Perform the following steps to implement NTMs:

  1. First, import all the required libraries:
import torchfrom torch import nnimport torch.nn.functional as Fimport numpy as npfrom time import timeimport torchvision.utils as vutilsfrom torch.utils.data import Dataset ...

Get Hands-On One-shot 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.