I'm curious about the difference between torch.zeros and torch.zeros_like, so I'll write it.
Returns a tensor with a value of 0.
>>> torch.zeros(3, 2)
tensor([[0., 0.],
[0., 0.],
[0., 0.]])
>>> torch.zeros(3)
tensor([0., 0., 0.])
It is used when you want to set all the values of a certain tensor to 0.
>>> input = torch.empty(3, 2)
tensor([[3.2561e+09, 3.0936e-41],
[0.0000e+00, 0.0000e+00],
[3.2557e+09, 3.0936e-41]])
>>> torch.zeros_like(input)
tensor([[0., 0.],
[0., 0.],
[0., 0.]])
In the above example, all input values are set to 0.