dataset = NetDataset()
train_loader = DataLoader(dataset=dataset, batch_size=128, shuffle=True)

…
for i, (inputs, labels) in enumerate(train_loader):
y_pred = model(inputs)
loss = criterion(y_pred, labels)