Rate this Page

Functional API#

The torch::nn::functional namespace provides stateless versions of neural network operations. Unlike module classes, functional operations do not hold learnable parameters — you pass weights explicitly.

When to use functional vs modules:

  • Use modules (torch::nn::Conv2d) when you need learnable parameters managed automatically (training, saving, loading).

  • Use functional (torch::nn::functional::conv2d) when you already have weights as tensors, or for operations without parameters (e.g., relu).

#include <torch/nn/functional.h>
namespace F = torch::nn::functional;

// Stateless activation — no module needed
auto output = F::relu(input);

// Convolution with explicit weight tensor
auto output = F::conv2d(input, weight, F::Conv2dFuncOptions().stride(1).padding(1));

// Softmax along a dimension
auto probs = F::softmax(logits, F::SoftmaxFuncOptions(/*dim=*/1));

Activation Functions#

inline Tensor torch::nn::functional::elu(Tensor input, const ELUFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.elu about the exact behavior of this functional.

See the documentation for torch::nn::functional::ELUFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::elu(x, F::ELUFuncOptions().alpha(0.42).inplace(true));

inline Tensor torch::nn::functional::selu(Tensor input, const SELUFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.selu about the exact behavior of this functional.

See the documentation for torch::nn::functional::SELUFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::selu(input, F::SELUFuncOptions(false));

inline Tensor torch::nn::functional::hardshrink(const Tensor &input, const HardshrinkFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.hardshrink about the exact behavior of this functional.

See the documentation for torch::nn::functional::HardshrinkFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::hardshrink(x, F::HardshrinkFuncOptions().lambda(0.42));

inline Tensor torch::nn::functional::hardtanh(Tensor input, const HardtanhFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.hardtanh about the exact behavior of this functional.

See the documentation for torch::nn::functional::HardtanhFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::hardtanh(x,
F::HardtanhFuncOptions().min_val(-1.0).max_val(1.0).inplace(true));

inline Tensor torch::nn::functional::leaky_relu(Tensor input, const LeakyReLUFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.leaky_relu about the exact behavior of this functional.

See the documentation for torch::nn::functional::LeakyReLUFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::leaky_relu(x,
F::LeakyReLUFuncOptions().negative_slope(0.42).inplace(true));

inline Tensor torch::nn::functional::logsigmoid(const Tensor &input)#
inline Tensor torch::nn::functional::glu(const Tensor &input, const GLUFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.glu about the exact behavior of this functional.

See the documentation for torch::nn::functional::GLUFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::glu(input, GLUFuncOptions(1));

inline Tensor torch::nn::functional::gelu(const Tensor &input, const GELUFuncOptions &options = {})#
inline Tensor torch::nn::functional::silu(const Tensor &input)#
inline Tensor torch::nn::functional::mish(const Tensor &input)#
inline Tensor torch::nn::functional::prelu(const Tensor &input, const Tensor &weight)#
inline Tensor torch::nn::functional::relu(Tensor input, const ReLUFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.relu about the exact behavior of this functional.

See the documentation for torch::nn::functional::ReLUFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::relu(x, F::ReLUFuncOptions().inplace(true));

inline Tensor torch::nn::functional::relu6(Tensor input, const ReLU6FuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.relu6 about the exact behavior of this functional.

See the documentation for torch::nn::functional::ReLU6FuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::relu6(x, F::ReLU6FuncOptions().inplace(true));

inline Tensor torch::nn::functional::rrelu(Tensor input, const RReLUFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.rrelu about the exact behavior of this functional.

See the documentation for torch::nn::functional::RReLUFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::rrelu(x, F::RReLUFuncOptions().lower(0.1).upper(0.4).inplace(true));

inline Tensor torch::nn::functional::celu(Tensor input, const CELUFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.celu about the exact behavior of this functional.

See the documentation for torch::nn::functional::CELUFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::celu(x, F::CELUFuncOptions().alpha(0.42).inplace(true));

inline Tensor torch::nn::functional::softplus(const Tensor &input, const SoftplusFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.softplus about the exact behavior of this functional.

See the documentation for torch::nn::functional::SoftplusFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::softplus(x, F::SoftplusFuncOptions().beta(0.5).threshold(3.0));

inline Tensor torch::nn::functional::softshrink(const Tensor &input, const SoftshrinkFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.softshrink about the exact behavior of this functional.

See the documentation for torch::nn::functional::SoftshrinkFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::softshrink(x, F::SoftshrinkFuncOptions(0.42));

inline Tensor torch::nn::functional::softsign(const Tensor &input)#
inline Tensor torch::nn::functional::tanhshrink(const Tensor &input)#
inline Tensor torch::nn::functional::threshold(Tensor input, const ThresholdFuncOptions &options)#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.threshold about the exact behavior of this functional.

See the documentation for torch::nn::functional::ThresholdFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::threshold(x, F::ThresholdFuncOptions(0.5, 0.5).inplace(true));

inline Tensor torch::nn::functional::softmax(const Tensor &input, const SoftmaxFuncOptions &options)#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.softmax about the exact behavior of this functional.

See the documentation for torch::nn::functional::SoftmaxFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::softmax(input, F::SoftmaxFuncOptions(1));

inline Tensor torch::nn::functional::softmin(const Tensor &input, const SoftminFuncOptions &options)#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.softmin about the exact behavior of this functional.

See the documentation for torch::nn::functional::SoftminFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::softmin(input, F::SoftminFuncOptions(1));

inline Tensor torch::nn::functional::log_softmax(const Tensor &input, const LogSoftmaxFuncOptions &options)#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.log_softmax about the exact behavior of this functional.

See the documentation for torch::nn::functional::LogSoftmaxFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::log_softmax(input, LogSoftmaxFuncOptions(1));

inline Tensor torch::nn::functional::gumbel_softmax(const Tensor &logits, const GumbelSoftmaxFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.gumbel_softmax about the exact behavior of this functional.

See the documentation for torch::nn::functional::GumbelSoftmaxFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::gumbel_softmax(logits, F::GumbelSoftmaxFuncOptions().hard(true).dim(-1));

Convolution Functions#

inline Tensor torch::nn::functional::conv1d(const Tensor &input, const Tensor &weight, const Conv1dFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.conv1d about the exact behavior of this functional.

See the documentation for torch::nn::functional::Conv1dFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::conv1d(x, weight, F::Conv1dFuncOptions().stride(1));

inline Tensor torch::nn::functional::conv2d(const Tensor &input, const Tensor &weight, const Conv2dFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.conv2d about the exact behavior of this functional.

See the documentation for torch::nn::functional::Conv2dFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::conv2d(x, weight, F::Conv2dFuncOptions().stride(1));

inline Tensor torch::nn::functional::conv3d(const Tensor &input, const Tensor &weight, const Conv3dFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.conv3d about the exact behavior of this functional.

See the documentation for torch::nn::functional::Conv3dFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::conv3d(x, weight, F::Conv3dFuncOptions().stride(1));

inline Tensor torch::nn::functional::conv_transpose1d(const Tensor &input, const Tensor &weight, const ConvTranspose1dFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.conv_transpose1d about the exact behavior of this functional.

See the documentation for torch::nn::functional::ConvTranspose1dFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::conv_transpose1d(x, weight, F::ConvTranspose1dFuncOptions().stride(1));

inline Tensor torch::nn::functional::conv_transpose2d(const Tensor &input, const Tensor &weight, const ConvTranspose2dFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.conv_transpose2d about the exact behavior of this functional.

See the documentation for torch::nn::functional::ConvTranspose2dFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::conv_transpose2d(x, weight, F::ConvTranspose2dFuncOptions().stride(1));

inline Tensor torch::nn::functional::conv_transpose3d(const Tensor &input, const Tensor &weight, const ConvTranspose3dFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.conv_transpose3d about the exact behavior of this functional.

See the documentation for torch::nn::functional::ConvTranspose3dFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::conv_transpose3d(x, weight, F::ConvTranspose3dFuncOptions().stride(1));

Pooling Functions#

inline Tensor torch::nn::functional::avg_pool1d(const Tensor &input, const AvgPool1dFuncOptions &options)#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.avg_pool1d about the exact behavior of this functional.

See the documentation for torch::nn::functional::AvgPool1dFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::avg_pool1d(x, F::AvgPool1dFuncOptions(3).stride(2));

inline Tensor torch::nn::functional::avg_pool2d(const Tensor &input, const AvgPool2dFuncOptions &options)#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.avg_pool2d about the exact behavior of this functional.

See the documentation for torch::nn::functional::AvgPool2dFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::avg_pool2d(x, F::AvgPool2dFuncOptions(3).stride(2));

inline Tensor torch::nn::functional::avg_pool3d(const Tensor &input, const AvgPool3dFuncOptions &options)#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.avg_pool3d about the exact behavior of this functional.

See the documentation for torch::nn::functional::AvgPool3dFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::avg_pool3d(x, F::AvgPool3dFuncOptions(3).stride(2));

inline Tensor torch::nn::functional::max_pool1d(const Tensor &input, const MaxPool1dFuncOptions &options)#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.max_pool1d about the exact behavior of this functional.

See the documentation for torch::nn::functional::MaxPool1dFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::max_pool1d(x, F::MaxPool1dFuncOptions(3).stride(2));

inline Tensor torch::nn::functional::max_pool2d(const Tensor &input, const MaxPool2dFuncOptions &options)#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.max_pool2d about the exact behavior of this functional.

See the documentation for torch::nn::functional::MaxPool2dFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::max_pool2d(x, F::MaxPool2dFuncOptions(3).stride(2));

inline Tensor torch::nn::functional::max_pool3d(const Tensor &input, const MaxPool3dFuncOptions &options)#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.max_pool3d about the exact behavior of this functional.

See the documentation for torch::nn::functional::MaxPool3dFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::max_pool3d(x, F::MaxPool3dFuncOptions(3).stride(2));

inline std::tuple<Tensor, Tensor> torch::nn::functional::max_pool1d_with_indices(const Tensor &input, const MaxPool1dFuncOptions &options)#

See the documentation for torch::nn::functional::MaxPool1dFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::max_pool1d_with_indices(x, F::MaxPool1dFuncOptions(3).stride(2));

inline std::tuple<Tensor, Tensor> torch::nn::functional::max_pool2d_with_indices(const Tensor &input, const MaxPool2dFuncOptions &options)#

See the documentation for torch::nn::functional::MaxPool2dFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::max_pool2d_with_indices(x, F::MaxPool2dFuncOptions(3).stride(2));

inline std::tuple<Tensor, Tensor> torch::nn::functional::max_pool3d_with_indices(const Tensor &input, const MaxPool3dFuncOptions &options)#

See the documentation for torch::nn::functional::MaxPool3dFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::max_pool3d_with_indices(x, F::MaxPool3dFuncOptions(3).stride(2));

inline Tensor torch::nn::functional::adaptive_max_pool1d(const Tensor &input, const AdaptiveMaxPool1dFuncOptions &options)#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.adaptive_max_pool1d about the exact behavior of this functional.

See the documentation for torch::nn::functional::AdaptiveMaxPool1dFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::adaptive_max_pool1d(x, F::AdaptiveMaxPool1dFuncOptions(3));

inline Tensor torch::nn::functional::adaptive_max_pool2d(const Tensor &input, const AdaptiveMaxPool2dFuncOptions &options)#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.adaptive_max_pool2d about the exact behavior of this functional.

See the documentation for torch::nn::functional::AdaptiveMaxPool2dFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::adaptive_max_pool2d(x, F::AdaptiveMaxPool2dFuncOptions(3));

inline Tensor torch::nn::functional::adaptive_max_pool3d(const Tensor &input, const AdaptiveMaxPool3dFuncOptions &options)#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.adaptive_max_pool3d about the exact behavior of this functional.

See the documentation for torch::nn::functional::AdaptiveMaxPool3dFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::adaptive_max_pool3d(x, F::AdaptiveMaxPool3dFuncOptions(3));

inline Tensor torch::nn::functional::adaptive_avg_pool1d(const Tensor &input, const AdaptiveAvgPool1dFuncOptions &options)#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.adaptive_avg_pool1d about the exact behavior of this functional.

See the documentation for torch::nn::functional::AdaptiveAvgPool1dFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::adaptive_avg_pool1d(x, F::AdaptiveAvgPool1dFuncOptions(3));

inline Tensor torch::nn::functional::adaptive_avg_pool2d(const Tensor &input, const AdaptiveAvgPool2dFuncOptions &options)#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.adaptive_avg_pool2d about the exact behavior of this functional.

See the documentation for torch::nn::functional::AdaptiveAvgPool2dFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::adaptive_avg_pool2d(x, F::AdaptiveAvgPool2dFuncOptions(3));

inline Tensor torch::nn::functional::adaptive_avg_pool3d(const Tensor &input, const AdaptiveAvgPool3dFuncOptions &options)#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.adaptive_avg_pool3d about the exact behavior of this functional.

See the documentation for torch::nn::functional::AdaptiveAvgPool3dFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::adaptive_avg_pool3d(x, F::AdaptiveAvgPool3dFuncOptions(3));

inline Tensor torch::nn::functional::max_unpool1d(const Tensor &input, const Tensor &indices, const MaxUnpool1dFuncOptions &options)#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.max_unpool1d about the exact behavior of this functional.

See the documentation for torch::nn::functional::MaxUnpool1dFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::max_unpool1d(x, indices,
F::MaxUnpool1dFuncOptions(3).stride(2).padding(1));

inline Tensor torch::nn::functional::max_unpool2d(const Tensor &input, const Tensor &indices, const MaxUnpool2dFuncOptions &options)#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.max_unpool2d about the exact behavior of this functional.

See the documentation for torch::nn::functional::MaxUnpool2dFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::max_unpool2d(x, indices,
F::MaxUnpool2dFuncOptions(3).stride(2).padding(1));

inline Tensor torch::nn::functional::max_unpool3d(const Tensor &input, const Tensor &indices, const MaxUnpool3dFuncOptions &options)#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.max_unpool3d about the exact behavior of this functional.

See the documentation for torch::nn::functional::MaxUnpool3dFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::max_unpool3d(x, indices, F::MaxUnpool3dFuncOptions(3));

inline Tensor torch::nn::functional::fractional_max_pool2d(const Tensor &input, const FractionalMaxPool2dFuncOptions &options)#

See the documentation for torch::nn::functional::FractionalMaxPool2dFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::fractional_max_pool2d(x,
F::FractionalMaxPool2dFuncOptions(3).output_size(2));

inline Tensor torch::nn::functional::fractional_max_pool3d(const Tensor &input, const FractionalMaxPool3dFuncOptions &options)#

See the documentation for torch::nn::functional::FractionalMaxPool3dFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::fractional_max_pool3d(x,
F::FractionalMaxPool3dFuncOptions(3).output_size(2));

inline Tensor torch::nn::functional::lp_pool1d(const Tensor &input, const LPPool1dFuncOptions &options)#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.lp_pool1d about the exact behavior of this functional.

See the documentation for torch::nn::functional::LPPool1dFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::lp_pool1d(x, F::LPPool1dFuncOptions(2, 3).stride(2));

inline Tensor torch::nn::functional::lp_pool2d(const Tensor &input, const LPPool2dFuncOptions &options)#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.lp_pool2d about the exact behavior of this functional.

See the documentation for torch::nn::functional::LPPool2dFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::lp_pool2d(x, F::LPPool2dFuncOptions(2, {2, 3}).stride(2));

inline Tensor torch::nn::functional::lp_pool3d(const Tensor &input, const LPPool3dFuncOptions &options)#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.lp_pool3d about the exact behavior of this functional.

See the documentation for torch::nn::functional::LPPool3dFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::lp_pool3d(x, F::LPPool3dFuncOptions(3, {3, 3, 5}).stride(3));

Linear Functions#

inline Tensor torch::nn::functional::linear(const Tensor &input, const Tensor &weight, const Tensor &bias = {})#
inline Tensor torch::nn::functional::bilinear(const Tensor &input1, const Tensor &input2, const Tensor &weight, const Tensor &bias = Tensor())#

Dropout Functions#

inline Tensor torch::nn::functional::dropout(Tensor input, const DropoutFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.dropout about the exact behavior of this functional.

See the documentation for torch::nn::functional::DropoutFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::dropout(input, F::DropoutFuncOptions().p(0.5));

inline Tensor torch::nn::functional::dropout2d(Tensor input, const Dropout2dFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.dropout2d about the exact behavior of this functional.

See the documentation for torch::nn::functional::Dropout2dFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::dropout2d(input, F::Dropout2dFuncOptions().p(0.5));

inline Tensor torch::nn::functional::dropout3d(Tensor input, const Dropout3dFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.dropout3d about the exact behavior of this functional.

See the documentation for torch::nn::functional::Dropout3dFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::dropout3d(input, F::Dropout3dFuncOptions().p(0.5));

inline Tensor torch::nn::functional::alpha_dropout(Tensor input, const AlphaDropoutFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.alpha_dropout about the exact behavior of this functional.

See the documentation for torch::nn::functional::AlphaDropoutFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::alpha_dropout(input,
F::AlphaDropoutFuncOptions().p(0.5).training(false));

inline Tensor torch::nn::functional::feature_alpha_dropout(Tensor input, const FeatureAlphaDropoutFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.feature_alpha_dropout about the exact behavior of this functional.

See the documentation for torch::nn::functional::FeatureAlphaDropoutFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::feature_alpha_dropout(input,
F::FeatureAlphaDropoutFuncOptions().p(0.5).training(false));

Embedding Functions#

inline Tensor torch::nn::functional::one_hot(const Tensor &tensor, int64_t num_classes = -1)#
inline Tensor torch::nn::functional::embedding(const Tensor &input, const Tensor &weight, const EmbeddingFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.embedding about the exact behavior of this functional.

See the documentation for torch::nn::functional::EmbeddingFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::embedding(input, weight,
F::EmbeddingFuncOptions().norm_type(2.5).scale_grad_by_freq(true).sparse(true));

inline Tensor torch::nn::functional::embedding_bag(const Tensor &input, const Tensor &weight, const EmbeddingBagFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.embedding_bag about the exact behavior of this functional.

See the documentation for torch::nn::functional::EmbeddingBagFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::embedding_bag(input, weight,
F::EmbeddingBagFuncOptions().mode(torch::kSum).offsets(offsets));

Normalization Functions#

inline Tensor torch::nn::functional::batch_norm(const Tensor &input, const Tensor &running_mean, const Tensor &running_var, const BatchNormFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.batch_norm about the exact behavior of this functional.

See the documentation for torch::nn::functional::BatchNormFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::batch_norm(input, mean, variance,
F::BatchNormFuncOptions().weight(weight).bias(bias).momentum(0.1).eps(1e-05).training(false));

inline Tensor torch::nn::functional::instance_norm(const Tensor &input, const InstanceNormFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.instance_norm about the exact behavior of this functional.

See the documentation for torch::nn::functional::InstanceNormFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::instance_norm(input,
F::InstanceNormFuncOptions().running_mean(mean).running_var(variance).weight(weight).bias(bias).momentum(0.1).eps(1e-5));

inline Tensor torch::nn::functional::layer_norm(const Tensor &input, const LayerNormFuncOptions &options)#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.layer_norm about the exact behavior of this functional.

See the documentation for torch::nn::functional::LayerNormFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::layer_norm(input, F::LayerNormFuncOptions({2, 2}).eps(2e-5));

inline Tensor torch::nn::functional::group_norm(const Tensor &input, const GroupNormFuncOptions &options)#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.group_norm about the exact behavior of this functional.

See the documentation for torch::nn::functional::GroupNormFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::group_norm(input, F::GroupNormFuncOptions(2).eps(2e-5));

inline Tensor torch::nn::functional::local_response_norm(const Tensor &input, const LocalResponseNormFuncOptions &options)#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.local_response_norm about the exact behavior of this functional.

See the documentation for torch::nn::functional::LocalResponseNormFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::local_response_norm(x, F::LocalResponseNormFuncOptions(2));

inline Tensor torch::nn::functional::normalize(const Tensor &input, NormalizeFuncOptions options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.normalize about the exact behavior of this functional.

See the documentation for torch::nn::functional::NormalizeFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::normalize(input, F::NormalizeFuncOptions().p(1).dim(-1));

Loss Functions#

inline Tensor torch::nn::functional::l1_loss(const Tensor &input, const Tensor &target, const L1LossFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.l1_loss about the exact behavior of this functional.

See the documentation for torch::nn::functional::L1LossFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::l1_loss(input, target, F::L1LossFuncOptions(torch::kNone));

inline Tensor torch::nn::functional::mse_loss(const Tensor &input, const Tensor &target, const MSELossFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.mse_loss about the exact behavior of this functional.

See the documentation for torch::nn::functional::MSELossFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::mse_loss(input, target, F::MSELossFuncOptions(torch::kNone));

inline Tensor torch::nn::functional::binary_cross_entropy(const Tensor &input, const Tensor &target, const BinaryCrossEntropyFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.binary_cross_entropy about the exact behavior of this functional.

See the documentation for torch::nn::functional::BinaryCrossEntropyFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::binary_cross_entropy(input, target,
F::BinaryCrossEntropyFuncOptions().weight(weight));

inline Tensor torch::nn::functional::binary_cross_entropy_with_logits(const Tensor &input, const Tensor &target, const BinaryCrossEntropyWithLogitsFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.binary_cross_entropy_with_logits about the exact behavior of this functional.

See the documentation for torch::nn::functional::BinaryCrossEntropyWithLogitsFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::binary_cross_entropy_with_logits(input, target,
F::BinaryCrossEntropyWithLogitsFuncOptions().pos_weight(pos_weight).reduction(torch::kSum));

inline Tensor torch::nn::functional::cross_entropy(const Tensor &input, const Tensor &target, const CrossEntropyFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.cross_entropy about the exact behavior of this functional.

See the documentation for torch::nn::functional::CrossEntropyFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::cross_entropy(input, target,
F::CrossEntropyFuncOptions().ignore_index(-100).reduction(torch::kMean));

inline Tensor torch::nn::functional::nll_loss(const Tensor &input, const Tensor &target, const NLLLossFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.nll_loss about the exact behavior of this functional.

See the documentation for torch::nn::functional::NLLLossFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::nll_loss(input, target,
F::NLLLossFuncOptions().ignore_index(-100).reduction(torch::kMean));

inline Tensor torch::nn::functional::kl_div(const Tensor &input, const Tensor &target, const KLDivFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.kl_div about the exact behavior of this functional.

See the documentation for torch::nn::functional::KLDivFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::kl_div(input, target,
F::KLDivFuncOptions.reduction(torch::kNone).log_target(false));

inline Tensor torch::nn::functional::smooth_l1_loss(const Tensor &input, const Tensor &target, const SmoothL1LossFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.smooth_l1_loss about the exact behavior of this functional.

See the documentation for torch::nn::functional::SmoothL1LossFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::smooth_l1_loss(input, target, F::SmoothL1LossFuncOptions(torch::kNone));

inline Tensor torch::nn::functional::huber_loss(const Tensor &input, const Tensor &target, const HuberLossFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.huber_loss about the exact behavior of this functional.

See the documentation for torch::nn::functional::HuberLossFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::huber_loss(input, target,
F::HuberLossFuncOptions().reduction(torch::kNone).delta(0.5));

inline Tensor torch::nn::functional::hinge_embedding_loss(const Tensor &input, const Tensor &target, const HingeEmbeddingLossFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.hinge_embedding_loss about the exact behavior of this functional.

See the documentation for torch::nn::functional::HingeEmbeddingLossFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::hinge_embedding_loss(input, target,
F::HingeEmbeddingLossFuncOptions().margin(2));

inline Tensor torch::nn::functional::multi_margin_loss(const Tensor &input, const Tensor &target, const MultiMarginLossFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.multi_margin_loss about the exact behavior of this functional.

See the documentation for torch::nn::functional::MultiMarginLossFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::multi_margin_loss(input, target,
F::MultiMarginLossFuncOptions().margin(2).weight(weight));

inline Tensor torch::nn::functional::cosine_embedding_loss(const Tensor &input1, const Tensor &input2, const Tensor &target, const CosineEmbeddingLossFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.cosine_embedding_loss about the exact behavior of this functional.

See the documentation for torch::nn::functional::CosineEmbeddingLossFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::cosine_embedding_loss(input1, input2, target,
F::CosineEmbeddingLossFuncOptions().margin(0.5));

inline Tensor torch::nn::functional::margin_ranking_loss(const Tensor &input1, const Tensor &input2, const Tensor &target, const MarginRankingLossFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.margin_ranking_loss about the exact behavior of this functional.

See the documentation for torch::nn::functional::MarginRankingLossFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::margin_ranking_loss(input1, input2, target,
F::MarginRankingLossFuncOptions().margin(0.5).reduction(torch::kSum));

inline Tensor torch::nn::functional::multilabel_margin_loss(const Tensor &input, const Tensor &target, const MultilabelMarginLossFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.multilabel_margin_loss about the exact behavior of this functional.

See the documentation for torch::nn::functional::MultilabelMarginLossFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::multilabel_margin_loss(input, target,
F::MultilabelMarginLossFuncOptions(torch::kNone));

inline Tensor torch::nn::functional::soft_margin_loss(const Tensor &input, const Tensor &target, const SoftMarginLossFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.soft_margin_loss about the exact behavior of this functional.

See the documentation for torch::nn::functional::SoftMarginLossFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::soft_margin_loss(input, target,
F::SoftMarginLossFuncOptions(torch::kNone));

inline Tensor torch::nn::functional::multilabel_soft_margin_loss(const Tensor &input, const Tensor &target, const MultilabelSoftMarginLossFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.multilabel_soft_margin_loss about the exact behavior of this functional.

See the documentation for torch::nn::functional::MultilabelSoftMarginLossFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::multilabel_soft_margin_loss(input, target,
F::MultilabelSoftMarginLossFuncOptions().reduction(torch::kNone).weight(weight));

inline Tensor torch::nn::functional::triplet_margin_loss(const Tensor &anchor, const Tensor &positive, const Tensor &negative, const TripletMarginLossFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.triplet_margin_loss about the exact behavior of this functional.

See the documentation for torch::nn::functional::TripletMarginLossFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::triplet_margin_loss(anchor, positive, negative,
F::TripletMarginLossFuncOptions().margin(1.0));

inline Tensor torch::nn::functional::triplet_margin_with_distance_loss(const Tensor &anchor, const Tensor &positive, const Tensor &negative, const TripletMarginWithDistanceLossFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.triplet_margin_with_distance_loss about the exact behavior of this functional.

See the documentation for torch::nn::functional::TripletMarginWithDistanceLossFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::triplet_margin_with_distance_loss(anchor, positive, negative,
F::TripletMarginWithDistanceLossFuncOptions().margin(1.0));

inline Tensor torch::nn::functional::ctc_loss(const Tensor &log_probs, const Tensor &targets, const Tensor &input_lengths, const Tensor &target_lengths, const CTCLossFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.ctc_loss about the exact behavior of this functional.

See the documentation for torch::nn::functional::CTCLossFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::ctc_loss(log_probs, targets, input_lengths, target_lengths,
F::CTCLossFuncOptions().reduction(torch::kNone));

inline Tensor torch::nn::functional::poisson_nll_loss(const Tensor &input, const Tensor &target, const PoissonNLLLossFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.poisson_nll_loss about the exact behavior of this functional.

See the documentation for torch::nn::functional::PoissonNLLLossFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::poisson_nll_loss(input, target,
F::PoissonNLLLossFuncOptions().reduction(torch::kNone));

Distance Functions#

inline Tensor torch::nn::functional::cosine_similarity(const Tensor &x1, const Tensor &x2, const CosineSimilarityFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.cosine_similarity about the exact behavior of this functional.

See the documentation for torch::nn::functional::CosineSimilarityFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::cosine_similarity(input1, input2,
F::CosineSimilarityFuncOptions().dim(1));

inline Tensor torch::nn::functional::pairwise_distance(const Tensor &x1, const Tensor &x2, const PairwiseDistanceFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.pairwise_distance about the exact behavior of this functional.

See the documentation for torch::nn::functional::PairwiseDistanceFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::pairwise_distance(input1, input2, F::PairwiseDistanceFuncOptions().p(1));

inline Tensor torch::nn::functional::pdist(const Tensor &input, double p = 2.0)#

Computes the p-norm distance between every pair of row vectors in the input.

This function will be faster if the rows are contiguous.

Vision Functions#

inline Tensor torch::nn::functional::interpolate(const Tensor &input, const InterpolateFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.interpolate about the exact behavior of this functional.

See the documentation for torch::nn::functional::InterpolateFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::interpolate(input,
F::InterpolateFuncOptions().size({4}).mode(torch::kNearest));

inline Tensor torch::nn::functional::affine_grid(const Tensor &theta, const IntArrayRef &size, bool align_corners = false)#
inline Tensor torch::nn::functional::grid_sample(const Tensor &input, const Tensor &grid, const GridSampleFuncOptions &options = {})#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.grid_sample about the exact behavior of this functional.

See the documentation for torch::nn::functional::GridSampleFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::grid_sample(input, grid,
F::GridSampleFuncOptions().mode(torch::kBilinear).padding_mode(torch::kZeros).align_corners(true));

inline Tensor torch::nn::functional::pad(const Tensor &input, const PadFuncOptions &options)#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.pad about the exact behavior of this functional.

See the documentation for torch::nn::functional::PadFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::pad(input, F::PadFuncOptions({1, 2, 2, 1, 1,
2}).mode(torch::kReplicate));

inline Tensor torch::nn::functional::pixel_shuffle(const Tensor &input, const PixelShuffleFuncOptions &options)#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.pixel_shuffle about the exact behavior of this functional.

See the documentation for torch::nn::functional::PixelShuffleFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::pixel_shuffle(x, F::PixelShuffleFuncOptions(2));

inline Tensor torch::nn::functional::pixel_unshuffle(const Tensor &input, const PixelUnshuffleFuncOptions &options)#

Fold/Unfold#

inline Tensor torch::nn::functional::fold(const Tensor &input, const FoldFuncOptions &options)#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.fold about the exact behavior of this functional.

See the documentation for torch::nn::functional::FoldFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::fold(input, F::FoldFuncOptions({3, 2}, {2, 2}));

inline Tensor torch::nn::functional::unfold(const Tensor &input, const UnfoldFuncOptions &options)#

See https://pytorch.org/docs/main/nn.functional.html#torch.nn.functional.unfold about the exact behavior of this functional.

See the documentation for torch::nn::functional::UnfoldFuncOptions class to learn what optional arguments are supported for this functional.

Example:

namespace F = torch::nn::functional;
F::unfold(input, F::UnfoldFuncOptions({2, 2}).padding(1).stride(2));

Functional Options Structs#

Each functional operation that takes configuration uses a corresponding options struct. The naming convention is <Operation>FuncOptions.

Activation Options:

using torch::nn::functional::ELUFuncOptions = ELUOptions#

Options for torch::nn::functional::elu.

See the documentation for torch::nn::ELUOptions class to learn what arguments are supported.

Example:

namespace F = torch::nn::functional;
F::elu(x, F::ELUFuncOptions().alpha(0.42).inplace(true));

using torch::nn::functional::SELUFuncOptions = SELUOptions#

Options for torch::nn::functional::selu.

See the documentation for torch::nn::SELUOptions class to learn what arguments are supported.

Example:

namespace F = torch::nn::functional;
F::selu(input, F::SELUFuncOptions(false));

using torch::nn::functional::GLUFuncOptions = GLUOptions#

Options for torch::nn::functional::glu.

See the documentation for torch::nn::GLUOptions class to learn what arguments are supported.

Example:

namespace F = torch::nn::functional;
F::glu(input, GLUFuncOptions(1));

using torch::nn::functional::GELUFuncOptions = GELUOptions#

Options for torch::nn::functional::gelu.

See the documentation for torch::nn::GELUOptions class to learn what arguments are supported.

Example:

namespace F = torch::nn::functional;
F::gelu(input, F::GELUFuncOptions().approximate("none"));

using torch::nn::functional::HardshrinkFuncOptions = HardshrinkOptions#

Options for torch::nn::functional::hardshrink.

See the documentation for torch::nn::HardshrinkOptions class to learn what arguments are supported.

Example:

namespace F = torch::nn::functional;
F::hardshrink(x, F::HardshrinkFuncOptions().lambda(0.42));

using torch::nn::functional::HardtanhFuncOptions = HardtanhOptions#

Options for torch::nn::functional::hardtanh.

See the documentation for torch::nn::HardtanhOptions class to learn what arguments are supported.

Example:

namespace F = torch::nn::functional;
F::hardtanh(x,
F::HardtanhFuncOptions().min_val(-1.0).max_val(1.0).inplace(true));

using torch::nn::functional::LeakyReLUFuncOptions = LeakyReLUOptions#

Options for torch::nn::functional::leaky_relu.

See the documentation for torch::nn::LeakyReLUOptions class to learn what arguments are supported.

Example:

namespace F = torch::nn::functional;
F::leaky_relu(x,
F::LeakyReLUFuncOptions().negative_slope(0.42).inplace(true));

using torch::nn::functional::ReLUFuncOptions = ReLUOptions#

Options for torch::nn::functional::relu.

See the documentation for torch::nn::ReLUOptions class to learn what arguments are supported.

Example:

namespace F = torch::nn::functional;
F::relu(x, F::ReLUFuncOptions().inplace(true));

using torch::nn::functional::ReLU6FuncOptions = ReLU6Options#

Options for torch::nn::functional::relu6.

See the documentation for torch::nn::ReLU6Options class to learn what arguments are supported.

Example:

namespace F = torch::nn::functional;
F::relu6(x, F::ReLU6FuncOptions().inplace(true));

using torch::nn::functional::CELUFuncOptions = CELUOptions#

Options for torch::nn::functional::celu.

See the documentation for torch::nn::CELUOptions class to learn what arguments are supported.

Example:

namespace F = torch::nn::functional;
F::celu(x, F::CELUFuncOptions().alpha(0.42).inplace(true));

using torch::nn::functional::SoftplusFuncOptions = SoftplusOptions#

Options for torch::nn::functional::softplus.

See the documentation for torch::nn::SoftplusOptions class to learn what arguments are supported.

Example:

namespace F = torch::nn::functional;
F::softplus(x, F::SoftplusFuncOptions().beta(0.5).threshold(3.0));

using torch::nn::functional::SoftshrinkFuncOptions = SoftshrinkOptions#

Options for torch::nn::functional::softshrink.

See the documentation for torch::nn::SoftshrinkOptions class to learn what arguments are supported.

Example:

namespace F = torch::nn::functional;
F::softshrink(x, F::SoftshrinkFuncOptions(0.42));

using torch::nn::functional::ThresholdFuncOptions = ThresholdOptions#

Options for torch::nn::functional::threshold.

See the documentation for torch::nn::ThresholdOptions class to learn what arguments are supported.

Example:

namespace F = torch::nn::functional;
F::threshold(x, F::ThresholdFuncOptions(0.5, 0.5).inplace(true));

Convolution Options:

using torch::nn::functional::Conv1dFuncOptions = ConvFuncOptions<1>#

ConvFuncOptions specialized for torch::nn::functional::conv1d.

Example:

namespace F = torch::nn::functional;
F::conv1d(x, weight, F::Conv1dFuncOptions().stride(1));

using torch::nn::functional::Conv2dFuncOptions = ConvFuncOptions<2>#

ConvFuncOptions specialized for torch::nn::functional::conv2d.

Example:

namespace F = torch::nn::functional;
F::conv2d(x, weight, F::Conv2dFuncOptions().stride(1));

using torch::nn::functional::Conv3dFuncOptions = ConvFuncOptions<3>#

ConvFuncOptions specialized for torch::nn::functional::conv3d.

Example:

namespace F = torch::nn::functional;
F::conv3d(x, weight, F::Conv3dFuncOptions().stride(1));

using torch::nn::functional::ConvTranspose1dFuncOptions = ConvTransposeFuncOptions<1>#

ConvTransposeFuncOptions specialized for torch::nn::functional::conv_transpose1d.

Example:

namespace F = torch::nn::functional;
F::conv_transpose1d(x, weight, F::ConvTranspose1dFuncOptions().stride(1));

using torch::nn::functional::ConvTranspose2dFuncOptions = ConvTransposeFuncOptions<2>#

ConvTransposeFuncOptions specialized for torch::nn::functional::conv_transpose2d.

Example:

namespace F = torch::nn::functional;
F::conv_transpose2d(x, weight, F::ConvTranspose2dFuncOptions().stride(1));

using torch::nn::functional::ConvTranspose3dFuncOptions = ConvTransposeFuncOptions<3>#

ConvTransposeFuncOptions specialized for torch::nn::functional::conv_transpose3d.

Example:

namespace F = torch::nn::functional;
F::conv_transpose3d(x, weight, F::ConvTranspose3dFuncOptions().stride(1));

Pooling Options:

using torch::nn::functional::AvgPool1dFuncOptions = AvgPool1dOptions#

Options for torch::nn::functional::avg_pool1d.

See the documentation for torch::nn::AvgPool1dOptions class to learn what arguments are supported.

Example:

namespace F = torch::nn::functional;
F::avg_pool1d(x, F::AvgPool1dFuncOptions(3).stride(2));

using torch::nn::functional::AvgPool2dFuncOptions = AvgPool2dOptions#

Options for torch::nn::functional::avg_pool2d.

See the documentation for torch::nn::AvgPool2dOptions class to learn what arguments are supported.

Example:

namespace F = torch::nn::functional;
F::avg_pool2d(x, F::AvgPool2dFuncOptions(3).stride(2));

using torch::nn::functional::AvgPool3dFuncOptions = AvgPool3dOptions#

Options for torch::nn::functional::avg_pool3d.

See the documentation for torch::nn::AvgPool3dOptions class to learn what arguments are supported.

Example:

namespace F = torch::nn::functional;
F::avg_pool3d(x, F::AvgPool3dFuncOptions(3).stride(2));

using torch::nn::functional::MaxPool1dFuncOptions = MaxPool1dOptions#

Options for torch::nn::functional::max_pool1d and torch::nn::functional::max_pool1d_with_indices.

Example:

namespace F = torch::nn::functional;
F::max_pool1d(x, F::MaxPool1dFuncOptions(3).stride(2));

using torch::nn::functional::MaxPool2dFuncOptions = MaxPool2dOptions#

Options for torch::nn::functional::max_pool2d and torch::nn::functional::max_pool2d_with_indices.

Example:

namespace F = torch::nn::functional;
F::max_pool2d(x, F::MaxPool2dFuncOptions(3).stride(2));

using torch::nn::functional::MaxPool3dFuncOptions = MaxPool3dOptions#

Options for torch::nn::functional::max_pool3d and torch::nn::functional::max_pool3d_with_indices.

Example:

namespace F = torch::nn::functional;
F::max_pool3d(x, F::MaxPool3dFuncOptions(3).stride(2));

using torch::nn::functional::AdaptiveMaxPool1dFuncOptions = AdaptiveMaxPool1dOptions#

Options for torch::nn::functional::adaptive_max_pool1d and torch::nn::functional::adaptive_max_pool1d_with_indices

Example:

namespace F = torch::nn::functional;
F::adaptive_max_pool1d(x, F::AdaptiveMaxPool1dFuncOptions(3));

using torch::nn::functional::AdaptiveMaxPool2dFuncOptions = AdaptiveMaxPool2dOptions#

Options for torch::nn::functional::adaptive_max_pool2d and torch::nn::functional::adaptive_max_pool2d_with_indices

Example:

namespace F = torch::nn::functional;
F::adaptive_max_pool2d(x, F::AdaptiveMaxPool2dFuncOptions(3));

using torch::nn::functional::AdaptiveMaxPool3dFuncOptions = AdaptiveMaxPool3dOptions#

Options for torch::nn::functional::adaptive_max_pool3d and torch::nn::functional::adaptive_max_pool3d_with_indices

Example:

namespace F = torch::nn::functional;
F::adaptive_max_pool3d(x, F::AdaptiveMaxPool3dFuncOptions(3));

using torch::nn::functional::AdaptiveAvgPool1dFuncOptions = AdaptiveAvgPool1dOptions#

Options for torch::nn::functional::adaptive_avg_pool1d.

See the documentation for torch::nn::AdaptiveAvgPool1dOptions class to learn what arguments are supported.

Example:

namespace F = torch::nn::functional;
F::adaptive_avg_pool1d(x, F::AdaptiveAvgPool1dFuncOptions(3));

using torch::nn::functional::AdaptiveAvgPool2dFuncOptions = AdaptiveAvgPool2dOptions#

Options for torch::nn::functional::adaptive_avg_pool2d.

See the documentation for torch::nn::AdaptiveAvgPool2dOptions class to learn what arguments are supported.

Example:

namespace F = torch::nn::functional;
F::adaptive_avg_pool2d(x, F::AdaptiveAvgPool2dFuncOptions(3));

using torch::nn::functional::AdaptiveAvgPool3dFuncOptions = AdaptiveAvgPool3dOptions#

Options for torch::nn::functional::adaptive_avg_pool3d.

See the documentation for torch::nn::AdaptiveAvgPool3dOptions class to learn what arguments are supported.

Example:

namespace F = torch::nn::functional;
F::adaptive_avg_pool3d(x, F::AdaptiveAvgPool3dFuncOptions(3));

Other Options:

using torch::nn::functional::CosineSimilarityFuncOptions = CosineSimilarityOptions#

Options for torch::nn::functional::cosine_similarity.

See the documentation for torch::nn::CosineSimilarityOptions class to learn what arguments are supported.

Example:

namespace F = torch::nn::functional;
F::cosine_similarity(input1, input2,
F::CosineSimilarityFuncOptions().dim(1));

using torch::nn::functional::PairwiseDistanceFuncOptions = PairwiseDistanceOptions#

Options for torch::nn::functional::pairwise_distance.

See the documentation for torch::nn::PairwiseDistanceOptions class to learn what arguments are supported.

Example:

namespace F = torch::nn::functional;
F::pairwise_distance(input1, input2, F::PairwiseDistanceFuncOptions().p(1));

using torch::nn::functional::Dropout2dFuncOptions = DropoutFuncOptions#

Options for torch::nn::functional::dropout2d.

Example:

namespace F = torch::nn::functional;
F::dropout2d(input, F::Dropout2dFuncOptions().p(0.5));

using torch::nn::functional::Dropout3dFuncOptions = DropoutFuncOptions#

Options for torch::nn::functional::dropout3d.

Example:

namespace F = torch::nn::functional;
F::dropout3d(input, F::Dropout3dFuncOptions().p(0.5));

using torch::nn::functional::L1LossFuncOptions = L1LossOptions#

Options for torch::nn::functional::l1_loss.

See the documentation for torch::nn::L1LossOptions class to learn what arguments are supported.

Example:

namespace F = torch::nn::functional;
F::l1_loss(input, target, F::L1LossFuncOptions(torch::kNone));

using torch::nn::functional::FoldFuncOptions = FoldOptions#

Options for torch::nn::functional::fold.

See the documentation for torch::nn::FoldOptions class to learn what arguments are supported.

Example:

namespace F = torch::nn::functional;
F::fold(input, F::FoldFuncOptions({3, 2}, {2, 2}));

using torch::nn::functional::UnfoldFuncOptions = UnfoldOptions#

Options for torch::nn::functional::unfold.

See the documentation for torch::nn::UnfoldOptions class to learn what arguments are supported.

Example:

namespace F = torch::nn::functional;
F::unfold(input, F::UnfoldFuncOptions({2, 2}).padding(1).stride(2));

using torch::nn::functional::PixelShuffleFuncOptions = PixelShuffleOptions#

Options for torch::nn::functional::pixel_shuffle.

See the documentation for torch::nn::PixelShuffleOptions class to learn what arguments are supported.

Example:

namespace F = torch::nn::functional;
F::pixel_shuffle(x, F::PixelShuffleFuncOptions(2));

using torch::nn::functional::PixelUnshuffleFuncOptions = PixelUnshuffleOptions#

Options for torch::nn::functional::pixel_unshuffle.

See the documentation for torch::nn::PixelUnshuffleOptions class to learn what arguments are supported.

Example:

namespace F = torch::nn::functional;
F::pixel_unshuffle(x, F::PixelUnshuffleFuncOptions(2));