Learn practical skills, build real-world projects, and advance your career
Updated 4 years ago
PyTorch: Zero to GANs
Assignment 1
PyTorch is an open source AI library dependent on the Torch library, utilized for applications.
Here, we will examine 5 operations that can provide used in Pytorch.
- function 1 : torch.transpose()
- function 2 : torch.reshape()
- function 3 : torch.squeeze()
- function 4 : torch.flatten()
- function 5 : torch.dist()
# Import torch and other required modules
import torch
Function 1 - torch.transpose(input, dim0, dim1) → Tensor
Returns a tensor swap two axes at once input.
# Example 1 - working (change this)
x = torch.tensor([[1, 3, 5],[6, 9, 8]])
print("before transpose:",x)
torch.transpose(x, 1, 0)
before transpose: tensor([[1, 3, 5],
[6, 9, 8]])
tensor([[1, 6],
[3, 9],
[5, 8]])
Changing the content of one would change the content of the other.