PyTorch

Why do we use it?

  1. Many research works related to Deep Learning (DL) are implemented on PyTorch
  2. It's a constantly evolving and expanding package (functorch)
  3. Package provide wide variety of tools to make your code computationally efficient (GPU)

How to initialize vectors, matrices, tensors (object with number of dimensions more than 2)?

Manual definition

From numpy

Zero, ones, random vector

Zeros

Ones

Range

Linspace

Matrices

Identity matrix

Diagonal of matrix

Diagonal matrix

Random matrix (uniform distribution)

Random matrix (normal distribution)

How calculate statistics on tensors

Numpy operations in PyTorch

Multiplication

Reshaping and dimension permutation

Decompositions

How to transfer data to GPU

Neural Networks

Simple network

More complex networks

$$\mathrm{net} = f_2(f_1(f_0(x)))$$$$f_0() = Linear(100,50)()$$$$f_1() = ReLU()$$$$f_2() = Linear(50,10)()$$

How to calc gradients and jacobians? (functorch)

Calculation of jacobian using standard tools

[1,20,100]

FuncTorch

FuncTorch operations over batch