How to use torch.sub() to Subtract 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]]])
Tensor1 minus Tensor2:
tensor([[[-4, -4, -4],
         [-4, -4, -4],
         [-4, -4, -4],
         [-4, -4, -4]],

        [[-4, -4, -4],
         [-4, -4, -4],
         [-4, -4, -4],
         [-4, -4, -4]]])

 

 

 

To finish reading, please visit source site

Leave a Reply