Tensors
Tensors
Vector Operations
Matrix Operations
Linear Regression
Mathematics
A tensor describes a relationship between algebraic objects.
Torch
An n-dimensional array with optimized operations.
#> torch_tensor
#> 1 4 7
#> 2 5 8
#> 3 6 9
#> [ CPUFloatType{3,3} ]
#> torch_tensor
#> 1
#> 2
#> 3
#> [ CPUFloatType{3} ]
#> torch_tensor
#> (1,.,.) =
#> 1 13
#> 5 17
#> 9 21
#>
#> (2,.,.) =
#> 2 14
#> 6 18
#> 10 22
#>
#> (3,.,.) =
#> 3 15
#> 7 19
#> 11 23
#>
#> (4,.,.) =
#> 4 16
#> 8 20
#> 12 24
#> [ CPUFloatType{4,3,2} ]
Note
Use if cuda is installed (Nvidia users)
Tensors
Vector Operations
Matrix Operations
Linear Regression
Tensors
Vector Operations
Matrix Operations
Linear Regression
#> torch_tensor
#> 1 4 7
#> 2 5 8
#> 3 6 9
#> [ CPUFloatType{3,3} ]
#> torch_tensor
#> 2 4 4
#> 4 3 3
#> 3 2 4
#> [ CPUFloatType{3,3} ]
#> torch_tensor
#> 1
#> 2
#> 3
#> [ CPUFloatType{3,1} ]
More information on matrix arithmetic can be found here.
More information on matrix multiplication can be found here.
Tensors
Vector Operations
Matrix Operations
Linear Regression
\[ Y_i = 3.85 + 12.3 X_1 - 9.7 X_2 + \varepsilon_i \]
\[ \varepsilon \sim N(0, 2.4) \]
\[ \hat\bbeta = (\bX^\mrT\bX)\inv\bX^\mrT\bY \]
\[ \bX =\left( \begin{array}{ccc} 1 & X_{1,1} & X_{2,1} \\ 1 & X_{1,2} & X_{2,2} \\ \vdots & \vdots & \vdots \\ 1 & X_{1,500} & X_{2,500} \\ \end{array} \right) \]
\[ \bY =\left( \begin{array}{ccc} Y_1 \\ Y_2 \\ \vdots \\ Y_{500} \end{array} \right) \]
\[ \hat\bbeta = (\bX^\mrT\bX)\inv\bX^\mrT\bY \]
\[ \hat\bbeta = (\bX^\mrT\bX)\inv\bX^\mrT\bY \]
m408.inqs.info/lectures/1a