Notes from PyTorch bootcamp
Numpy
import numpy as np
x = np.array([1,1])
Simple arithmetic
x = np.array([4,4,6])
y = np.array([5,3.4,6])
z = x + y
print (z)
Dot product:
np.dot(x,y)
Matrix: np.matrix
x = np.matrix([[4,5], [6,7])
Matrix multiplication:
np.multiply(a,b) - elementwise; otherwise a*b
Inverse matrix:
from numpy.linalg import inv
print (inv(x))
PyTorch
import torch
import numpy as np
x = [[4,3],[5,6]]
y = np.array(x)
z = torch.Tensor(y)