Neural Network Tutorials - Herong's Tutorial Examples - 1.20, by Dr. Herong Yang
Commonly Used 'torch' Funcitons
This section describes some commonly used PyTorch functions, including add(), multiply(), matmul(), tf.reduce_sum(), tf.nn.softmax(), etc.
As a quick reference, here is a list of commonly used PyTorch, "torch" library, functions:
1. Functions provided by the "torch" module itself:
torch.empty(m, n, ...) - Creates an empty tensor with the given shape.
torch.rand(m, n, ...) - Creates a tensor of random values with the given shape.
torch.torch.zeros(m, n, ...) - Creates a tensor of zeros with the given shape.
torch.tensor([[...],[...],...]) - Creates an tensor with the given date.
torch.rand_like(a) - Creates an empty tensor with the given shape.
a.size() - Returns the size (shape) of this tensor.
torch.add(a,b) - Creates a tensor by taking the sum of two given tensors. Same as (a+b).
a.add_(b) - Updates this tensor by adding values from the given tensor.
x.view(n, m, ...) - Creates a tensor by reshaping this tensor with the given shape.
Table of Contents