randint randint(start, end, (tensor size)) torch.randint(3, 5, (3,)) >>> tensor([4, 3, 4]) torch.randint(3, 10, (2, 2)) >>> tensor([[4, 5], [6, 7]]) scatter_ scatter_(dim, index, value) y.unsqueeze(1) >>> tensor([[3], [1], [2]]) y_one_hot.scatter_(1, y.unsqueeze(1),1) >>> tensor([[0., 0., 0., 1., 0.], # tensor(1.7024, grad_fn=) - cost function 2 : log_softmax (y_one_hot * - F.log_softmax(model(x..