Pytorch Exercise
Pytorch Exercise
1. Tensor Creation
● torch.tensor() - This function creates a tensor from a Python list or NumPy array.
● torch.arange() - This function creates a tensor with values from start to end with a
specified
● torch.eye() - This function creates a tensor with ones on the diagonal and zeros
elsewhere.
● torch.rand() - This function creates a tensor with random values from a uniform
distribution.
● torch.randint() - This function creates a tensor with random integer values from a
specified range.
2. Tensor Operations
● Arithmetic operations:
● Matrix operations:
● Reduction operations:
1. torch.sum() - Calculates the sum of all elements in a tensor.
● Comparison operations:
● Reshaping operations:
● Layers:
1. torch.nn.Linear()- This function is used to create a fully connected linear layer.
It takes in the number of input features and output features as arguments. This
layer performs a matrix multiplication followed by an optional bias addition.
● Loss functions:
● Optimizers:
● Utility modules:
1. torch.nn.Module() - This function is used to create a neural network module. It
is the base class for all neural network modules in PyTorch and provides the
basic functionality for defining and training neural networks.