Element Wise Multiplication of Tensors in PyTorch with torch.mul() & torch.multiply()

Element Wise Multiplication of Tensors in PyTorch with torch.mul() & torch.multiply()

Introduction

In this article, we will see how we can perform element-wise multiplication of tensors in PyTorch by using torch.mul() or torch.multiply() function. We will see various examples to understand better how these functions work.

Element Wise Tensor Multiplication with torch.mul() & torch.multiply()

torch.mul() function in PyTorch is used to do element-wise multiplication of tensors. It should be noted here that torch.multiply() is just an alias for torch.mul() function and they do the same work.

Using either of torch.mul()

 

 

 

To finish reading, please visit source site

Leave a Reply