Assignment 1 - All About torch.Tensor
Deep Learning with PyTorch: Zero to GANs
PyTorch is a framework based on the python language, in order to make scientific computing and enabling the use of GPUs to speed up the computing process. It is used mainly for deep learning. The mathematical workhorse of the computations is the tensor, which is a multi-dimensional matrix. Tensors hold elements of a single data type.
There are hundreds of tensor-related functions in PyTorch. In this assignment we will discuss 5 of them, selected with the criteria of being statistical distribution tensor filler functions.
- normal_()
- bernoulli()
- cauchy_()
- exponential_()
- random_()
# Import torch and other required modules
import torch
Function 1 - normal_()
This is an in-place function for filling a referred tensor with the paramatrized normal distribution, with options being mean=x and std=y.
normal_(mean=0, std=1, *, generator=None) → Tensor
torch.empty(3,3).normal_(mean=0,std=1)
tensor([[1., 2.],
[3., 4.]])
This is a 3 by 3 tensor with normally distributed values.