
Before you can see the whole, it’s sea.
Before you organize the whole, it’s universe.
See the whole and organize it, it’s a transparent box.
——Sky. J.
| tensor | torch.is_tensor(obj) | Returns True if obj is a PyTorch tensor. |
| torch.is_storage(obj) | Returns True if obj is a PyTorch storage object. | |
| torch.set_default_dtype(d) | Sets the default floating point dtype to d. The default floating point dtype is initially torch.float32. | |
| torch.get_default_dtype() | Get the current default floating point torch.dtype. | |
| creation ops | torch.tensor(data, dtype=None, device=None, requires_grad=False) | Constructs a tensor with data. |
| torch.from_numpy(ndarray) | Creates a Tensor from a numpy.ndarray. The returned tensor and ndarray share the same memory. Modifications to the tensor will be reflected in the ndarray and vice versa. The returned tensor is not resizable. | |
| torch.zeros(sizes, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False) | Returns a tensor filled with the scalar value 0, with the shape defined by the variable argument sizes. | |
| torch.zeros_like(input, dtype=None, layout=None, device=None, requires_grad=False) | Returns a tensor filled with the scalar value 0, with the same size as input. | |
| torch.ones(sizes, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False) | Returns a tensor filled with the scalar value 1, with the shape defined by the variable argument sizes. | |
| torch.ones_like(input, dtype=None, layout=None, device=None, requires_grad=False) | Returns a tensor filled with the scalar value 1, with the same size as input. | |
| torch.arange(start=0, end, step=1, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False) | [start(=0):step(=1):end) (favor) | |
| torch.range(start=0, end, step=1, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False) | [start(=0):step(=1):end] | |
| torch.linspace(start, end, steps=100, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False) | Returns a one-dimensional tensor of steps equally spaced points between start and end. The output tensor is 1-D of size steps. | |
| torch.logspace(start, end, steps=100, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False) | Returns a one-dimensional tensor of steps points logarithmically spaced between 10^start and 10^end | |
| torch.eye(n, m=None, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False) | Returns a 2-D tensor with ones on the diagonal and zeros elsewhere. | |
| torch.empty(*sizes, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False) | Returns a tensor filled with uninitialized data. The shape of the tensor is defined by the variable argument sizes. | |
| torch.empty_like(input, dtype=None, layout=None, device=None, requires_grad=False) | Returns an uninitialized tensor with the same size as input. | |
| torch.full(size, fill_value, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False) | Returns a tensor of size size filled with fill_value. | |
| torch.full_like(input, fill_value, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False) | Returns a tensor with the same size as input filled with fill_value. | |
| Indexing, Slicing, Joining, Mutating Ops | torch.cat(seq, dim=0, out=None) | Concatenates the given sequence of seq tensors in the given dimension. All tensors must either have the same shape (except in the concatenating dimension) or be empty. |
| torch.chunk(tensor, chunks, dim=0) | Splits a tensor into a specific number of chunks. Last chunk will be smaller if the tensor size along the given dimension dim is not divisible by chunks. | |
| torch.gather(input, dim, index, out=None) | Gathers values along an axis specified by dim. | |
| torch.index_select(input, dim, index, out=None) | Returns a new tensor which indexes the input tensor along dimension dim using the entries in index which is a LongTensor. | |
| torch.masked_select(input, mask, out=None) | Returns a new 1-D tensor which indexes the input tensor according to the binary mask mask which is a ByteTensor. The shapes of the mask tensor and the input tensor don’t need to match, but they must be broadcastable. | |
| torch.nonzero(input, out=None) | Returns a tensor containing the indices of all non-zero elements of input. Each row in the result contains the indices of a non-zero element in input. If input has n dimensions, then the resulting indices tensor out is of size (z×n), where z is the total number of non-zero elements in the input tensor. | |
| torch.reshape(input, shape) | Returns a tensor with the same data and number of elements as input, but with the specified shape. When possible, the returned tensor will be a view of input. Otherwise, it will be a copy. | |
| torch.split(tensor, split_size_or_sections, dim=0) | Splits the tensor into chunks. | |
| torch.squeeze(input, dim=None, out=None) | Returns a tensor with all the dimensions of input of size 1 removed. | |
| torch.stack(seq, dim=0, out=None) | Concatenates sequence of tensors along a new dimension. All tensors need to be of the same size. seq (sequence of Tensors) – sequence of tensors to concatenate | |
| torch.t(input) | Expects input to be a matrix (2-D tensor) and transposes dimensions 0 and 1. | |
| torch.take(input, indices) | Returns a new tensor with the elements of input at the given indices. The input tensor is treated as if it were viewed as a 1-D tensor. The result takes the same shape as the indices. | |
| torch.transpose(input, dim0, dim1) | Returns a tensor that is a transposed version of input. The given dimensions dim0 and dim1 are swapped. | |
| torch.unbind(tensor, dim=0) | Removes a tensor dimension. Returns a tuple of all slices along a given dimension, already without it. | |
| torch.unsqueeze(input, dim, out=None) | Returns a new tensor with a dimension of size one inserted at the specified position. The returned tensor shares the same underlying data with this tensor. | |
| torch.where(condition, x, y) | Return a tensor of elements selected from either x or y, depending on condition. The tensors condition, x, y must be broadcastable. |
UPDATING…
PICK FROM https://pytorch.org/docs/stable/torch.html#tensors




近期评论