PyTorch RNN From Scratch

API, Code, ML, Python, PyTorch
PyTorch RNN From Scratch New to pyTorch, as usual, wanted to learn by doing things from scratch. Below are a few blogs that got me going.Number 1, really from scratchhttps://towardsdatascience.com/understanding-pytorch-with-an-example-a-step-by-step-tutorial-81fc5f8c4e8e?#3a3fImageRNN but it is using nn.RNN, I wanted even lower.. :)https://medium.com/dair-ai/building-rnns-is-fun-with-pytorch-and-google-colab-3903ea9a3a79PyTorch - Tutorial that set me thinking..but this is text classification not using Dataloader and batch processing, as I consider batching is tricky one to get going, so, I wanted to indulge on it ;)https://pytorch.org/tutorials/intermediate/char_rnn_classification_tutorial.htmlhttps://pytorch.org/tutorials/beginner/former_torchies/nnft_tutorial.html[code] import torchimport torch.nn as nn import torchvision import torchvision.transforms as transforms import matplotlib.pyplot as plt import numpy as np [/code]Load the MNIST data[code] BATCH_SIZE = 64 # list all transformations transform = transforms.Compose( [transforms.ToTensor()]) # download and load training dataset trainset = torchvision.datasets.MNIST(root='./data', train=True, download=True, transform=transform) trainloader = torch.utils.data.DataLoader(trainset, batch_size=BATCH_SIZE,shuffle=True, num_workers=2,drop_last=True) # download and load testing…
Read More