How can a variable mutiply with a variable

I have 8 variable the size is 128641616 in a list lista , and a variable is 1288 which named mask
I want use the mask combine the lista to a variable named output.
mask=torch.t(mask)
for i in range(8):
for j in range(128):
lista[i][j] = lista [i][j] * mask[i][j]

but there is a error:

TypeError: mul received an invalid combination of arguments - got (torch.FloatTensor), but expected one of:

  • (float value)
    didn’t match because some of the arguments have invalid types: (torch.FloatTensor)
  • (torch.cuda.FloatTensor other)
    didn’t match because some of the arguments have invalid types: (torch.FloatTensor)
    how can i solve it?
    thank you.

Hi the problem is that one of your tensor is a cuda tensor while the other one is a cpu tensor. You should call .cuda() on the cpu one.

2 Likes

thank you. it works.