I this piece of code of yours
# accuracy
            _, predicted = torch.max(outputs.data, 1)
            total_train += mask.size(0)
            correct_train += predicted.eq(mask.data).sum().item()`

what are you trying to do in first line with torch.max especially why 1 and not 0. In 3rd line with predicted.eq()