Transformers, Pytorch, Machine Learning, Deep Dives, Data Science.
numpy as np import matplotlib.pyplot as plt from tqdm import tqdm from torch.utils.data import DataLoader from torch.nn.utils.rnn import pad_sequence from mpl_toolkits.axes_grid1 import ImageGrid def collate_fn(batch): """ This function pads inputs with PAD_IDX to have batches of equal length """