Functions 137
adaptive_avg_pool1d
functionFull reference ↗adaptive_avg_pool2d
functionFull reference ↗- tensorplay.nn.functional.adaptive_avg_pool2d(input, output_size)[source]
adaptive_avg_pool3d
functionFull reference ↗- tensorplay.nn.functional.adaptive_avg_pool3d(input: TensorBase, output_size) TensorBase[source]
Apply a 3D adaptive average pooling over an input signal.
adaptive_max_pool1d_with_indices
functionFull reference ↗adaptive_max_pool1d
functionFull reference ↗adaptive_max_pool2d_with_indices
functionFull reference ↗adaptive_max_pool2d
functionFull reference ↗- tensorplay.nn.functional.adaptive_max_pool2d(input, output_size)[source]
adaptive_max_pool3d_with_indices
functionFull reference ↗adaptive_max_pool3d
functionFull reference ↗- tensorplay.nn.functional.adaptive_max_pool3d(input, output_size, return_indices=False)[source]
Applies a 3D adaptive max pooling over an input signal composed of several input planes. Input shape
(N, C, D, H, W)or unbatched(C, D, H, W).See
AdaptiveMaxPool3dfor details.
affine_grid
functionFull reference ↗- tensorplay.nn.functional.affine_grid(theta: TensorBase, size, align_corners=None) TensorBase[source]
Generate 2D or 3D flow field (sampling grid), given a batch of affine matrices
theta.
alpha_dropout
functionFull reference ↗- tensorplay.nn.functional.alpha_dropout(input, p=0.5, training=True, inplace=False)[source]
avg_pool1d
functionFull reference ↗- tensorplay.nn.functional.avg_pool1d(input: TensorBase, kernel_size, stride=None, padding=0, ceil_mode: bool = False, count_include_pad: bool = True, divisor_override=None) TensorBase[source]
avg_pool1d(input, kernel_size, stride=None, padding=0, ceil_mode=False, count_include_pad=True, divisor_override=None) -> Tensor
Applies a 1D average pooling over an input signal composed of several input planes. Input shape
(N, C, L)or unbatched(C, L).
avg_pool2d
functionFull reference ↗- tensorplay.nn.functional.avg_pool2d(input, kernel_size, stride=None, padding=0, ceil_mode=False, count_include_pad=True, divisor_override=None)[source]
avg_pool3d
functionFull reference ↗- tensorplay.nn.functional.avg_pool3d(input: TensorBase, kernel_size, stride=None, padding=0, ceil_mode: bool = False, count_include_pad: bool = True, divisor_override=None) TensorBase[source]
avg_pool3d(input, kernel_size, stride=None, padding=0, ceil_mode=False, count_include_pad=True, divisor_override=None) -> Tensor
Applies a 3D average pooling over an input signal composed of several input planes. Input shape
(N, C, D, H, W)or unbatched(C, D, H, W).
batch_norm
functionFull reference ↗- tensorplay.nn.functional.batch_norm(input, running_mean=None, running_var=None, weight=None, bias=None, training=False, momentum=0.1, eps=1e-05)[source]
bilinear
functionFull reference ↗- tensorplay.nn.functional.bilinear(input1, input2, weight, bias=None)[source]
binary_cross_entropy_with_logits
functionFull reference ↗- tensorplay.nn.functional.binary_cross_entropy_with_logits(input: TensorBase, target: TensorBase, weight: TensorBase | None = None, size_average=None, reduce=None, reduction: str = 'mean', pos_weight: TensorBase | None = None) TensorBase[source]
Compute Binary Cross Entropy between target and input logits.
optionally rescaled by
weight, then reduced. SeeBCEWithLogitsLossfor details.
binary_cross_entropy
functionFull reference ↗celu_
functionFull reference ↗- tensorplay.nn.functional.celu_(Tensor(a!) self, Scalar alpha=1.0) -> Tensor(a!)
celu
functionFull reference ↗channel_shuffle
functionFull reference ↗conv_tbc
functionFull reference ↗- tensorplay.nn.functional.conv_tbc(input, weight, bias=None, pad=0)[source]
Applies a 1D convolution over an input of shape (T, B, C) along the
(kernel_width, in_channels, out_channels); the math is a standard cross-channel conv1d after permuting to (B, C, T).
conv_transpose1d
functionFull reference ↗- tensorplay.nn.functional.conv_transpose1d(input, weight, bias=None, stride=1, padding=0, output_padding=0, groups=1, dilation=1)[source]
conv_transpose2d
functionFull reference ↗- tensorplay.nn.functional.conv_transpose2d(input, weight, bias=None, stride=1, padding=0, output_padding=0, groups=1, dilation=1)[source]
conv_transpose3d
functionFull reference ↗- tensorplay.nn.functional.conv_transpose3d(input, weight, bias=None, stride=1, padding=0, output_padding=0, groups=1, dilation=1)[source]
conv1d
functionFull reference ↗- tensorplay.nn.functional.conv1d(input, weight, bias=None, stride=1, padding=0, dilation=1, groups=1)[source]
Applies a 1D convolution over an input signal composed of several input planes.
See
Conv1dfor details and output shape.- Parameters:
input – input tensor of shape
weight – filters of shape
bias – optional bias of shape . Default:
Nonestride – the stride of the convolving kernel. Can be a single number or a one-element tuple (sW,). Default: 1
padding – implicit paddings on both sides of the input. Can be a single number or a one-element tuple (padW,). Default: 0
dilation – the spacing between kernel elements. Can be a single number or a one-element tuple (dW,). Default: 1
groups – split input into groups, should be divisible by the number of groups. Default: 1
Examples:
>>> inputs = tp.randn(33, 16, 30) >>> filters = tp.randn(20, 16, 5) >>> F.conv1d(inputs, filters)
conv2d
functionFull reference ↗- tensorplay.nn.functional.conv2d(input, weight, bias=None, stride=1, padding=0, dilation=1, groups=1)[source]
Applies a 2D convolution over an input image composed of several input planes.
See
Conv2dfor details and output shape.- Parameters:
input – input tensor of shape
weight – filters of shape
bias – optional bias tensor of shape . Default:
Nonestride – the stride of the convolving kernel. Can be a single number or a tuple (sH, sW). Default: 1
padding – implicit paddings on both sides of the input. Can be a single number or a tuple (padH, padW). Default: 0
dilation – the spacing between kernel elements. Can be a single number or a tuple (dH, dW). Default: 1
groups – split input into groups, both and should be divisible by the number of groups. Default: 1
Examples:
>>> # With square kernels and equal stride >>> filters = tp.randn(8, 4, 3, 3) >>> inputs = tp.randn(1, 4, 5, 5) >>> F.conv2d(inputs, filters, padding=1)
conv3d
functionFull reference ↗- tensorplay.nn.functional.conv3d(input, weight, bias=None, stride=1, padding=0, dilation=1, groups=1)[source]
Applies a 3D convolution over an input image composed of several input planes.
See
Conv3dfor details and output shape.- Parameters:
input – input tensor of shape
weight – filters of shape
bias – optional bias tensor of shape . Default:
Nonestride – the stride of the convolving kernel. Can be a single number or a tuple (sD, sH, sW). Default: 1
padding – implicit paddings on both sides of the input. Can be a single number or a tuple (padD, padH, padW). Default: 0
dilation – the spacing between kernel elements. Can be a single number or a tuple (dD, dH, dW). Default: 1
groups – split input into groups, both and should be divisible by the number of groups. Default: 1
Examples:
>>> # With square kernels and equal stride >>> filters = tp.randn(8, 4, 3, 3, 3) >>> inputs = tp.randn(1, 4, 5, 5, 5) >>> F.conv3d(inputs, filters, padding=1)
cosine_embedding_loss
functionFull reference ↗cosine_similarity
functionFull reference ↗cross_entropy
functionFull reference ↗- tensorplay.nn.functional.cross_entropy(input, target, weight=None, size_average=None, ignore_index=-100, reduce=None, reduction='mean', label_smoothing=0.0)[source]
Compute the cross entropy loss between input logits and target.
the class-probability path, positive
label_smoothingblends the NLL with a smoothed uniform term, and otherwise this isnll_loss(log_softmax(input), target)with N-d support.See
CrossEntropyLossfor details.
ctc_loss
functionFull reference ↗- tensorplay.nn.functional.ctc_loss(log_probs: TensorBase, targets: TensorBase, input_lengths, target_lengths, blank: int = 0, reduction: str = 'mean', zero_infinity: bool = False) TensorBase[source]
Compute the Connectionist Temporal Classification loss.
(alpha recurrence over the blank-extended target sequence); autograd flows through
log_probsvia the composed primitives.- Parameters:
log_probs – or log-softmax outputs.
targets – or concatenated .
target_lengths (input_lengths /) – or scalars.
blank – index of the blank label. Default: 0.
reduction –
'none' | 'mean' | 'sum'.zero_infinity – zero out infinite losses (targets too long for T).
dropout_
functionFull reference ↗dropout
functionFull reference ↗- tensorplay.nn.functional.dropout(input, p=0.5, training=True, inplace=False)[source]
dropout1d
functionFull reference ↗dropout2d
functionFull reference ↗- tensorplay.nn.functional.dropout2d(input, p=0.5, training=True, inplace=False)[source]
dropout3d
functionFull reference ↗- tensorplay.nn.functional.dropout3d(input, p=0.5, training=True, inplace=False)[source]
elu_
functionFull reference ↗- tensorplay.nn.functional.elu_(Tensor(a!) self, Scalar alpha=1, Scalar scale=1, Scalar input_scale=1) -> Tensor(a!)
elu
functionFull reference ↗embedding_bag
functionFull reference ↗- tensorplay.nn.functional.embedding_bag(input: TensorBase, weight: TensorBase, offsets=None, max_norm=None, norm_type: float = 2, scale_grad_by_freq: bool = False, mode: str = 'mean', sparse: bool = False, per_sample_weights=None, include_last_offset: bool = False, padding_idx=None) TensorBase[source]
Compute sums, means or maxes of
bagsof embeddings.1-D inputs with
offsets(incl.include_last_offset), fixed length 2-D inputs,per_sample_weights(sum mode),padding_idxexclusion andmax_normrenormalization. Seetensorplay.nn.EmbeddingBagfor details.
embedding
functionFull reference ↗- tensorplay.nn.functional.embedding(input, weight, padding_idx=None, max_norm=None, norm_type=2.0, scale_grad_by_freq=False, sparse=False)[source]
feature_alpha_dropout
functionFull reference ↗- tensorplay.nn.functional.feature_alpha_dropout(input: TensorBase, p: float = 0.5, training: bool = False, inplace: bool = False) TensorBase[source]
Randomly masks out entire channels, setting activations to the negative saturation value of the SELU activation function.
See
FeatureAlphaDropoutfor details.
feature_dropout_
functionFull reference ↗- tensorplay.nn.functional.feature_dropout_(input, p=0.5, training=True)[source]
In-place version of
feature_dropout().
feature_dropout
functionFull reference ↗- tensorplay.nn.functional.feature_dropout(input, p=0.5, training=False, inplace=False)[source]
Randomly zeroes entire channels (dim 1).
flatten
functionFull reference ↗- tensorplay.nn.functional.flatten(input, start_dim=0, end_dim=-1)[source]
fold
functionFull reference ↗- tensorplay.nn.functional.fold(input, output_size, kernel_size, dilation=1, padding=0, stride=1)[source]
Combine an array of sliding local blocks into a tensor containing
fractional_max_pool2d_with_indices
functionFull reference ↗- tensorplay.nn.functional.fractional_max_pool2d_with_indices(input: TensorBase, kernel_size, output_size=None, output_ratio=None, return_indices: bool = True, _random_samples=None)[source]
Applies 2D fractional max pooling over an input signal composed of several input planes, returning
(output, indices).The max-pooling operation is applied in 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,
kor(kH, kW)output_size – target output size
oH x oWoutput_ratio – alternative to output_size, in range (0, 1)
return_indices – return pooling indices as well
_random_samples – optional
(B, C, 2)random starts override
See
FractionalMaxPool2dfor details.
fractional_max_pool2d
functionFull reference ↗- tensorplay.nn.functional.fractional_max_pool2d(input: TensorBase, kernel_size, output_size=None, output_ratio=None, return_indices: bool = False, _random_samples=None)[source]
Applies 2D fractional max pooling over an input signal.
If
return_indicesisTrue, returns(output, indices); otherwise just the output.
fractional_max_pool3d_with_indices
functionFull reference ↗- tensorplay.nn.functional.fractional_max_pool3d_with_indices(input: TensorBase, kernel_size, output_size=None, output_ratio=None, return_indices: bool = True, _random_samples=None)[source]
Applies 3D fractional max pooling over an input signal composed of several input planes, returning
(output, indices).Each plane consumes three random samples ordered
(T, H, W), matching
fractional_max_pool3d
functionFull reference ↗- tensorplay.nn.functional.fractional_max_pool3d(input: TensorBase, kernel_size, output_size=None, output_ratio=None, return_indices: bool = False, _random_samples=None)[source]
Applies 3D fractional max pooling over an input signal.
If
return_indicesisTrue, returns(output, indices); otherwise just the output.
gaussian_nll_loss
functionFull reference ↗gelu
functionFull reference ↗glu
functionFull reference ↗grid_sample
functionFull reference ↗- tensorplay.nn.functional.grid_sample(input: TensorBase, grid: TensorBase, mode: str = 'bilinear', padding_mode: str = 'zeros', align_corners=None) TensorBase[source]
Compute grid sample.
Given an
inputand a flow-fieldgrid, computes theoutputusinginputvalues and pixel locations fromgrid. Currently, only spatial (4-D) and volumetric (5-D)inputare supported.- Parameters:
input (Tensor) – input of shape (4-D case) or (5-D case)
grid (Tensor) – flow-field of shape (4-D case) or (5-D case)
mode (str) –
'bilinear'|'nearest'|'bicubic'. Default:'bilinear'padding_mode (str) –
'zeros'|'border'|'reflection'. Default:'zeros'align_corners (bool, optional) – extrema treatment, default
False.
Dispatches to the native grid_sampler_2d / grid_sampler_3d kernels both
inputandgrid.
group_norm
functionFull reference ↗- tensorplay.nn.functional.group_norm(input, num_groups, weight=None, bias=None, eps=1e-05)[source]
grouped_mm
functionFull reference ↗- tensorplay.nn.functional.grouped_mm(input, mat2, offs)[source]
gru_cell
functionFull reference ↗gumbel_softmax
functionFull reference ↗hardshrink
functionFull reference ↗hardsigmoid
functionFull reference ↗hardswish
functionFull reference ↗hardtanh_
functionFull reference ↗- tensorplay.nn.functional.hardtanh_(Tensor(a!) self, Scalar min_val=-1, Scalar max_val=1) -> Tensor(a!)
hardtanh
functionFull reference ↗hinge_embedding_loss
functionFull reference ↗huber_loss
functionFull reference ↗- tensorplay.nn.functional.huber_loss(input: TensorBase, target: TensorBase, reduction: str = 'mean', delta: float = 1.0, weight: TensorBase | None = None) TensorBase[source]
Compute the Huber loss, with optional weighting.
Function uses a squared term if the absolute error falls below delta and a delta-scaled L1 term otherwise. See
HuberLossfor details.
instance_norm
functionFull reference ↗- tensorplay.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)[source]
interpolate
functionFull reference ↗- tensorplay.nn.functional.interpolate(input: TensorBase, size=None, scale_factor=None, mode: str = 'nearest', align_corners=None, recompute_scale_factor=None, antialias: bool = False) TensorBase[source]
interpolate(input, size=None, scale_factor=None, mode=’nearest’, align_corners=None) -> Tensor
Routes to the native
upsample_*ops exactly like
kl_div
functionFull reference ↗- tensorplay.nn.functional.kl_div(input: TensorBase, target: TensorBase, size_average=None, reduce=None, reduction: str = 'mean', log_target: bool = False) TensorBase[source]
Compute the KL Divergence loss.
inputholds log-probabilities; seeKLDivLoss. Note thatreduction='mean'divides by the number of elements and does not return the true KL divergence value — use'batchmean'.
l1_loss
functionFull reference ↗- tensorplay.nn.functional.l1_loss(input: TensorBase, target: TensorBase, size_average=None, reduce=None, reduction: str = 'mean', weight: TensorBase | None = None) TensorBase[source]
Compute the L1 loss, with optional weighting.
Function that takes the mean element-wise absolute value difference. See
L1Lossfor details.
layer_norm
functionFull reference ↗- tensorplay.nn.functional.layer_norm(input, normalized_shape, weight=None, bias=None, eps=1e-05)[source]
leaky_relu_
functionFull reference ↗- tensorplay.nn.functional.leaky_relu_(Tensor(a!) self, Scalar negative_slope=0.01) -> Tensor(a!)
leaky_relu
functionFull reference ↗linear_cross_entropy
functionFull reference ↗- tensorplay.nn.functional.linear_cross_entropy(input: TensorBase, linear_weight: TensorBase, target: TensorBase, *, linear_bias=None, weight=None, reduction: str = 'mean', ignore_index=None, label_smoothing: float = 0.0, options=None) TensorBase[source]
Compute cross entropy between
input, transformed linearly, and target.Equivalent to
cross_entropy(linear(input, linear_weight), target, **kwargs)(reference path; chunked/fused options are ignored).
linear
functionFull reference ↗- tensorplay.nn.functional.linear(input: TensorBase, weight: TensorBase, bias: TensorBase | None = None) TensorBase[source]
Applies a linear transformation to the incoming data: .
- Shape:
Input: where means any number of dimensions including none and .
Weight: where .
Bias:
Output:
See
Linearfor more details.
local_response_norm
functionFull reference ↗- tensorplay.nn.functional.local_response_norm(input: TensorBase, size: int, alpha: float = 0.0001, beta: float = 0.75, k: float = 1.0) TensorBase[source]
Apply local response normalization over an input signal.
The input signal is composed of several input planes, where channels occupy the second dimension. Normalization is applied across channels.
See
LocalResponseNormfor details.
log_softmax
functionFull reference ↗- tensorplay.nn.functional.log_softmax(input, dim=None, dtype=None)[source]
logsigmoid
functionFull reference ↗lp_pool1d
functionFull reference ↗lp_pool2d
functionFull reference ↗- tensorplay.nn.functional.lp_pool2d(input: TensorBase, norm_type, kernel_size, stride=None, ceil_mode: bool = False) TensorBase[source]
Apply a 2D power-average pooling over an input signal.
If the sum of all inputs to the power of p is zero, the gradient is set to zero as well.
See
LPPool2dfor details.
lp_pool3d
functionFull reference ↗lstm_cell
functionFull reference ↗- tensorplay.nn.functional.lstm_cell(input, hx, cx, w_ih, w_hh, b_ih=None, b_hh=None)[source]
One time step of a long short-term memory cell. Returns the next hidden state and next cell state.
margin_ranking_loss
functionFull reference ↗max_pool1d_with_indices
functionFull reference ↗max_pool1d
functionFull reference ↗- tensorplay.nn.functional.max_pool1d(input: TensorBase, kernel_size, stride=None, padding=0, dilation=1, ceil_mode: bool = False, return_indices: bool = False)[source]
max_pool1d(input, kernel_size, stride=None, padding=0, dilation=1, ceil_mode=False, return_indices=False) -> Tensor
Applies a 1D max pooling over an input signal composed of several input planes. Input shape
(N, C, L)or unbatched(C, L).
max_pool2d_with_indices
functionFull reference ↗- tensorplay.nn.functional.max_pool2d_with_indices(input: TensorBase, kernel_size, stride=None, padding=0, dilation=1, ceil_mode: bool = False, return_indices: bool = True)[source]
Applies a 2D max pooling over an input composed of several input planes, returning
(output, indices).See
MaxPool2dfor details.
max_pool2d
functionFull reference ↗- tensorplay.nn.functional.max_pool2d(input, kernel_size, stride=None, padding=0, dilation=1, ceil_mode=False, return_indices=False)[source]
max_pool3d_with_indices
functionFull reference ↗max_pool3d
functionFull reference ↗- tensorplay.nn.functional.max_pool3d(input: TensorBase, kernel_size, stride=None, padding=0, dilation=1, ceil_mode: bool = False, return_indices: bool = False) TensorBase[source]
max_pool3d(input, kernel_size, stride=None, padding=0, dilation=1, ceil_mode=False, return_indices=False) -> Tensor
Applies a 3D max pooling over an input signal composed of several input planes. Input shape
(N, C, D, H, W)or unbatched(C, D, H, W).
max_unpool1d
functionFull reference ↗- tensorplay.nn.functional.max_unpool1d(input: TensorBase, indices: TensorBase, kernel_size, stride=None, padding=0, output_size=None) TensorBase[source]
Compute a partial inverse of
MaxPool1d.See
MaxUnpool1dfor details.
max_unpool2d
functionFull reference ↗- tensorplay.nn.functional.max_unpool2d(input: TensorBase, indices: TensorBase, kernel_size, stride=None, padding=0, output_size=None) TensorBase[source]
Compute a partial inverse of
MaxPool2d.See
MaxUnpool2dfor details.
max_unpool3d
functionFull reference ↗- tensorplay.nn.functional.max_unpool3d(input: TensorBase, indices: TensorBase, kernel_size, stride=None, padding=0, output_size=None) TensorBase[source]
Compute a partial inverse of
MaxPool3d.See
MaxUnpool3dfor details.
mish
functionFull reference ↗mse_loss
functionFull reference ↗- tensorplay.nn.functional.mse_loss(input, target, reduction='mean')[source]
multi_head_attention_forward
functionFull reference ↗- tensorplay.nn.functional.multi_head_attention_forward(query: TensorBase, key: TensorBase, value: TensorBase, embed_dim_to_check: int, num_heads: int, in_proj_weight: TensorBase = None, in_proj_bias: TensorBase = None, bias_k=None, bias_v=None, add_zero_attn: bool = False, dropout_p: float = 0.0, out_proj_weight: TensorBase = None, out_proj_bias: TensorBase = None, training: bool = True, key_padding_mask=None, need_weights: bool = True, attn_mask=None, use_separate_proj_weight: bool = False, q_proj_weight=None, k_proj_weight=None, v_proj_weight=None, static_k=None, static_v=None, average_attn_weights: bool = True, is_causal: bool = False)[source]
multi_head_attention_forward(query, key, value, embed_dim_to_check, num_heads, in_proj_weight, in_proj_bias=None, bias_k=None, bias_v=None, add_zero_attn=False, dropout_p=0.0, out_proj_weight=None, out_proj_bias=None, training=True, key_padding_mask=None, need_weights=True, attn_mask=None, use_separate_proj_weight=False, q_proj_weight=None, k_proj_weight=None, v_proj_weight=None, static_k=None, static_v=None, average_attn_weights=True, is_causal=False) -> (Tensor, Optional[Tensor])
Computes multi-head attention on (L, N, E) inputs (2D unbatched inputs are promoted internally and the batch dim is squeezed on return). Returns the projected output of shape (L, N, E) and, when
need_weightsis true, the attention weights of shape (N, L, S) — or (num_heads, L, S) withaverage_attn_weights=False.
multi_margin_loss
functionFull reference ↗- tensorplay.nn.functional.multi_margin_loss(input: TensorBase, target: TensorBase, p: int = 1, margin: float = 1.0, weight: TensorBase | None = None, size_average=None, reduce=None, reduction: str = 'mean') TensorBase[source]
Compute the multi margin loss, with optional weighting.
sum_d max(0, margin - x_y + x_d)^p * w_y / Cover non-target classes. SeeMultiMarginLossfor details.
multilabel_margin_loss
functionFull reference ↗- tensorplay.nn.functional.multilabel_margin_loss(input: TensorBase, target: TensorBase, size_average=None, reduce=None, reduction: str = 'mean') TensorBase[source]
Compute the multilabel margin loss.
for each positive label
y(targets are active until the first-1), addmax(0, 1 - x[y] + x[d])over non-target labelsd; divide by C. SeeMultiLabelMarginLossfor details.
multilabel_soft_margin_loss
functionFull reference ↗native_channel_shuffle
functionFull reference ↗nll_loss
functionFull reference ↗- tensorplay.nn.functional.nll_loss(input, target, weight=None, size_average=None, ignore_index=-100, reduce=None, reduction='mean')[source]
The negative log likelihood loss.
inputwith a scalartarget, 2D(N, C), and N-dtarget.See
NLLLossfor details.
normalize
functionFull reference ↗one_hot
functionFull reference ↗- tensorplay.nn.functional.one_hot(tensor, num_classes=-1) LongTensor[source]
Returns long tensor shaped
tensor.shape + (num_classes,)with a 1 at
pad
functionFull reference ↗- tensorplay.nn.functional.pad(input, pad, mode='constant', value=0)[source]
Pads tensor.
padvalues are described starting from the last dimension and may cover any suffix of the input dimensions.
pairwise_distance
functionFull reference ↗pdist
functionFull reference ↗pixel_shuffle
functionFull reference ↗pixel_unshuffle
functionFull reference ↗- tensorplay.nn.functional.pixel_unshuffle(input: TensorBase, downscale_factor: int) TensorBase[source]
Reverses the
pixel_shuffle()transformation:(*, C, H x r, W x r) -> (*, C x r^2, H, W).
poisson_nll_loss
functionFull reference ↗- tensorplay.nn.functional.poisson_nll_loss(input: TensorBase, target: TensorBase, log_input: bool = True, full: bool = False, size_average=None, eps: float = 1e-08, reduce=None, reduction: str = 'mean') TensorBase[source]
Compute the Poisson negative log likelihood loss.
See
PoissonNLLLossfor details.
prelu
functionFull reference ↗- tensorplay.nn.functional.prelu(input, weight)[source]
relu_
functionFull reference ↗- tensorplay.nn.functional.relu_(Tensor(a!) self) -> Tensor(a!)
relu
functionFull reference ↗- tensorplay.nn.functional.relu(input, inplace=False)[source]
relu6
functionFull reference ↗rms_norm
functionFull reference ↗- tensorplay.nn.functional.rms_norm(input: TensorBase, normalized_shape, weight: TensorBase | None = None, eps: float | None = None) TensorBase[source]
Apply Root Mean Square Layer Normalization.
Dispatches to the native fused kernel (single dispatch, CPU vectorized rows / CUDA block-per-row); falls back to the composite below under CompositeImplicitAutograd rms_norm.
rnn_relu_cell
functionFull reference ↗rnn_tanh_cell
functionFull reference ↗rrelu_
functionFull reference ↗rrelu
functionFull reference ↗scaled_dot_product_attention
functionFull reference ↗- tensorplay.nn.functional.scaled_dot_product_attention(query: TensorBase, key: TensorBase, value: TensorBase, attn_mask=None, dropout_p: float = 0.0, is_causal: bool = False, scale=None, enable_gqa: bool = False, backend: str | None = None) TensorBase[source]
scaled_dot_product_attention(query, key, value, attn_mask=None, dropout_p=0.0, is_causal=False, scale=None, enable_gqa=False, backend=None) -> Tensor
Computes scaled dot product attention on query, key and value. Routes to reference:
- Parameters:
backend (str, optional) –
'flash'|'mem_efficient','math', orNoneto pick automatically.'flash'selects the fused flash-attention kernel,'math'forces the composed reference path. WhenNone, the routing candidate order is governed bytensorplay.nn.attention.sdpa_kernel().
scaled_grouped_mm
functionFull reference ↗- tensorplay.nn.functional.scaled_grouped_mm(*args, **kwargs)[source]
scaled_mm
functionFull reference ↗- tensorplay.nn.functional.scaled_mm(*args, **kwargs)[source]
selu_
functionFull reference ↗- tensorplay.nn.functional.selu_(Tensor(a!) self) -> Tensor(a!)
selu
functionFull reference ↗sigmoid
functionFull reference ↗silu
functionFull reference ↗- tensorplay.nn.functional.silu(input: TensorBase, inplace: bool = False) TensorBase[source]
Apply the Sigmoid Linear Unit (SiLU) function, element-wise.
The SiLU function is also known as the swish function.
Note
See Gaussian Error Linear Units (GELUs) where the SiLU (Sigmoid Linear Unit) was originally coined, and see Sigmoid-Weighted Linear Units for Neural Network Function Approximation in Reinforcement Learning and Swish: a Self-Gated Activation Function where the SiLU was experimented with later.
See
SiLUfor more details.
smooth_l1_loss
functionFull reference ↗- tensorplay.nn.functional.smooth_l1_loss(input: TensorBase, target: TensorBase, size_average=None, reduce=None, reduction: str = 'mean', beta: float = 1.0) TensorBase[source]
Compute the Smooth L1 loss.
Function uses a squared term if the absolute element-wise error falls below beta and an L1 term otherwise. See
SmoothL1Lossfor details.
soft_margin_loss
functionFull reference ↗softmax
functionFull reference ↗- tensorplay.nn.functional.softmax(input, dim=None, dtype=None)[source]
softmin
functionFull reference ↗softplus
functionFull reference ↗softshrink
functionFull reference ↗softsign
functionFull reference ↗tanh
functionFull reference ↗tanhshrink
functionFull reference ↗threshold_
functionFull reference ↗- tensorplay.nn.functional.threshold_(Tensor(a!) self, Scalar threshold, Scalar value) -> Tensor(a!)
threshold
functionFull reference ↗triplet_margin_loss
functionFull reference ↗- tensorplay.nn.functional.triplet_margin_loss(anchor: TensorBase, positive: TensorBase, negative: TensorBase, margin: float = 1.0, p: float = 2, eps: float = 1e-06, swap: bool = False, size_average=None, reduce=None, reduction: str = 'mean') TensorBase[source]
Compute the triplet loss between given input tensors and a margin greater than 0.
See
TripletMarginLossfor details.
triplet_margin_with_distance_loss
functionFull reference ↗- tensorplay.nn.functional.triplet_margin_with_distance_loss(anchor: TensorBase, positive: TensorBase, negative: TensorBase, *, distance_function=None, margin: float = 1.0, swap: bool = False, reduction: str = 'mean') TensorBase[source]
Compute the triplet margin loss using a custom distance function.
See
TripletMarginWithDistanceLossfor details.
unfold
functionFull reference ↗- tensorplay.nn.functional.unfold(input, kernel_size, dilation=1, padding=0, stride=1)[source]

