PyTorch - Tensors multiplication along new dimension

Viewed 109

Sorry if already asked, but I can't find the words to look for on Google.

Let's say I have a tensor t1 of size [a,b] and a tensor t2 of size [c].

How can I output a tensor t3 of size [a,b,c], so that:

t3[0, :, 0] = t1[0, :] * t2[0]
t3[0, :, 1] = t1[0, :] * t2[1]
t3[0, :, 2] = t1[0, :] * t2[2]

...

t3[1, :, 0] = t1[1, :] * t2[0]
t3[1, :, 1] = t1[1, :] * t2[1]
t3[1, :, 2] = t1[1, :] * t2[2]

and so on, without a for loop ?

Thanks

1 Answers
Related