text
stringlengths
0
1.73k
source
stringlengths
35
119
category
stringclasses
2 values
torch.hsplit torch.hsplit(input, indices_or_sections) -> List of Tensors Splits "input", a tensor with one or more dimensions, into multiple tensors horizontally according to "indices_or_sections". Each split is a view of "input". If "input" is one dimensional this is equivalent to calling torch.tensor_split(input, indices_or_sections, dim=0) (the split dimension is zero), and if "input" has two or more dimensions it's equivalent to calling torch.tensor_split(input, indices_or_sections, dim=1) (the split dimension is 1), except that if "indices_or_sections" is an integer it must evenly divide the split dimension or a runtime error will be thrown. This function is based on NumPy's "numpy.hsplit()". Parameters: * input (Tensor) -- tensor to split. * **indices_or_sections** (*int** or **list** or **tuple of ints*) -- See argument in "torch.tensor_split()". Example:: >>> t = torch.arange(16.0).reshape(4,4) >>> t
https://pytorch.org/docs/stable/generated/torch.hsplit.html
pytorch docs
t tensor([[ 0., 1., 2., 3.], [ 4., 5., 6., 7.], [ 8., 9., 10., 11.], [12., 13., 14., 15.]]) >>> torch.hsplit(t, 2) (tensor([[ 0., 1.], [ 4., 5.], [ 8., 9.], [12., 13.]]), tensor([[ 2., 3.], [ 6., 7.], [10., 11.], [14., 15.]])) >>> torch.hsplit(t, [3, 6]) (tensor([[ 0., 1., 2.], [ 4., 5., 6.], [ 8., 9., 10.], [12., 13., 14.]]), tensor([[ 3.], [ 7.], [11.], [15.]]), tensor([], size=(4, 0)))
https://pytorch.org/docs/stable/generated/torch.hsplit.html
pytorch docs
torch.Tensor.aminmax Tensor.aminmax(*, dim=None, keepdim=False) -> (Tensor min, Tensor max) See "torch.aminmax()"
https://pytorch.org/docs/stable/generated/torch.Tensor.aminmax.html
pytorch docs
ConvBn3d class torch.ao.nn.intrinsic.qat.ConvBn3d(in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, bias=None, padding_mode='zeros', eps=1e-05, momentum=0.1, freeze_bn=False, qconfig=None) A ConvBn3d module is a module fused from Conv3d and BatchNorm3d, attached with FakeQuantize modules for weight, used in quantization aware training. We combined the interface of "torch.nn.Conv3d" and "torch.nn.BatchNorm3d". Similar to "torch.nn.Conv3d", with FakeQuantize modules initialized to default. Variables: * freeze_bn -- * **weight_fake_quant** -- fake quant module for weight
https://pytorch.org/docs/stable/generated/torch.ao.nn.intrinsic.qat.ConvBn3d.html
pytorch docs
torch.Tensor.retain_grad Tensor.retain_grad() -> None Enables this Tensor to have their "grad" populated during "backward()". This is a no-op for leaf tensors.
https://pytorch.org/docs/stable/generated/torch.Tensor.retain_grad.html
pytorch docs
BCELoss class torch.nn.BCELoss(weight=None, size_average=None, reduce=None, reduction='mean') Creates a criterion that measures the Binary Cross Entropy between the target and the input probabilities: The unreduced (i.e. with "reduction" set to "'none'") loss can be described as: \ell(x, y) = L = \{l_1,\dots,l_N\}^\top, \quad l_n = - w_n \left[ y_n \cdot \log x_n + (1 - y_n) \cdot \log (1 - x_n) \right], where N is the batch size. If "reduction" is not "'none'" (default "'mean'"), then \ell(x, y) = \begin{cases} \operatorname{mean}(L), & \text{if reduction} = \text{`mean';}\\ \operatorname{sum}(L), & \text{if reduction} = \text{`sum'.} \end{cases} This is used for measuring the error of a reconstruction in for example an auto-encoder. Note that the targets y should be numbers between 0 and 1. Notice that if x_n is either 0 or 1, one of the log terms would be
https://pytorch.org/docs/stable/generated/torch.nn.BCELoss.html
pytorch docs
mathematically undefined in the above loss equation. PyTorch chooses to set \log (0) = -\infty, since \lim_{x\to 0} \log (x) = -\infty. However, an infinite term in the loss equation is not desirable for several reasons. For one, if either y_n = 0 or (1 - y_n) = 0, then we would be multiplying 0 with infinity. Secondly, if we have an infinite loss value, then we would also have an infinite term in our gradient, since \lim_{x\to 0} \frac{d}{dx} \log (x) = \infty. This would make BCELoss's backward method nonlinear with respect to x_n, and using it for things like linear regression would not be straight-forward. Our solution is that BCELoss clamps its log function outputs to be greater than or equal to -100. This way, we can always have a finite loss value and a linear backward method. Parameters: * weight (Tensor, optional) -- a manual rescaling weight given to the loss of each batch element. If given, has
https://pytorch.org/docs/stable/generated/torch.nn.BCELoss.html
pytorch docs
to be a Tensor of size nbatch. * **size_average** (*bool**, **optional*) -- Deprecated (see "reduction"). By default, the losses are averaged over each loss element in the batch. Note that for some losses, there are multiple elements per sample. If the field "size_average" is set to "False", the losses are instead summed for each minibatch. Ignored when "reduce" is "False". Default: "True" * **reduce** (*bool**, **optional*) -- Deprecated (see "reduction"). By default, the losses are averaged or summed over observations for each minibatch depending on "size_average". When "reduce" is "False", returns a loss per batch element instead and ignores "size_average". Default: "True" * **reduction** (*str**, **optional*) -- Specifies the reduction to apply to the output: "'none'" | "'mean'" | "'sum'". "'none'": no reduction will be applied, "'mean'": the sum of
https://pytorch.org/docs/stable/generated/torch.nn.BCELoss.html
pytorch docs
the output will be divided by the number of elements in the output, "'sum'": the output will be summed. Note: "size_average" and "reduce" are in the process of being deprecated, and in the meantime, specifying either of those two args will override "reduction". Default: "'mean'" Shape: * Input: (*), where * means any number of dimensions. * Target: (*), same shape as the input. * Output: scalar. If "reduction" is "'none'", then (*), same shape as input. Examples: >>> m = nn.Sigmoid() >>> loss = nn.BCELoss() >>> input = torch.randn(3, requires_grad=True) >>> target = torch.empty(3).random_(2) >>> output = loss(m(input), target) >>> output.backward()
https://pytorch.org/docs/stable/generated/torch.nn.BCELoss.html
pytorch docs
torch.Tensor.outer Tensor.outer(vec2) -> Tensor See "torch.outer()".
https://pytorch.org/docs/stable/generated/torch.Tensor.outer.html
pytorch docs
torch.Tensor.clip Tensor.clip(min=None, max=None) -> Tensor Alias for "clamp()".
https://pytorch.org/docs/stable/generated/torch.Tensor.clip.html
pytorch docs
torch.Tensor.square Tensor.square() -> Tensor See "torch.square()"
https://pytorch.org/docs/stable/generated/torch.Tensor.square.html
pytorch docs
torch.hann_window torch.hann_window(window_length, periodic=True, *, dtype=None, layout=torch.strided, device=None, requires_grad=False) -> Tensor Hann window function. w[n] = \frac{1}{2}\ \left[1 - \cos \left( \frac{2 \pi n}{N - 1} \right)\right] = \sin^2 \left( \frac{\pi n}{N - 1} \right), where N is the full window size. The input "window_length" is a positive integer controlling the returned window size. "periodic" flag determines whether the returned window trims off the last duplicate value from the symmetric window and is ready to be used as a periodic window with functions like "torch.stft()". Therefore, if "periodic" is true, the N in above formula is in fact \text{window_length} + 1. Also, we always have "torch.hann_window(L, periodic=True)" equal to "torch.hann_window(L + 1, periodic=False)[:-1])". Note: If "window_length" =1, the returned window contains a single value 1. Parameters:
https://pytorch.org/docs/stable/generated/torch.hann_window.html
pytorch docs
value 1. Parameters: * window_length (int) -- the size of returned window * **periodic** (*bool**, **optional*) -- If True, returns a window to be used as periodic function. If False, return a symmetric window. Keyword Arguments: * dtype ("torch.dtype", optional) -- the desired data type of returned tensor. Default: if "None", uses a global default (see "torch.set_default_tensor_type()"). Only floating point types are supported. * **layout** ("torch.layout", optional) -- the desired layout of returned window tensor. Only "torch.strided" (dense layout) is supported. * **device** ("torch.device", optional) -- the desired device of returned tensor. Default: if "None", uses the current device for the default tensor type (see "torch.set_default_tensor_type()"). "device" will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types.
https://pytorch.org/docs/stable/generated/torch.hann_window.html
pytorch docs
tensor types. * **requires_grad** (*bool**, **optional*) -- If autograd should record operations on the returned tensor. Default: "False". Returns: A 1-D tensor of size (\text{window_length},) containing the window Return type: Tensor
https://pytorch.org/docs/stable/generated/torch.hann_window.html
pytorch docs
fuse_fx class torch.quantization.quantize_fx.fuse_fx(model, fuse_custom_config=None, backend_config=None) Fuse modules like conv+bn, conv+bn+relu etc, model must be in eval mode. Fusion rules are defined in torch.quantization.fx.fusion_pattern.py Parameters: * model (***) -- a torch.nn.Module model * **fuse_custom_config** (***) -- custom configurations for fuse_fx. See "FuseCustomConfig" for more details Return type: GraphModule Example: from torch.ao.quantization import fuse_fx m = Model().eval() m = fuse_fx(m)
https://pytorch.org/docs/stable/generated/torch.quantization.quantize_fx.fuse_fx.html
pytorch docs
torch.linalg.solve torch.linalg.solve(A, B, *, left=True, out=None) -> Tensor Computes the solution of a square system of linear equations with a unique solution. Letting \mathbb{K} be \mathbb{R} or \mathbb{C}, this function computes the solution X \in \mathbb{K}^{n \times k} of the linear system associated to A \in \mathbb{K}^{n \times n}, B \in \mathbb{K}^{n \times k}, which is defined as AX = B If "left"= False, this function returns the matrix X \in \mathbb{K}^{n \times k} that solves the system XA = B\mathrlap{\qquad A \in \mathbb{K}^{k \times k}, B \in \mathbb{K}^{n \times k}.} This system of linear equations has one solution if and only if A is invertible. This function assumes that A is invertible. Supports inputs of float, double, cfloat and cdouble dtypes. Also supports batches of matrices, and if the inputs are batches of matrices then the output has the same batch dimensions.
https://pytorch.org/docs/stable/generated/torch.linalg.solve.html
pytorch docs
Letting *** be zero or more batch dimensions, If "A" has shape (, n, n) and "B" has shape (, n) (a batch of vectors) or shape (, n, k) (a batch of matrices or "multiple right-hand sides"), this function returns X of shape (, n) or (, n, k)* respectively. Otherwise, if "A" has shape (, n, n) and "B" has shape (n,) or (n, k), "B" is broadcasted to have shape (, n) or (, n, k)* respectively. This function then returns the solution of the resulting batch of systems of linear equations. Note: This function computes *X = *"A"*.inverse() @ *"B" in a faster and more numerically stable way than performing the computations separately. Note: It is possible to compute the solution of the system XA = B by passing the inputs "A" and "B" transposed and transposing the output returned by this function. Note: When inputs are on a CUDA device, this function synchronizes that device with the CPU.
https://pytorch.org/docs/stable/generated/torch.linalg.solve.html
pytorch docs
device with the CPU. See also: "torch.linalg.solve_triangular()" computes the solution of a triangular system of linear equations with a unique solution. Parameters: * A (Tensor) -- tensor of shape (, n, n)* where *** is zero or more batch dimensions. * **B** (*Tensor*) -- right-hand side tensor of shape *(*, n)* or *(*, n, k)* or *(n,)* or *(n, k)* according to the rules described above Keyword Arguments: * left (bool, optional) -- whether to solve the system AX=B or XA = B. Default: True. * **out** (*Tensor**, **optional*) -- output tensor. Ignored if *None*. Default: *None*. Raises: RuntimeError -- if the "A" matrix is not invertible or any matrix in a batched "A" is not invertible. Examples: >>> A = torch.randn(3, 3) >>> b = torch.randn(3) >>> x = torch.linalg.solve(A, b) >>> torch.allclose(A @ x, b) True
https://pytorch.org/docs/stable/generated/torch.linalg.solve.html
pytorch docs
torch.allclose(A @ x, b) True >>> A = torch.randn(2, 3, 3) >>> B = torch.randn(2, 3, 4) >>> X = torch.linalg.solve(A, B) >>> X.shape torch.Size([2, 3, 4]) >>> torch.allclose(A @ X, B) True >>> A = torch.randn(2, 3, 3) >>> b = torch.randn(3, 1) >>> x = torch.linalg.solve(A, b) # b is broadcasted to size (2, 3, 1) >>> x.shape torch.Size([2, 3, 1]) >>> torch.allclose(A @ x, b) True >>> b = torch.randn(3) >>> x = torch.linalg.solve(A, b) # b is broadcasted to size (2, 3) >>> x.shape torch.Size([2, 3]) >>> Ax = A @ x.unsqueeze(-1) >>> torch.allclose(Ax, b.unsqueeze(-1).expand_as(Ax)) True
https://pytorch.org/docs/stable/generated/torch.linalg.solve.html
pytorch docs
torch.polar torch.polar(abs, angle, *, out=None) -> Tensor Constructs a complex tensor whose elements are Cartesian coordinates corresponding to the polar coordinates with absolute value "abs" and angle "angle". \text{out} = \text{abs} \cdot \cos(\text{angle}) + \text{abs} \cdot \sin(\text{angle}) \cdot j Note: *torch.polar* is similar to std::polar and does not compute the polar decomposition of a complex tensor like Python's *cmath.polar* and SciPy's *linalg.polar* do. The behavior of this function is undefined if *abs* is negative or NaN, or if *angle* is infinite. Parameters: * abs (Tensor) -- The absolute value the complex tensor. Must be float or double. * **angle** (*Tensor*) -- The angle of the complex tensor. Must be same dtype as "abs". Keyword Arguments: out (Tensor) -- If the inputs are "torch.float32", must be "torch.complex64". If the inputs are "torch.float64", must be
https://pytorch.org/docs/stable/generated/torch.polar.html
pytorch docs
"torch.complex128". Example: >>> import numpy as np >>> abs = torch.tensor([1, 2], dtype=torch.float64) >>> angle = torch.tensor([np.pi / 2, 5 * np.pi / 4], dtype=torch.float64) >>> z = torch.polar(abs, angle) >>> z tensor([(0.0000+1.0000j), (-1.4142-1.4142j)], dtype=torch.complex128)
https://pytorch.org/docs/stable/generated/torch.polar.html
pytorch docs
torch.foreach_sqrt torch.foreach_sqrt(self: List[Tensor]) -> None Apply "torch.sqrt()" to each Tensor of the input list.
https://pytorch.org/docs/stable/generated/torch._foreach_sqrt_.html
pytorch docs
torch.numel torch.numel(input) -> int Returns the total number of elements in the "input" tensor. Parameters: input (Tensor) -- the input tensor. Example: >>> a = torch.randn(1, 2, 3, 4, 5) >>> torch.numel(a) 120 >>> a = torch.zeros(4,4) >>> torch.numel(a) 16
https://pytorch.org/docs/stable/generated/torch.numel.html
pytorch docs
torch.Tensor.igammac Tensor.igammac(other) -> Tensor See "torch.igammac()"
https://pytorch.org/docs/stable/generated/torch.Tensor.igammac.html
pytorch docs
torch.lt torch.lt(input, other, *, out=None) -> Tensor Computes \text{input} < \text{other} element-wise. The second argument can be a number or a tensor whose shape is broadcastable with the first argument. Parameters: * input (Tensor) -- the tensor to compare * **other** (*Tensor** or **float*) -- the tensor or value to compare Keyword Arguments: out (Tensor, optional) -- the output tensor. Returns: A boolean tensor that is True where "input" is less than "other" and False elsewhere Example: >>> torch.lt(torch.tensor([[1, 2], [3, 4]]), torch.tensor([[1, 1], [4, 4]])) tensor([[False, False], [True, False]])
https://pytorch.org/docs/stable/generated/torch.lt.html
pytorch docs
torch.triu_indices torch.triu_indices(row, col, offset=0, *, dtype=torch.long, device='cpu', layout=torch.strided) -> Tensor Returns the indices of the upper triangular part of a "row" by "col" matrix in a 2-by-N Tensor, where the first row contains row coordinates of all indices and the second row contains column coordinates. Indices are ordered based on rows and then columns. The upper triangular part of the matrix is defined as the elements on and above the diagonal. The argument "offset" controls which diagonal to consider. If "offset" = 0, all elements on and above the main diagonal are retained. A positive value excludes just as many diagonals above the main diagonal, and similarly a negative value includes just as many diagonals below the main diagonal. The main diagonal are the set of indices \lbrace (i, i) \rbrace for i \in [0, \min{d_{1}, d_{2}} - 1] where d_{1}, d_{2} are the dimensions of the matrix. Note:
https://pytorch.org/docs/stable/generated/torch.triu_indices.html
pytorch docs
Note: When running on CUDA, "row * col" must be less than 2^{59} to prevent overflow during calculation. Parameters: * row ("int") -- number of rows in the 2-D matrix. * **col** ("int") -- number of columns in the 2-D matrix. * **offset** ("int") -- diagonal offset from the main diagonal. Default: if not provided, 0. Keyword Arguments: * dtype ("torch.dtype", optional) -- the desired data type of returned tensor. Default: if "None", "torch.long". * **device** ("torch.device", optional) -- the desired device of returned tensor. Default: if "None", uses the current device for the default tensor type (see "torch.set_default_tensor_type()"). "device" will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types. * **layout** ("torch.layout", optional) -- currently only support "torch.strided". Example: >>> a = torch.triu_indices(3, 3)
https://pytorch.org/docs/stable/generated/torch.triu_indices.html
pytorch docs
a = torch.triu_indices(3, 3) >>> a tensor([[0, 0, 0, 1, 1, 2], [0, 1, 2, 1, 2, 2]]) >>> a = torch.triu_indices(4, 3, -1) >>> a tensor([[0, 0, 0, 1, 1, 1, 2, 2, 3], [0, 1, 2, 0, 1, 2, 1, 2, 2]]) >>> a = torch.triu_indices(4, 3, 1) >>> a tensor([[0, 0, 1], [1, 2, 2]])
https://pytorch.org/docs/stable/generated/torch.triu_indices.html
pytorch docs
LazyInstanceNorm1d class torch.nn.LazyInstanceNorm1d(eps=1e-05, momentum=0.1, affine=True, track_running_stats=True, device=None, dtype=None) A "torch.nn.InstanceNorm1d" module with lazy initialization of the "num_features" argument of the "InstanceNorm1d" that is inferred from the "input.size(1)". The attributes that will be lazily initialized are weight, bias, running_mean and running_var. Check the "torch.nn.modules.lazy.LazyModuleMixin" for further documentation on lazy modules and their limitations. Parameters: * num_features -- C from an expected input of size (N, C, L) or (C, L) * **eps** (*float*) -- a value added to the denominator for numerical stability. Default: 1e-5 * **momentum** (*float*) -- the value used for the running_mean and running_var computation. Default: 0.1 * **affine** (*bool*) -- a boolean value that when set to "True", this module has learnable affine parameters,
https://pytorch.org/docs/stable/generated/torch.nn.LazyInstanceNorm1d.html
pytorch docs
initialized the same way as done for batch normalization. Default: "False". * **track_running_stats** (*bool*) -- a boolean value that when set to "True", this module tracks the running mean and variance, and when set to "False", this module does not track such statistics and always uses batch statistics in both training and eval modes. Default: "False" Shape: * Input: (N, C, L) or (C, L) * Output: (N, C, L) or (C, L) (same shape as input) cls_to_become alias of "InstanceNorm1d"
https://pytorch.org/docs/stable/generated/torch.nn.LazyInstanceNorm1d.html
pytorch docs
enable_observer class torch.quantization.fake_quantize.enable_observer(mod) Enable observation for this module, if applicable. Example usage: # model is any PyTorch model model.apply(torch.ao.quantization.enable_observer)
https://pytorch.org/docs/stable/generated/torch.quantization.fake_quantize.enable_observer.html
pytorch docs
torch.fake_quantize_per_channel_affine torch.fake_quantize_per_channel_affine(input, scale, zero_point, quant_min, quant_max) -> Tensor Returns a new tensor with the data in "input" fake quantized per channel using "scale", "zero_point", "quant_min" and "quant_max", across the channel specified by "axis". \text{output} = min( \text{quant\_max}, max( \text{quant\_min}, \text{std::nearby\_int}(\text{input} / \text{scale}) + \text{zero\_point} ) ) Parameters: * input (Tensor) -- the input value(s), in "torch.float32" * **scale** (*Tensor*) -- quantization scale, per channel in "torch.float32" * **zero_point** (*Tensor*) -- quantization zero_point, per channel in "torch.int32" or "torch.half" or "torch.float32" * **axis** (*int32*) -- channel axis * **quant_min** (*int64*) -- lower bound of the quantized domain
https://pytorch.org/docs/stable/generated/torch.fake_quantize_per_channel_affine.html
pytorch docs
quant_max (int64) -- upper bound of the quantized domain Returns: A newly fake_quantized per channel "torch.float32" tensor Return type: Tensor Example: >>> x = torch.randn(2, 2, 2) >>> x tensor([[[-0.2525, -0.0466], [ 0.3491, -0.2168]], [[-0.5906, 1.6258], [ 0.6444, -0.0542]]]) >>> scales = (torch.randn(2) + 1) * 0.05 >>> scales tensor([0.0475, 0.0486]) >>> zero_points = torch.zeros(2).to(torch.int32) >>> zero_points tensor([0, 0]) >>> torch.fake_quantize_per_channel_affine(x, scales, zero_points, 1, 0, 255) tensor([[[0.0000, 0.0000], [0.3405, 0.0000]], [[0.0000, 1.6134], [0.6323, 0.0000]]])
https://pytorch.org/docs/stable/generated/torch.fake_quantize_per_channel_affine.html
pytorch docs
torch.Tensor.subtract Tensor.subtract(other, *, alpha=1) -> Tensor See "torch.subtract()".
https://pytorch.org/docs/stable/generated/torch.Tensor.subtract.html
pytorch docs
torch.nn.functional.instance_norm torch.nn.functional.instance_norm(input, running_mean=None, running_var=None, weight=None, bias=None, use_input_stats=True, momentum=0.1, eps=1e-05) Applies Instance Normalization for each channel in each data sample in a batch. See "InstanceNorm1d", "InstanceNorm2d", "InstanceNorm3d" for details. Return type: Tensor
https://pytorch.org/docs/stable/generated/torch.nn.functional.instance_norm.html
pytorch docs
torch.Tensor.random_ Tensor.random_(from=0, to=None, *, generator=None) -> Tensor Fills "self" tensor with numbers sampled from the discrete uniform distribution over "[from, to - 1]". If not specified, the values are usually only bounded by "self" tensor's data type. However, for floating point types, if unspecified, range will be "[0, 2^mantissa]" to ensure that every value is representable. For example, torch.tensor(1, dtype=torch.double).random_() will be uniform in "[0, 2^53]".
https://pytorch.org/docs/stable/generated/torch.Tensor.random_.html
pytorch docs
per_channel_dynamic_qconfig torch.quantization.qconfig.per_channel_dynamic_qconfig alias of QConfig(activation=functools.partial(, dtype=torch.quint8, quant_min=0, quant_max=255, is_dynamic=True){}, weight=functools.partial(, dtype=torch.qint8, qscheme=torch.per_channel_symmetric){})
https://pytorch.org/docs/stable/generated/torch.quantization.qconfig.per_channel_dynamic_qconfig.html
pytorch docs
torch.fft.ihfftn torch.fft.ihfftn(input, s=None, dim=None, norm=None, *, out=None) -> Tensor Computes the N-dimensional inverse discrete Fourier transform of real "input". "input" must be a real-valued signal, interpreted in the Fourier domain. The n-dimensional IFFT of a real signal is Hermitian- symmetric, "X[i, j, ...] = conj(X[-i, -j, ...])". "ihfftn()" represents this in the one-sided form where only the positive frequencies below the Nyquist frequency are included in the last signal dimension. To compute the full output, use "ifftn()". Note: Supports torch.half on CUDA with GPU Architecture SM53 or greater. However it only supports powers of 2 signal length in every transformed dimensions. Parameters: * input (Tensor) -- the input tensor * **s** (*Tuple**[**int**]**, **optional*) -- Signal size in the transformed dimensions. If given, each dimension "dim[i]" will
https://pytorch.org/docs/stable/generated/torch.fft.ihfftn.html
pytorch docs
either be zero-padded or trimmed to the length "s[i]" before computing the Hermitian IFFT. If a length "-1" is specified, no padding is done in that dimension. Default: "s = [input.size(d) for d in dim]" * **dim** (*Tuple**[**int**]**, **optional*) -- Dimensions to be transformed. Default: all dimensions, or the last "len(s)" dimensions if "s" is given. * **norm** (*str**, **optional*) -- Normalization mode. For the backward transform ("ihfftn()"), these correspond to: * ""forward"" - no normalization * ""backward"" - normalize by "1/n" * ""ortho"" - normalize by "1/sqrt(n)" (making the Hermitian IFFT orthonormal) Where "n = prod(s)" is the logical IFFT size. Calling the forward transform ("hfftn()") with the same normalization mode will apply an overall normalization of "1/n" between the two transforms. This is required to make "ihfftn()" the exact
https://pytorch.org/docs/stable/generated/torch.fft.ihfftn.html
pytorch docs
inverse. Default is ""backward"" (normalize by "1/n"). Keyword Arguments: out (Tensor, optional) -- the output tensor. -[ Example ]- T = torch.rand(10, 10) ihfftn = torch.fft.ihfftn(T) ihfftn.size() torch.Size([10, 6]) Compared against the full output from "ifftn()", we have all elements up to the Nyquist frequency. ifftn = torch.fft.ifftn(t) torch.allclose(ifftn[..., :6], ihfftn) True The discrete Fourier transform is separable, so "ihfftn()" here is equivalent to a combination of "ihfft()" and "ifft()": two_iffts = torch.fft.ifft(torch.fft.ihfft(t, dim=1), dim=0) torch.allclose(ihfftn, two_iffts) True
https://pytorch.org/docs/stable/generated/torch.fft.ihfftn.html
pytorch docs
torch.isnan torch.isnan(input) -> Tensor Returns a new tensor with boolean elements representing if each element of "input" is NaN or not. Complex values are considered NaN when either their real and/or imaginary part is NaN. Parameters: input (Tensor) -- the input tensor. Returns: A boolean tensor that is True where "input" is NaN and False elsewhere Example: >>> torch.isnan(torch.tensor([1, float('nan'), 2])) tensor([False, True, False])
https://pytorch.org/docs/stable/generated/torch.isnan.html
pytorch docs
torch.linalg.eigvals torch.linalg.eigvals(A, *, out=None) -> Tensor Computes the eigenvalues of a square matrix. Letting \mathbb{K} be \mathbb{R} or \mathbb{C}, the eigenvalues of a square matrix A \in \mathbb{K}^{n \times n} are defined as the roots (counted with multiplicity) of the polynomial p of degree n given by p(\lambda) = \operatorname{det}(A - \lambda \mathrm{I}_n)\mathrlap{\qquad \lambda \in \mathbb{C}} where \mathrm{I}_n is the n-dimensional identity matrix. Supports input of float, double, cfloat and cdouble dtypes. Also supports batches of matrices, and if "A" is a batch of matrices then the output has the same batch dimensions. Note: The eigenvalues of a real matrix may be complex, as the roots of a real polynomial may be complex.The eigenvalues of a matrix are always well-defined, even when the matrix is not diagonalizable. Note:
https://pytorch.org/docs/stable/generated/torch.linalg.eigvals.html
pytorch docs
Note: When inputs are on a CUDA device, this function synchronizes that device with the CPU. See also: "torch.linalg.eig()" computes the full eigenvalue decomposition. Parameters: A (Tensor) -- tensor of shape (, n, n)* where *** is zero or more batch dimensions. Keyword Arguments: out (Tensor, optional) -- output tensor. Ignored if None. Default: None. Returns: A complex-valued tensor containing the eigenvalues even when "A" is real. Examples: >>> A = torch.randn(2, 2, dtype=torch.complex128) >>> L = torch.linalg.eigvals(A) >>> L tensor([ 1.1226+0.5738j, -0.7537-0.1286j], dtype=torch.complex128) >>> torch.dist(L, torch.linalg.eig(A).eigenvalues) tensor(2.4576e-07)
https://pytorch.org/docs/stable/generated/torch.linalg.eigvals.html
pytorch docs
disable_fake_quant class torch.quantization.fake_quantize.disable_fake_quant(mod) Disable fake quantization for this module, if applicable. Example usage: # model is any PyTorch model model.apply(torch.ao.quantization.disable_fake_quant)
https://pytorch.org/docs/stable/generated/torch.quantization.fake_quantize.disable_fake_quant.html
pytorch docs
torch.Tensor.clip_ Tensor.clip_(min=None, max=None) -> Tensor Alias for "clamp_()".
https://pytorch.org/docs/stable/generated/torch.Tensor.clip_.html
pytorch docs
torch.amin torch.amin(input, dim, keepdim=False, *, out=None) -> Tensor Returns the minimum value of each slice of the "input" tensor in the given dimension(s) "dim". Note: The difference between "max"/"min" and "amax"/"amin" is: * "amax"/"amin" supports reducing on multiple dimensions, * "amax"/"amin" does not return indices, * "amax"/"amin" evenly distributes gradient between equal values, while "max(dim)"/"min(dim)" propagates gradient only to a single index in the source tensor. If "keepdim" is "True", the output tensor is of the same size as "input" except in the dimension(s) "dim" where it is of size 1. Otherwise, "dim" is squeezed (see "torch.squeeze()"), resulting in the output tensor having 1 (or "len(dim)") fewer dimension(s). Parameters: * input (Tensor) -- the input tensor. * **dim** (*int** or **tuple of ints*) -- the dimension or dimensions to reduce.
https://pytorch.org/docs/stable/generated/torch.amin.html
pytorch docs
dimensions to reduce. * **keepdim** (*bool*) -- whether the output tensor has "dim" retained or not. Keyword Arguments: out (Tensor, optional) -- the output tensor. Example: >>> a = torch.randn(4, 4) >>> a tensor([[ 0.6451, -0.4866, 0.2987, -1.3312], [-0.5744, 1.2980, 1.8397, -0.2713], [ 0.9128, 0.9214, -1.7268, -0.2995], [ 0.9023, 0.4853, 0.9075, -1.6165]]) >>> torch.amin(a, 1) tensor([-1.3312, -0.5744, -1.7268, -1.6165])
https://pytorch.org/docs/stable/generated/torch.amin.html
pytorch docs
torch.ones_like torch.ones_like(input, *, dtype=None, layout=None, device=None, requires_grad=False, memory_format=torch.preserve_format) -> Tensor Returns a tensor filled with the scalar value 1, with the same size as "input". "torch.ones_like(input)" is equivalent to "torch.ones(input.size(), dtype=input.dtype, layout=input.layout, device=input.device)". Warning: As of 0.4, this function does not support an "out" keyword. As an alternative, the old "torch.ones_like(input, out=output)" is equivalent to "torch.ones(input.size(), out=output)". Parameters: input (Tensor) -- the size of "input" will determine size of the output tensor. Keyword Arguments: * dtype ("torch.dtype", optional) -- the desired data type of returned Tensor. Default: if "None", defaults to the dtype of "input". * **layout** ("torch.layout", optional) -- the desired layout of
https://pytorch.org/docs/stable/generated/torch.ones_like.html
pytorch docs
returned tensor. Default: if "None", defaults to the layout of "input". * **device** ("torch.device", optional) -- the desired device of returned tensor. Default: if "None", defaults to the device of "input". * **requires_grad** (*bool**, **optional*) -- If autograd should record operations on the returned tensor. Default: "False". * **memory_format** ("torch.memory_format", optional) -- the desired memory format of returned Tensor. Default: "torch.preserve_format". Example: >>> input = torch.empty(2, 3) >>> torch.ones_like(input) tensor([[ 1., 1., 1.], [ 1., 1., 1.]])
https://pytorch.org/docs/stable/generated/torch.ones_like.html
pytorch docs
torch.sub torch.sub(input, other, *, alpha=1, out=None) -> Tensor Subtracts "other", scaled by "alpha", from "input". \text{{out}}_i = \text{{input}}_i - \text{{alpha}} \times \text{{other}}_i Supports broadcasting to a common shape, type promotion, and integer, float, and complex inputs. Parameters: * input (Tensor) -- the input tensor. * **other** (*Tensor** or **Number*) -- the tensor or number to subtract from "input". Keyword Arguments: * alpha (Number) -- the multiplier for "other". * **out** (*Tensor**, **optional*) -- the output tensor. Example: >>> a = torch.tensor((1, 2)) >>> b = torch.tensor((0, 1)) >>> torch.sub(a, b, alpha=2) tensor([1, 0])
https://pytorch.org/docs/stable/generated/torch.sub.html
pytorch docs
QConfigMapping class torch.ao.quantization.qconfig_mapping.QConfigMapping Mapping from model ops to "torch.ao.quantization.QConfig" s. The user can specify QConfigs using the following methods (in increasing match priority): "set_global" : sets the global (default) QConfig "set_object_type" : sets the QConfig for a given module type, function, or method name "set_module_name_regex" : sets the QConfig for modules matching the given regex string "set_module_name" : sets the QConfig for modules matching the given module name "set_module_name_object_type_order" : sets the QConfig for modules matching a combination of the given module name, object type, and the index at which the module appears Example usage: qconfig_mapping = QConfigMapping() .set_global(global_qconfig) .set_object_type(torch.nn.Linear, qconfig1) .set_object_type(torch.nn.ReLU, qconfig1)
https://pytorch.org/docs/stable/generated/torch.ao.quantization.qconfig_mapping.QConfigMapping.html
pytorch docs
.set_module_name_regex("foo.bar.conv[0-9]+", qconfig1) .set_module_name_regex("foo.*", qconfig2) .set_module_name("module1", qconfig1) .set_module_name("module2", qconfig2) .set_module_name_object_type_order("foo.bar", torch.nn.functional.linear, 0, qconfig3) classmethod from_dict(qconfig_dict) Create a "QConfigMapping" from a dictionary with the following keys (all optional): "" (for global QConfig) "object_type" "module_name_regex" "module_name" "module_name_object_type_order" The values of this dictionary are expected to be lists of tuples. Return type: *QConfigMapping* set_global(global_qconfig) Set the global (default) QConfig. Return type: *QConfigMapping* set_module_name(module_name, qconfig) Set the QConfig for modules matching the given module name. If
https://pytorch.org/docs/stable/generated/torch.ao.quantization.qconfig_mapping.QConfigMapping.html
pytorch docs
the QConfig for an existing module name was already set, the new QConfig will override the old one. Return type: *QConfigMapping* set_module_name_object_type_order(module_name, object_type, index, qconfig) Set the QConfig for modules matching a combination of the given module name, object type, and the index at which the module appears. If the QConfig for an existing (module name, object type, index) was already set, the new QConfig will override the old one. Return type: *QConfigMapping* set_module_name_regex(module_name_regex, qconfig) Set the QConfig for modules matching the given regex string. Regexes will be matched in the order in which they are registered through this method. Thus, the caller should register more specific patterns first, e.g.: qconfig_mapping = QConfigMapping() .set_module_name_regex("foo.*bar.*conv[0-9]+", qconfig1)
https://pytorch.org/docs/stable/generated/torch.ao.quantization.qconfig_mapping.QConfigMapping.html
pytorch docs
.set_module_name_regex("foo.bar.", qconfig2) .set_module_name_regex("foo.*", qconfig3) In this example, "foo.bar.conv0" would match qconfig1, "foo.bar.linear" would match qconfig2, and "foo.baz.relu" would match qconfig3. If the QConfig for an existing module name regex was already set, the new QConfig will override the old one while preserving the order in which the regexes were originally registered. Return type: *QConfigMapping* set_object_type(object_type, qconfig) Set the QConfig for a given module type, function, or method name. If the QConfig for an existing object type was already set, the new QConfig will override the old one. Return type: *QConfigMapping* to_dict() Convert this "QConfigMapping" to a dictionary with the following keys: "" (for global QConfig) "object_type" "module_name_regex" "module_name"
https://pytorch.org/docs/stable/generated/torch.ao.quantization.qconfig_mapping.QConfigMapping.html
pytorch docs
"module_name" "module_name_object_type_order" The values of this dictionary are lists of tuples. Return type: *Dict*[str, *Any*]
https://pytorch.org/docs/stable/generated/torch.ao.quantization.qconfig_mapping.QConfigMapping.html
pytorch docs
torch.var torch.var(input, dim=None, *, correction=1, keepdim=False, out=None) -> Tensor Calculates the variance over the dimensions specified by "dim". "dim" can be a single dimension, list of dimensions, or "None" to reduce over all dimensions. The variance (\sigma^2) is calculated as \sigma^2 = \frac{1}{N - \delta N}\sum_{i=0}^{N-1}(x_i-\bar{x})^2 where x is the sample set of elements, \bar{x} is the sample mean, N is the number of samples and \delta N is the "correction". If "keepdim" is "True", the output tensor is of the same size as "input" except in the dimension(s) "dim" where it is of size 1. Otherwise, "dim" is squeezed (see "torch.squeeze()"), resulting in the output tensor having 1 (or "len(dim)") fewer dimension(s). Parameters: * input (Tensor) -- the input tensor. * **dim** (*int** or **tuple of ints**, **optional*) -- the dimension or dimensions to reduce. If "None", all dimensions are reduced.
https://pytorch.org/docs/stable/generated/torch.var.html
pytorch docs
are reduced. Keyword Arguments: * correction (int) -- difference between the sample size and sample degrees of freedom. Defaults to Bessel's correction, "correction=1". Changed in version 2.0: Previously this argument was called "unbiased" and was a boolean with "True" corresponding to "correction=1" and "False" being "correction=0". * **keepdim** (*bool*) -- whether the output tensor has "dim" retained or not. * **out** (*Tensor**, **optional*) -- the output tensor. -[ Example ]- a = torch.tensor( ... [[ 0.2035, 1.2959, 1.8101, -0.4644], ... [ 1.5027, -0.3270, 0.5905, 0.6538], ... [-1.5745, 1.3330, -0.5596, -0.6548], ... [ 0.1264, -0.5080, 1.6420, 0.1992]]) torch.var(a, dim=1, keepdim=True) tensor([[1.0631], [0.5590], [1.4893], [0.8258]])
https://pytorch.org/docs/stable/generated/torch.var.html
pytorch docs
torch.multinomial torch.multinomial(input, num_samples, replacement=False, *, generator=None, out=None) -> LongTensor Returns a tensor where each row contains "num_samples" indices sampled from the multinomial probability distribution located in the corresponding row of tensor "input". Note: The rows of "input" do not need to sum to one (in which case we use the values as weights), but must be non-negative, finite and have a non-zero sum. Indices are ordered from left to right according to when each was sampled (first samples are placed in first column). If "input" is a vector, "out" is a vector of size "num_samples". If "input" is a matrix with m rows, "out" is an matrix of shape (m \times \text{num_samples}). If replacement is "True", samples are drawn with replacement. If not, they are drawn without replacement, which means that when a sample index is drawn for a row, it cannot be drawn again for that row. Note:
https://pytorch.org/docs/stable/generated/torch.multinomial.html
pytorch docs
row. Note: When drawn without replacement, "num_samples" must be lower than number of non-zero elements in "input" (or the min number of non- zero elements in each row of "input" if it is a matrix). Parameters: * input (Tensor) -- the input tensor containing probabilities * **num_samples** (*int*) -- number of samples to draw * **replacement** (*bool**, **optional*) -- whether to draw with replacement or not Keyword Arguments: * generator ("torch.Generator", optional) -- a pseudorandom number generator for sampling * **out** (*Tensor**, **optional*) -- the output tensor. Example: >>> weights = torch.tensor([0, 10, 3, 0], dtype=torch.float) # create a tensor of weights >>> torch.multinomial(weights, 2) tensor([1, 2]) >>> torch.multinomial(weights, 4) # ERROR! RuntimeError: invalid argument 2: invalid multinomial distribution (with replacement=False,
https://pytorch.org/docs/stable/generated/torch.multinomial.html
pytorch docs
not enough non-negative category to sample) at ../aten/src/TH/generic/THTensorRandom.cpp:320 >>> torch.multinomial(weights, 4, replacement=True) tensor([ 2, 1, 1, 1])
https://pytorch.org/docs/stable/generated/torch.multinomial.html
pytorch docs
torch.histogramdd torch.histogramdd(input, bins, *, range=None, weight=None, density=False, out=None) -> (Tensor, Tensor[]) Computes a multi-dimensional histogram of the values in a tensor. Interprets the elements of an input tensor whose innermost dimension has size N as a collection of N-dimensional points. Maps each of the points into a set of N-dimensional bins and returns the number of points (or total weight) in each bin. "input" must be a tensor with at least 2 dimensions. If input has shape (M, N), each of its M rows defines a point in N-dimensional space. If input has three or more dimensions, all but the last dimension are flattened. Each dimension is independently associated with its own strictly increasing sequence of bin edges. Bin edges may be specified explicitly by passing a sequence of 1D tensors. Alternatively, bin edges may be constructed automatically by passing a sequence of
https://pytorch.org/docs/stable/generated/torch.histogramdd.html
pytorch docs
integers specifying the number of equal-width bins in each dimension. For each N-dimensional point in input: * Each of its coordinates is binned independently among the bin edges corresponding to its dimension * Binning results are combined to identify the N-dimensional bin (if any) into which the point falls * If the point falls into a bin, the bin's count (or total weight) is incremented * Points which do not fall into any bin do not contribute to the output "bins" can be a sequence of N 1D tensors, a sequence of N ints, or a single int. If "bins" is a sequence of N 1D tensors, it explicitly specifies the N sequences of bin edges. Each 1D tensor should contain a strictly increasing sequence with at least one element. A sequence of K bin edges defines K-1 bins, explicitly specifying the left and right edges of all bins. Every bin is exclusive of its left edge.
https://pytorch.org/docs/stable/generated/torch.histogramdd.html
pytorch docs
Only the rightmost bin is inclusive of its right edge. If "bins" is a sequence of N ints, it specifies the number of equal-width bins in each dimension. By default, the leftmost and rightmost bin edges in each dimension are determined by the minimum and maximum elements of the input tensor in the corresponding dimension. The "range" argument can be provided to manually specify the leftmost and rightmost bin edges in each dimension. If "bins" is an int, it specifies the number of equal-width bins for all dimensions. Note: See also "torch.histogram()", which specifically computes 1D histograms. While "torch.histogramdd()" infers the dimensionality of its bins and binned values from the shape of "input", "torch.histogram()" accepts and flattens "input" of any shape. Parameters: * input (Tensor) -- the input tensor. * **bins** -- Tensor[], int[], or int. If Tensor[], defines the
https://pytorch.org/docs/stable/generated/torch.histogramdd.html
pytorch docs
sequences of bin edges. If int[], defines the number of equal- width bins in each dimension. If int, defines the number of equal-width bins for all dimensions. Keyword Arguments: * range (sequence of python:float) -- Defines the leftmost and rightmost bin edges in each dimension. * **weight** (*Tensor*) -- By default, each value in the input has weight 1. If a weight tensor is passed, each N-dimensional coordinate in input contributes its associated weight towards its bin's result. The weight tensor should have the same shape as the "input" tensor excluding its innermost dimension N. * **density** (*bool*) -- If False (default), the result will contain the count (or total weight) in each bin. If True, each count (weight) is divided by the total count (total weight), then divided by the volume of its associated bin. Returns: N-dimensional Tensor containing the values of the histogram.
https://pytorch.org/docs/stable/generated/torch.histogramdd.html
pytorch docs
bin_edges(Tensor[]): sequence of N 1D Tensors containing the bin edges. Return type: hist (Tensor) Example:: >>> torch.histogramdd(torch.tensor([[0., 1.], [1., 0.], [2., 0.], [2., 2.]]), bins=[3, 3], ... weight=torch.tensor([1., 2., 4., 8.])) torch.return_types.histogramdd( hist=tensor([[0., 1., 0.], [2., 0., 0.], [4., 0., 8.]]), bin_edges=(tensor([0.0000, 0.6667, 1.3333, 2.0000]), tensor([0.0000, 0.6667, 1.3333, 2.0000]))) >>> torch.histogramdd(torch.tensor([[0., 0.], [1., 1.], [2., 2.]]), bins=[2, 2], ... range=[0., 1., 0., 1.], density=True) torch.return_types.histogramdd( hist=tensor([[2., 0.], [0., 2.]]), bin_edges=(tensor([0.0000, 0.5000, 1.0000]), tensor([0.0000, 0.5000, 1.0000])))
https://pytorch.org/docs/stable/generated/torch.histogramdd.html
pytorch docs
torch.Tensor.logaddexp Tensor.logaddexp(other) -> Tensor See "torch.logaddexp()"
https://pytorch.org/docs/stable/generated/torch.Tensor.logaddexp.html
pytorch docs
torch.row_stack torch.row_stack(tensors, *, out=None) -> Tensor Alias of "torch.vstack()".
https://pytorch.org/docs/stable/generated/torch.row_stack.html
pytorch docs
torch.Tensor.is_conj Tensor.is_conj() -> bool Returns True if the conjugate bit of "self" is set to true.
https://pytorch.org/docs/stable/generated/torch.Tensor.is_conj.html
pytorch docs
torch.empty torch.empty(size, , out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False, pin_memory=False, memory_format=torch.contiguous_format) -> Tensor Returns a tensor filled with uninitialized data. The shape of the tensor is defined by the variable argument "size". Parameters: size (int...) -- a sequence of integers defining the shape of the output tensor. Can be a variable number of arguments or a collection like a list or tuple. Keyword Arguments: * out (Tensor, optional) -- the output tensor. * **dtype** ("torch.dtype", optional) -- the desired data type of returned tensor. Default: if "None", uses a global default (see "torch.set_default_tensor_type()"). * **layout** ("torch.layout", optional) -- the desired layout of returned Tensor. Default: "torch.strided". * **device** ("torch.device", optional) -- the desired device of
https://pytorch.org/docs/stable/generated/torch.empty.html
pytorch docs
returned tensor. Default: if "None", uses the current device for the default tensor type (see "torch.set_default_tensor_type()"). "device" will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types. * **requires_grad** (*bool**, **optional*) -- If autograd should record operations on the returned tensor. Default: "False". * **pin_memory** (*bool**, **optional*) -- If set, returned tensor would be allocated in the pinned memory. Works only for CPU tensors. Default: "False". * **memory_format** ("torch.memory_format", optional) -- the desired memory format of returned Tensor. Default: "torch.contiguous_format". Example: >>> torch.empty((2,3), dtype=torch.int64) tensor([[ 9.4064e+13, 2.8000e+01, 9.3493e+13], [ 7.5751e+18, 7.1428e+18, 7.5955e+18]])
https://pytorch.org/docs/stable/generated/torch.empty.html
pytorch docs
torch.nn.functional.elu torch.nn.functional.elu(input, alpha=1.0, inplace=False) Applies the Exponential Linear Unit (ELU) function element-wise. See "ELU" for more details. Return type: Tensor
https://pytorch.org/docs/stable/generated/torch.nn.functional.elu.html
pytorch docs
ConvTranspose2d class torch.ao.nn.quantized.ConvTranspose2d(in_channels, out_channels, kernel_size, stride=1, padding=0, output_padding=0, groups=1, bias=True, dilation=1, padding_mode='zeros', device=None, dtype=None) Applies a 2D transposed convolution operator over an input image composed of several input planes. For details on input arguments, parameters, and implementation see "ConvTranspose2d". For special notes, please, see "Conv2d" Variables: * weight (Tensor) -- packed tensor derived from the learnable weight parameter. * **scale** (*Tensor*) -- scalar for the output scale * **zero_point** (*Tensor*) -- scalar for the output zero point See "ConvTranspose2d" for other attributes. Examples: >>> # QNNPACK or FBGEMM as backend >>> torch.backends.quantized.engine = 'qnnpack' >>> # With square kernels and equal stride >>> import torch.nn.quantized as nnq
https://pytorch.org/docs/stable/generated/torch.ao.nn.quantized.ConvTranspose2d.html
pytorch docs
import torch.nn.quantized as nnq >>> m = nnq.ConvTranspose2d(16, 33, 3, stride=2) >>> # non-square kernels and unequal stride and with padding >>> m = nnq.ConvTranspose2d(16, 33, (3, 5), stride=(2, 1), padding=(4, 2)) >>> input = torch.randn(20, 16, 50, 100) >>> q_input = torch.quantize_per_tensor(input, scale=1.0, zero_point=0, dtype=torch.quint8) >>> output = m(q_input) >>> # exact output size can be also specified as an argument >>> input = torch.randn(1, 16, 12, 12) >>> q_input = torch.quantize_per_tensor(input, scale=1.0, zero_point=0, dtype=torch.quint8) >>> downsample = nnq.Conv2d(16, 16, 3, stride=2, padding=1) >>> upsample = nnq.ConvTranspose2d(16, 16, 3, stride=2, padding=1) >>> h = downsample(q_input) >>> h.size() torch.Size([1, 16, 6, 6]) >>> output = upsample(h, output_size=input.size()) >>> output.size() torch.Size([1, 16, 12, 12])
https://pytorch.org/docs/stable/generated/torch.ao.nn.quantized.ConvTranspose2d.html
pytorch docs
torch.vdot torch.vdot(input, other, *, out=None) -> Tensor Computes the dot product of two 1D vectors along a dimension. In symbols, this function computes \sum_{i=1}^n \overline{x_i}y_i. where \overline{x_i} denotes the conjugate for complex vectors, and it is the identity for real vectors. Note: Unlike NumPy's vdot, torch.vdot intentionally only supports computing the dot product of two 1D tensors with the same number of elements. See also: "torch.linalg.vecdot()" computes the dot product of two batches of vectors along a dimension. Parameters: * input (Tensor) -- first tensor in the dot product, must be 1D. Its conjugate is used if it's complex. * **other** (*Tensor*) -- second tensor in the dot product, must be 1D. Keyword args: Note: out (Tensor, optional): the output tensor. Example: >>> torch.vdot(torch.tensor([2, 3]), torch.tensor([2, 1])) tensor(7)
https://pytorch.org/docs/stable/generated/torch.vdot.html
pytorch docs
tensor(7) >>> a = torch.tensor((1 +2j, 3 - 1j)) >>> b = torch.tensor((2 +1j, 4 - 0j)) >>> torch.vdot(a, b) tensor([16.+1.j]) >>> torch.vdot(b, a) tensor([16.-1.j])
https://pytorch.org/docs/stable/generated/torch.vdot.html
pytorch docs
torch.nn.utils.vector_to_parameters torch.nn.utils.vector_to_parameters(vec, parameters) Convert one vector to the parameters Parameters: * vec (Tensor) -- a single vector represents the parameters of a model. * **parameters** (*Iterable**[**Tensor**]*) -- an iterator of Tensors that are the parameters of a model.
https://pytorch.org/docs/stable/generated/torch.nn.utils.vector_to_parameters.html
pytorch docs
torch.svd torch.svd(input, some=True, compute_uv=True, *, out=None) Computes the singular value decomposition of either a matrix or batch of matrices "input". The singular value decomposition is represented as a namedtuple (U, S, V), such that "input" = U \text{diag}(S) V^{\text{H}}. where V^{\text{H}} is the transpose of V for real inputs, and the conjugate transpose of V for complex inputs. If "input" is a batch of matrices, then U, S, and V are also batched with the same batch dimensions as "input". If "some" is True (default), the method returns the reduced singular value decomposition. In this case, if the last two dimensions of "input" are m and n, then the returned U and V matrices will contain only min(n, m) orthonormal columns. If "compute_uv" is False, the returned U and V will be zero- filled matrices of shape (m, m) and (n, n) respectively, and
https://pytorch.org/docs/stable/generated/torch.svd.html
pytorch docs
the same device as "input". The argument "some" has no effect when "compute_uv" is False. Supports "input" of float, double, cfloat and cdouble data types. The dtypes of U and V are the same as "input"'s. S will always be real-valued, even if "input" is complex. Warning: "torch.svd()" is deprecated in favor of "torch.linalg.svd()" and will be removed in a future PyTorch release."U, S, V = torch.svd(A, some=some, compute_uv=True)" (default) should be replaced with U, S, Vh = torch.linalg.svd(A, full_matrices=not some) V = Vh.mH "_, S, _ = torch.svd(A, some=some, compute_uv=False)" should be replaced with S = torch.linalg.svdvals(A) Note: Differences with "torch.linalg.svd()": * "some" is the opposite of "torch.linalg.svd()"'s "full_matrices". Note that default value for both is *True*, so the default behavior is effectively the opposite.
https://pytorch.org/docs/stable/generated/torch.svd.html
pytorch docs
"torch.svd()" returns V, whereas "torch.linalg.svd()" returns Vh, that is, V^{\text{H}}. If "compute_uv" is False, "torch.svd()" returns zero-filled tensors for U and Vh, whereas "torch.linalg.svd()" returns empty tensors. Note: The singular values are returned in descending order. If "input" is a batch of matrices, then the singular values of each matrix in the batch are returned in descending order. Note: The *S* tensor can only be used to compute gradients if "compute_uv" is *True*. Note: When "some" is *False*, the gradients on *U[..., :, min(m, n):]* and *V[..., :, min(m, n):]* will be ignored in the backward pass, as those vectors can be arbitrary bases of the corresponding subspaces. Note: The implementation of "torch.linalg.svd()" on CPU uses LAPACK's routine *?gesdd* (a divide-and-conquer algorithm) instead of *?gesvd* for speed. Analogously, on GPU, it uses cuSOLVER's
https://pytorch.org/docs/stable/generated/torch.svd.html
pytorch docs
routines gesvdj and gesvdjBatched on CUDA 10.1.243 and later, and MAGMA's routine gesdd on earlier versions of CUDA. Note: The returned *U* will not be contiguous. The matrix (or batch of matrices) will be represented as a column-major matrix (i.e. Fortran-contiguous). Warning: The gradients with respect to *U* and *V* will only be finite when the input does not have zero nor repeated singular values. Warning: If the distance between any two singular values is close to zero, the gradients with respect to *U* and *V* will be numerically unstable, as they depends on \frac{1}{\min_{i \neq j} \sigma_i^2 - \sigma_j^2}. The same happens when the matrix has small singular values, as these gradients also depend on *S⁻¹*. Warning: For complex-valued "input" the singular value decomposition is not unique, as *U* and *V* may be multiplied by an arbitrary phase factor e^{i \phi} on every column. The same happens when
https://pytorch.org/docs/stable/generated/torch.svd.html
pytorch docs
"input" has repeated singular values, where one may multiply the columns of the spanning subspace in U and V by a rotation matrix and the resulting vectors will span the same subspace. Different platforms, like NumPy, or inputs on different device types, may produce different U and V tensors. Parameters: * input (Tensor) -- the input tensor of size (, m, n) where *** is zero or more batch dimensions consisting of (m, n)* matrices. * **some** (*bool**, **optional*) -- controls whether to compute the reduced or full decomposition, and consequently, the shape of returned *U* and *V*. Default: *True*. * **compute_uv** (*bool**, **optional*) -- controls whether to compute *U* and *V*. Default: *True*. Keyword Arguments: out (tuple, optional) -- the output tuple of tensors Example: >>> a = torch.randn(5, 3) >>> a tensor([[ 0.2364, -0.7752, 0.6372],
https://pytorch.org/docs/stable/generated/torch.svd.html
pytorch docs
tensor([[ 0.2364, -0.7752, 0.6372], [ 1.7201, 0.7394, -0.0504], [-0.3371, -1.0584, 0.5296], [ 0.3550, -0.4022, 1.5569], [ 0.2445, -0.0158, 1.1414]]) >>> u, s, v = torch.svd(a) >>> u tensor([[ 0.4027, 0.0287, 0.5434], [-0.1946, 0.8833, 0.3679], [ 0.4296, -0.2890, 0.5261], [ 0.6604, 0.2717, -0.2618], [ 0.4234, 0.2481, -0.4733]]) >>> s tensor([2.3289, 2.0315, 0.7806]) >>> v tensor([[-0.0199, 0.8766, 0.4809], [-0.5080, 0.4054, -0.7600], [ 0.8611, 0.2594, -0.4373]]) >>> torch.dist(a, torch.mm(torch.mm(u, torch.diag(s)), v.t())) tensor(8.6531e-07) >>> a_big = torch.randn(7, 5, 3) >>> u, s, v = torch.svd(a_big) >>> torch.dist(a_big, torch.matmul(torch.matmul(u, torch.diag_embed(s)), v.mT)) tensor(2.6503e-06)
https://pytorch.org/docs/stable/generated/torch.svd.html
pytorch docs
RNNBase class torch.nn.RNNBase(mode, input_size, hidden_size, num_layers=1, bias=True, batch_first=False, dropout=0.0, bidirectional=False, proj_size=0, device=None, dtype=None) flatten_parameters() Resets parameter data pointer so that they can use faster code paths. Right now, this works only if the module is on the GPU and cuDNN is enabled. Otherwise, it's a no-op.
https://pytorch.org/docs/stable/generated/torch.nn.RNNBase.html
pytorch docs
torch.tril_indices torch.tril_indices(row, col, offset=0, *, dtype=torch.long, device='cpu', layout=torch.strided) -> Tensor Returns the indices of the lower triangular part of a "row"-by- "col" matrix in a 2-by-N Tensor, where the first row contains row coordinates of all indices and the second row contains column coordinates. Indices are ordered based on rows and then columns. The lower triangular part of the matrix is defined as the elements on and below the diagonal. The argument "offset" controls which diagonal to consider. If "offset" = 0, all elements on and below the main diagonal are retained. A positive value includes just as many diagonals above the main diagonal, and similarly a negative value excludes just as many diagonals below the main diagonal. The main diagonal are the set of indices \lbrace (i, i) \rbrace for i \in [0, \min{d_{1}, d_{2}} - 1] where d_{1}, d_{2} are the dimensions of the matrix. Note:
https://pytorch.org/docs/stable/generated/torch.tril_indices.html
pytorch docs
Note: When running on CUDA, "row * col" must be less than 2^{59} to prevent overflow during calculation. Parameters: * row ("int") -- number of rows in the 2-D matrix. * **col** ("int") -- number of columns in the 2-D matrix. * **offset** ("int") -- diagonal offset from the main diagonal. Default: if not provided, 0. Keyword Arguments: * dtype ("torch.dtype", optional) -- the desired data type of returned tensor. Default: if "None", "torch.long". * **device** ("torch.device", optional) -- the desired device of returned tensor. Default: if "None", uses the current device for the default tensor type (see "torch.set_default_tensor_type()"). "device" will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types. * **layout** ("torch.layout", optional) -- currently only support "torch.strided". Example: >>> a = torch.tril_indices(3, 3)
https://pytorch.org/docs/stable/generated/torch.tril_indices.html
pytorch docs
a = torch.tril_indices(3, 3) >>> a tensor([[0, 1, 1, 2, 2, 2], [0, 0, 1, 0, 1, 2]]) >>> a = torch.tril_indices(4, 3, -1) >>> a tensor([[1, 2, 2, 3, 3, 3], [0, 0, 1, 0, 1, 2]]) >>> a = torch.tril_indices(4, 3, 1) >>> a tensor([[0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3], [0, 1, 0, 1, 2, 0, 1, 2, 0, 1, 2]])
https://pytorch.org/docs/stable/generated/torch.tril_indices.html
pytorch docs
torch.Tensor.copy_ Tensor.copy_(src, non_blocking=False) -> Tensor Copies the elements from "src" into "self" tensor and returns "self". The "src" tensor must be broadcastable with the "self" tensor. It may be of a different data type or reside on a different device. Parameters: * src (Tensor) -- the source tensor to copy from * **non_blocking** (*bool*) -- if "True" and this copy is between CPU and GPU, the copy may occur asynchronously with respect to the host. For other cases, this argument has no effect.
https://pytorch.org/docs/stable/generated/torch.Tensor.copy_.html
pytorch docs
torch.Tensor.chalf Tensor.chalf(memory_format=torch.preserve_format) -> Tensor "self.chalf()" is equivalent to "self.to(torch.complex32)". See "to()". Parameters: memory_format ("torch.memory_format", optional) -- the desired memory format of returned Tensor. Default: "torch.preserve_format".
https://pytorch.org/docs/stable/generated/torch.Tensor.chalf.html
pytorch docs
torch.nn.functional.fractional_max_pool3d torch.nn.functional.fractional_max_pool3d(args, *kwargs) Applies 3D fractional max pooling over an input signal composed of several input planes. Fractional MaxPooling is described in detail in the paper Fractional MaxPooling by Ben Graham The max-pooling operation is applied in kT \times kH \times kW regions by a stochastic step size determined by the target output size. The number of output features is equal to the number of input planes. Parameters: * kernel_size -- the size of the window to take a max over. Can be a single number k (for a square kernel of k \times k \times k) or a tuple (kT, kH, kW) * **output_size** -- the target output size of the form oT \times oH \times oW. Can be a tuple *(oT, oH, oW)* or a single number oH for a cubic output oH \times oH \times oH * **output_ratio** -- If one wants to have an output size as a
https://pytorch.org/docs/stable/generated/torch.nn.functional.fractional_max_pool3d.html
pytorch docs
ratio of the input size, this option can be given. This has to be a number or tuple in the range (0, 1) * **return_indices** -- if "True", will return the indices along with the outputs. Useful to pass to "max_unpool3d()". Shape: * Input: (N, C, T_{in}, H_{in}, W_{in}) or (C, T_{in}, H_{in}, W_{in}). * Output: (N, C, T_{out}, H_{out}, W_{out}) or (C, T_{out}, H_{out}, W_{out}), where (T_{out}, H_{out}, W_{out})=\text{output\_size} or (T_{out}, H_{out}, W_{out})=\text{output\_ratio} \times (T_{in}, H_{in}, W_{in}) Examples:: >>> input = torch.randn(20, 16, 50, 32, 16) >>> # pool of cubic window of size=3, and target output size 13x12x11 >>> F.fractional_max_pool3d(input, 3, output_size=(13, 12, 11)) >>> # pool of cubic window and target output size being half of input size >>> F.fractional_max_pool3d(input, 3, output_ratio=(0.5, 0.5, 0.5))
https://pytorch.org/docs/stable/generated/torch.nn.functional.fractional_max_pool3d.html
pytorch docs
ConvBnReLU2d class torch.ao.nn.intrinsic.qat.ConvBnReLU2d(in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, bias=None, padding_mode='zeros', eps=1e-05, momentum=0.1, freeze_bn=False, qconfig=None) A ConvBnReLU2d module is a module fused from Conv2d, BatchNorm2d and ReLU, attached with FakeQuantize modules for weight, used in quantization aware training. We combined the interface of "torch.nn.Conv2d" and "torch.nn.BatchNorm2d" and "torch.nn.ReLU". Similar to torch.nn.Conv2d, with FakeQuantize modules initialized to default. Variables: weight_fake_quant -- fake quant module for weight
https://pytorch.org/docs/stable/generated/torch.ao.nn.intrinsic.qat.ConvBnReLU2d.html
pytorch docs
ParametrizationList class torch.nn.utils.parametrize.ParametrizationList(modules, original, unsafe=False) A sequential container that holds and manages the "original" or "original0", "original1", ... parameters or buffers of a parametrized "torch.nn.Module". It is the type of "module.parametrizations[tensor_name]" when "module[tensor_name]" has been parametrized with "register_parametrization()". If the first registered parametrization has a "right_inverse" that returns one tensor or does not have a "right_inverse" (in which case we assume that "right_inverse" is the identity), it will hold the tensor under the name "original". If it has a "right_inverse" that returns more than one tensor, these will be registered as "original0", "original1", ... Warning: This class is used internally by "register_parametrization()". It is documented here for completeness. It shall not be instantiated by the user. Parameters:
https://pytorch.org/docs/stable/generated/torch.nn.utils.parametrize.ParametrizationList.html
pytorch docs
by the user. Parameters: * modules (sequence) -- sequence of modules representing the parametrizations * **original** (*Parameter** or **Tensor*) -- parameter or buffer that is parametrized * **unsafe** (*bool*) -- a boolean flag that denotes whether the parametrization may change the dtype and shape of the tensor. Default: *False* Warning: the parametrization is not checked for consistency upon registration. Enable this flag at your own risk. right_inverse(value) Calls the methods "right_inverse" (see "register_parametrization()") of the parametrizations in the inverse order they were registered in. Then, it stores the result in "self.original" if "right_inverse" outputs one tensor or in "self.original0", "self.original1", ... if it outputs several. Parameters: **value** (*Tensor*) -- Value to which initialize the module
https://pytorch.org/docs/stable/generated/torch.nn.utils.parametrize.ParametrizationList.html
pytorch docs
torch.nn.functional.cosine_embedding_loss torch.nn.functional.cosine_embedding_loss(input1, input2, target, margin=0, size_average=None, reduce=None, reduction='mean') -> Tensor See "CosineEmbeddingLoss" for details. Return type: Tensor
https://pytorch.org/docs/stable/generated/torch.nn.functional.cosine_embedding_loss.html
pytorch docs
torch._foreach_frac torch._foreach_frac(self: List[Tensor]) -> List[Tensor] Apply "torch.frac()" to each Tensor of the input list.
https://pytorch.org/docs/stable/generated/torch._foreach_frac.html
pytorch docs
torch.stft torch.stft(input, n_fft, hop_length=None, win_length=None, window=None, center=True, pad_mode='reflect', normalized=False, onesided=None, return_complex=None) Short-time Fourier transform (STFT). Warning: From version 1.8.0, "return_complex" must always be given explicitly for real inputs and *return_complex=False* has been deprecated. Strongly prefer *return_complex=True* as in a future pytorch release, this function will only return complex tensors.Note that "torch.view_as_real()" can be used to recover a real tensor with an extra last dimension for real and imaginary components. The STFT computes the Fourier transform of short overlapping windows of the input. This giving frequency components of the signal as they change over time. The interface of this function is modeled after (but not a drop-in replacement for) librosa stft function. Ignoring the optional batch dimension, this method computes the
https://pytorch.org/docs/stable/generated/torch.stft.html
pytorch docs
following expression: X[\omega, m] = \sum_{k = 0}^{\text{win\_length-1}}% \text{window}[k]\ \text{input}[m \times \text{hop\_length} + k]\ % \exp\left(- j \frac{2 \pi \cdot \omega k}{\text{win\_length}}\right), where m is the index of the sliding window, and \omega is the frequency 0 \leq \omega < \text{n_fft} for "onesided=False", or 0 \leq \omega < \lfloor \text{n_fft} / 2 \rfloor + 1 for "onesided=True". "input" must be either a 1-D time sequence or a 2-D batch of time sequences. If "hop_length" is "None" (default), it is treated as equal to "floor(n_fft / 4)". If "win_length" is "None" (default), it is treated as equal to "n_fft". "window" can be a 1-D tensor of size "win_length", e.g., from "torch.hann_window()". If "window" is "None" (default), it is treated as if having 1 everywhere in the window. If \text{win_length} < \text{n_fft}, "window" will be padded on
https://pytorch.org/docs/stable/generated/torch.stft.html
pytorch docs
both sides to length "n_fft" before being applied. If "center" is "True" (default), "input" will be padded on both sides so that the t-th frame is centered at time t \times \text{hop_length}. Otherwise, the t-th frame begins at time t \times \text{hop_length}. "pad_mode" determines the padding method used on "input" when "center" is "True". See "torch.nn.functional.pad()" for all available options. Default is ""reflect"". If "onesided" is "True" (default for real input), only values for \omega in \left[0, 1, 2, \dots, \left\lfloor \frac{\text{n_fft}}{2} \right\rfloor + 1\right] are returned because the real-to-complex Fourier transform satisfies the conjugate symmetry, i.e., X[m, \omega] = X[m, \text{n_fft} - \omega]^*. Note if the input or window tensors are complex, then "onesided" output is not possible. If "normalized" is "True" (default is "False"), the function
https://pytorch.org/docs/stable/generated/torch.stft.html
pytorch docs
returns the normalized STFT results, i.e., multiplied by (\text{frame_length})^{-0.5}. If "return_complex" is "True" (default if input is complex), the return is a "input.dim() + 1" dimensional complex tensor. If "False", the output is a "input.dim() + 2" dimensional real tensor where the last dimension represents the real and imaginary components. Returns either a complex tensor of size ( \times N \times T) if "return_complex" is true, or a real tensor of size ( \times N \times T \times 2). Where * is the optional batch size of "input", N is the number of frequencies where STFT is applied and T is the total number of frames used. Warning: This function changed signature at version 0.4.1. Calling with the previous signature may cause error or return incorrect result. Parameters: * input (Tensor) -- the input tensor * **n_fft** (*int*) -- size of Fourier transform
https://pytorch.org/docs/stable/generated/torch.stft.html
pytorch docs