2

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

0

1 Answer 1

2

Using torch.kron will give a tensor a x b*c, then using torch.Tensor.reshape could map to a tensor a x b x c :

t3=torch.kron(t1,t2).reshape(a,b,c) 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.