Pytorch, Torch, Torchvision, Deep Learning, Python.
labels.to(device) # Convert train data to Variable to store the gradients train = Variable(images.view(images.shape)) labels = Variable(labels) # Forward pass outputs = model(train) loss = error(outputs, labels) # Initializing a gradient as zero to avoid blending of gradient among the batches.