RNN
RNN Notes ( in development )
Recurrent Neural Network
- Input
- Hidden State
- Output
We can process a sequence of vectors x by applying a recurrence of formula at every time step.
Example of rnn for captcha identification
first let's define a dataset, we'll use the dataset base class from pytorch. The dataloader is being used to stack the images together into batches. we will use a collate_fn method to fix the issue of variable length
here is a sample image :
defining the dataset class
import os
class CaptchaDataset(Dataset):
def __init__(self) -> None:
self.data_dir = "" # make sure data_dir ends with forward slash
self.filenames = [self.data_dir + item for item in os.listdir(self.data_dir)]
return
def __len__(self) -> int:
return len(self.filenames)
def __getitem__(self, idx):
"""
load image
convert to single channel
return img in tensor format, label
"""
return
