Imports

Distributed Training

import torch.distributed as dist             # distributed communication
from torch.multiprocessing import Process    # memory sharing processes

Vision

from torchvision import datasets, models, transforms     # vision datasets,
                                                         # architectures &
                                                         # transforms
import torchvision.transforms as transforms              # composable transforms

ONNX

torch.onnx.export(model, dummy data, xxxx.proto)       # exports an ONNX formatted
                                                       # model using a trained model, dummy
                                                       # data and the desired file name
model = onnx.load("alexnet.proto")                     # load an ONNX model
onnx.checker.check_model(model)                        # check that the model
                                                       # IR is well formed
onnx.helper.printable_graph(model.graph)               # print a human readable
                                                       # representation of the graph

Torchscript and JIT

torch.jit.trace()         # takes your module or function and an example
                          # data input, and traces the computational steps
                          # that the data encounters as it progresses through the model
@script                   # decorator used to indicate data-dependent
                          # control flow within the code being traced

Neural Network API

import torch.autograd as autograd         # computation graph
from torch import Tensor                  # tensor node in the computation graph
import torch.nn as nn                     # neural networks
import torch.nn.functional as F           # layers, activations and more
import torch.optim as optim               # optimizers e.g. gradient descent, ADAM, etc.
from torch.jit import script, trace       # hybrid frontend decorator and tracing jit

General

import torch                                        # root package
from torch.utils.data import Dataset, DataLoader    # dataset representation and loading
Comments