Hello guys. I am very interested in learning PyTorch.so I am trying to understand some basic code in PyTorch.
here are some of the doubts I got while going through the code

I found a piece of code like this in training function

for batch_idx, (data, target) in enumerate(pbar):
    # get samples
    data, target = data.to(device), target.to(device)

Here my doubt is what does "data.to(device), target.to(device ) "do in PyTorch.
2)I also found line of code
optimizer.zero_grad()
what does this piece of code do in PyTorch? One of the comments says that it will make gradients zero.
so what does the advantage if we make gradients to zero.??