Learn practical skills, build real-world projects, and advance your career

Title Here

Subtitle Here

An short introduction about PyTorch and about the chosen functions.

  • torch.t()
  • function 2
  • function 3
  • function 4
  • function 5
# Import torch and other required modules
import torch

Function 1 - torch.t ()

This function is used to transpose the tensor.

# Example 1 - working 
x = torch.randn((2,6))
print(x)
torch.t(x)
tensor([[-1.3359, -0.7484, 0.3769, -0.7799, 0.2041, -1.1173], [-0.1039, 0.3924, -1.6204, 0.5465, -0.9032, -0.5252]])
tensor([[-1.3359, -0.1039],
        [-0.7484,  0.3924],
        [ 0.3769, -1.6204],
        [-0.7799,  0.5465],
        [ 0.2041, -0.9032],
        [-1.1173, -0.5252]])

The random values were obtained in a matrix tensor