hello,
>>> b = torch.tensor([1,2,3])
>>> a = torch.tensor([1,2,3,4,5,6,7,8,9])
what should I do to make c = a* b = [1,4,9,4,10,18,7,16,27]??
Thanks!
hello,
>>> b = torch.tensor([1,2,3])
>>> a = torch.tensor([1,2,3,4,5,6,7,8,9])
what should I do to make c = a* b = [1,4,9,4,10,18,7,16,27]??
Thanks!
Maybe you should read tensor matrix operation first
c = (a.reshape(-1, b.shape[0])*b).flatten()
Thanks!I do it in this way
b.repeat(3).mul(a)
=-=
c = a.reshape(-1, b.shape[0]) * b
print(c.flatten())
I’d like to use the broadcast mechanic instead of extend the tensor manually, for I guess the broadcast implement in the torch or numpy will be more efficient.