Implementing a recurrent network

So we can concentrate on the models, we will use the same dataset we are familiar with. Even though we are working with static images, we can treat these as a time series by unrolling each 28 pixel input size over 28 time steps, enabling the network to make a computation on the complete image:

In the preceding model, we use the nn.RNN class to create a model with two recurrent layers. The nn.RNN class has the following default signature:

nn.RNN(input_size, hidden_size, num_layers, batch_first=False, nonlinearity = 'tanh' 

The input is our 28 x 28 MNIST images. This model takes 28 pixels of each image, unrolling ...

Get Deep Learning with PyTorch Quick Start Guide 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.