Torch multiplicaiton


I have two tensors.

a.size() is torch.size([64, 3, 3, 3])
b.size() is torch.size([64])

I wanna a[0]*b[0], a[1]*b[1], … a[63]*b[63].

Should I use for loop to operate above calculations?


What do you mean by a[0]*b[0] ? Because a[0] is a tensor while b[0] is a number?
If you want to add the value of b[0] element-wise to a[0], then a * b.view(64, 1, 1, 1).expand_as(a).