Tom Hale
Tom Hale

Reputation: 46775

PyTorch element-wise product of vectors / matrices / tensors

In PyTorch, how do I get the element-wise product of two vectors / matrices / tensors?

For googlers, this is product is also known as:

Upvotes: 41

Views: 57528

Answers (1)

Tom Hale
Tom Hale

Reputation: 46775

Given two tensors A and B you can use either:

Note: for matrix multiplication, you want to use A @ B which is equivalent to torch.matmul().

Upvotes: 60

Related Questions