basics
Packages
import torch #similar to numpy
import torch.autograd #differntiation lib
import torch.nn as nn# neural networks lib with autograd integration
import torch.nn.functional as F #functional implementation of nn(lower level, not trainable)
import torch.optim as optim # standard op methods like gradient descent
torch.manual_seed(123)Tensors
Creation
torch.empty(5,3) #uninitialized 5*3
torch.rand(5,3)
torch.zeroes(5, 3, dtype=torch.long)v = [1,2,3]
v_tensor = torch.Tensor(v)size
Operations
Cat
Reshape
Numpy
Computation Graphs and Automatic Differentiation
See comp graph
Last updated