I have tensors of BxCHxW where B is the batch. Then are the following codes equivalent?
l1_loss = torch.nn.L1Loss()
loss = l1_loss(pred,gt)
and
l1_loss = torch.nn.L1Loss()
for idx in range(B):
if idx==0:
loss = l1_loss(pred[idx,:,:,:],gt[idx,:,:,:])
else:
loss = l1_loss(pred[idx,:,:,:],gt[idx,:,:,:]) + loss
loss = loss/B