Learn practical skills, build real-world projects, and advance your career
Updated 4 years ago
Week 1 Assignment
Subtitle Here
PyTorch is an open source machine learning library based on the Torch library, used for applications such as computer vision and natural language processing, primarily developed by Facebook's AI Research lab
torch.max()
torch.min()
torch.where()
torch.reshape()
torch.eye()
# Import torch and other required modules
import torch
Function 1 - max()
torch.max() is used to return the maximumm value of the input tensors.
torch.max(input) → Tensor
The parameters for this function input (Tensor) – the input tensor of size (*, n, n).
torch.max(input, dim, keepdim=False, out=None) -> (Tensor, LongTensor)
# Example 1 - working (change this)
max_ten = torch.randn([1, 3])
print(max_ten)
max_element = torch.max(max_ten)
print(max_element)
tensor([[0.2903, 2.3476, 0.5144]])
tensor(2.3476)
The following example return the largest element in the above given tensor that has been randomnly generated using the random function.