How to use torch.add() to Add Tensors in PyTorch

First Tensor:
tensor([[[ 0,  1,  2],
         [ 3,  4,  5],
         [ 6,  7,  8],
         [ 9, 10, 11]],

        [[12, 13, 14],
         [15, 16, 17],
         [18, 19, 20],
         [21, 22, 23]]])
Second Tensor:
tensor([[[ 4,  5,  6],
         [ 7,  8,  9],
         [10, 11, 12],
         [13, 14, 15]],

        [[16, 17, 18],
         [19, 20, 21],
         [22, 23, 24],
         [25, 26, 27]]])
Sum of Tensor1 and Tensor2:
tensor([[[ 4,  6,  8],
         [10, 12, 14],
         [16, 18, 20],
         [22, 24, 26]],

        [[28, 30, 32],
         [34, 36, 38],
         [40, 42, 44],
         [46, 48, 50]]])

 

 

 

To finish reading, please visit source site

Leave a Reply