Professional Documents
Culture Documents
Pytorch Assignment 1
Pytorch Assignment 1
For example, if input is a vector of size N, the result will also be a vector of
size N, with elements.
>>> a = torch.randn(10)
>>> a
tensor([ 0.6001, 0.2069, -0.1919, 0.9792, 0.6727, 1.0062, 0.4126,
-0.2129, -0.4206, 0.1968])
>>> torch.cumprod(a, dim=0)
tensor([ 0.6001, 0.1241, -0.0238, -0.0233, -0.0157, -0.0158, -0.0065,
0.0014, -0.0006, -0.0001])
Parameters
input (Tensor) – the input tensor.
start_dim (int) – the first dim to flatten
end_dim (int) – the last dim to flatten
Example:
The elements are sorted into equal width bins between min and max .
If min and max are both zero, the minimum and maximum values of the data
are used.
Parameters
input (Tensor) – the input tensor.
bins (int) – number of histogram bins
min (int) – lower end of the range (inclusive)
max (int) – upper end of the range (inclusive)
out (Tensor, optional) – the output tensor.
Returns
Histogram represented as a tensor
Return type
Tensor
Example:
Parameters
input (Tensor) – the input tensor.
dims (a list or tuple) – axis to flip on
Example:
>>> x = torch.arange(8).view(2, 2, 2)
>>> x
tensor([[[ 0, 1],
[ 2, 3]],
[[ 4, 5],
[ 6, 7]]])
>>> torch.flip(x, [0, 1])
tensor([[[ 6, 7],
[ 4, 5]],
[[ 2, 3],
[ 0, 1]]])
torch.trunc (input, out=None) → Tensor
Returns a new tensor with the truncated integer values of the elements
of input .
Parameters
input (Tensor) – the input tensor.
out (Tensor, optional) – the output tensor.
Example:
>>> a = torch.randn(4)
>>> a
tensor([ 3.4742, 0.5466, -0.8008, -0.9079])
>>> torch.trunc(a)
tensor([ 3., 0., -0., -0.])