Title: Functional API — PyTorch main documentation
Description: Functional API in PyTorch C++ — torch::nn::functional stateless operations for neural networks.
Keywords:
Domain: docs.pytorch.org
{
"@context": "https://schema.org",
"@type": "Article",
"name": "Functional API",
"headline": "Functional API",
"description": "Functional API in PyTorch C++ \u2014 torch::nn::functional stateless operations for neural networks.",
"url": "/api/nn/functional.html",
"articleBody": "Functional API# The torch::nn::functional namespace provides stateless versions of neural network operations. Unlike module classes, functional operations do not hold learnable parameters \u2014 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 \u003ctorch/nn/functional.h\u003e namespace F = torch::nn::functional; // Stateless activation \u2014 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 \u0026options = {})# 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 \u0026options = {})# 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 \u0026input, const HardshrinkFuncOptions \u0026options = {})# 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 \u0026options = {})# 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 \u0026options = {})# 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 \u0026input)# inline Tensor torch::nn::functional::glu(const Tensor \u0026input, const GLUFuncOptions \u0026options = {})# 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 \u0026input, const GELUFuncOptions \u0026options = {})# inline Tensor torch::nn::functional::silu(const Tensor \u0026input)# inline Tensor torch::nn::functional::mish(const Tensor \u0026input)# inline Tensor torch::nn::functional::prelu(const Tensor \u0026input, const Tensor \u0026weight)# inline Tensor torch::nn::functional::relu(Tensor input, const ReLUFuncOptions \u0026options = {})# 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 \u0026options = {})# 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 \u0026options = {})# 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 \u0026options = {})# 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 \u0026input, const SoftplusFuncOptions \u0026options = {})# 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 \u0026input, const SoftshrinkFuncOptions \u0026options = {})# 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 \u0026input)# inline Tensor torch::nn::functional::tanhshrink(const Tensor \u0026input)# inline Tensor torch::nn::functional::threshold(Tensor input, const ThresholdFuncOptions \u0026options)# 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 \u0026input, const SoftmaxFuncOptions \u0026options)# 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 \u0026input, const SoftminFuncOptions \u0026options)# 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 \u0026input, const LogSoftmaxFuncOptions \u0026options)# 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 \u0026logits, const GumbelSoftmaxFuncOptions \u0026options = {})# 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 \u0026input, const Tensor \u0026weight, const Conv1dFuncOptions \u0026options = {})# 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 \u0026input, const Tensor \u0026weight, const Conv2dFuncOptions \u0026options = {})# 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 \u0026input, const Tensor \u0026weight, const Conv3dFuncOptions \u0026options = {})# 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 \u0026input, const Tensor \u0026weight, const ConvTranspose1dFuncOptions \u0026options = {})# 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 \u0026input, const Tensor \u0026weight, const ConvTranspose2dFuncOptions \u0026options = {})# 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 \u0026input, const Tensor \u0026weight, const ConvTranspose3dFuncOptions \u0026options = {})# 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 \u0026input, const AvgPool1dFuncOptions \u0026options)# 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 \u0026input, const AvgPool2dFuncOptions \u0026options)# 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 \u0026input, const AvgPool3dFuncOptions \u0026options)# 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 \u0026input, const MaxPool1dFuncOptions \u0026options)# 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 \u0026input, const MaxPool2dFuncOptions \u0026options)# 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 \u0026input, const MaxPool3dFuncOptions \u0026options)# 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\u003cTensor, Tensor\u003e torch::nn::functional::max_pool1d_with_indices(const Tensor \u0026input, const MaxPool1dFuncOptions \u0026options)# 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\u003cTensor, Tensor\u003e torch::nn::functional::max_pool2d_with_indices(const Tensor \u0026input, const MaxPool2dFuncOptions \u0026options)# 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\u003cTensor, Tensor\u003e torch::nn::functional::max_pool3d_with_indices(const Tensor \u0026input, const MaxPool3dFuncOptions \u0026options)# 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 \u0026input, const AdaptiveMaxPool1dFuncOptions \u0026options)# 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 \u0026input, const AdaptiveMaxPool2dFuncOptions \u0026options)# 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 \u0026input, const AdaptiveMaxPool3dFuncOptions \u0026options)# 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 \u0026input, const AdaptiveAvgPool1dFuncOptions \u0026options)# 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 \u0026input, const AdaptiveAvgPool2dFuncOptions \u0026options)# 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 \u0026input, const AdaptiveAvgPool3dFuncOptions \u0026options)# 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 \u0026input, const Tensor \u0026indices, const MaxUnpool1dFuncOptions \u0026options)# 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 \u0026input, const Tensor \u0026indices, const MaxUnpool2dFuncOptions \u0026options)# 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 \u0026input, const Tensor \u0026indices, const MaxUnpool3dFuncOptions \u0026options)# 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 \u0026input, const FractionalMaxPool2dFuncOptions \u0026options)# 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 \u0026input, const FractionalMaxPool3dFuncOptions \u0026options)# 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 \u0026input, const LPPool1dFuncOptions \u0026options)# 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 \u0026input, const LPPool2dFuncOptions \u0026options)# 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 \u0026input, const LPPool3dFuncOptions \u0026options)# 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 \u0026input, const Tensor \u0026weight, const Tensor \u0026bias = {})# inline Tensor torch::nn::functional::bilinear(const Tensor \u0026input1, const Tensor \u0026input2, const Tensor \u0026weight, const Tensor \u0026bias = Tensor())# Dropout Functions# inline Tensor torch::nn::functional::dropout(Tensor input, const DropoutFuncOptions \u0026options = {})# 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 \u0026options = {})# 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 \u0026options = {})# 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 \u0026options = {})# 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 \u0026options = {})# 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 \u0026tensor, int64_t num_classes = -1)# inline Tensor torch::nn::functional::embedding(const Tensor \u0026input, const Tensor \u0026weight, const EmbeddingFuncOptions \u0026options = {})# 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 \u0026input, const Tensor \u0026weight, const EmbeddingBagFuncOptions \u0026options = {})# 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 \u0026input, const Tensor \u0026running_mean, const Tensor \u0026running_var, const BatchNormFuncOptions \u0026options = {})# 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 \u0026input, const InstanceNormFuncOptions \u0026options = {})# 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 \u0026input, const LayerNormFuncOptions \u0026options)# 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 \u0026input, const GroupNormFuncOptions \u0026options)# 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 \u0026input, const LocalResponseNormFuncOptions \u0026options)# 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 \u0026input, 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 \u0026input, const Tensor \u0026target, const L1LossFuncOptions \u0026options = {})# 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 \u0026input, const Tensor \u0026target, const MSELossFuncOptions \u0026options = {})# 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 \u0026input, const Tensor \u0026target, const BinaryCrossEntropyFuncOptions \u0026options = {})# 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 \u0026input, const Tensor \u0026target, const BinaryCrossEntropyWithLogitsFuncOptions \u0026options = {})# 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 \u0026input, const Tensor \u0026target, const CrossEntropyFuncOptions \u0026options = {})# 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 \u0026input, const Tensor \u0026target, const NLLLossFuncOptions \u0026options = {})# 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 \u0026input, const Tensor \u0026target, const KLDivFuncOptions \u0026options = {})# 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 \u0026input, const Tensor \u0026target, const SmoothL1LossFuncOptions \u0026options = {})# 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 \u0026input, const Tensor \u0026target, const HuberLossFuncOptions \u0026options = {})# 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 \u0026input, const Tensor \u0026target, const HingeEmbeddingLossFuncOptions \u0026options = {})# 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 \u0026input, const Tensor \u0026target, const MultiMarginLossFuncOptions \u0026options = {})# 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 \u0026input1, const Tensor \u0026input2, const Tensor \u0026target, const CosineEmbeddingLossFuncOptions \u0026options = {})# 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 \u0026input1, const Tensor \u0026input2, const Tensor \u0026target, const MarginRankingLossFuncOptions \u0026options = {})# 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 \u0026input, const Tensor \u0026target, const MultilabelMarginLossFuncOptions \u0026options = {})# 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 \u0026input, const Tensor \u0026target, const SoftMarginLossFuncOptions \u0026options = {})# 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 \u0026input, const Tensor \u0026target, const MultilabelSoftMarginLossFuncOptions \u0026options = {})# 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 \u0026anchor, const Tensor \u0026positive, const Tensor \u0026negative, const TripletMarginLossFuncOptions \u0026options = {})# 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 \u0026anchor, const Tensor \u0026positive, const Tensor \u0026negative, const TripletMarginWithDistanceLossFuncOptions \u0026options = {})# 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 \u0026log_probs, const Tensor \u0026targets, const Tensor \u0026input_lengths, const Tensor \u0026target_lengths, const CTCLossFuncOptions \u0026options = {})# 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 \u0026input, const Tensor \u0026target, const PoissonNLLLossFuncOptions \u0026options = {})# 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 \u0026x1, const Tensor \u0026x2, const CosineSimilarityFuncOptions \u0026options = {})# 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 \u0026x1, const Tensor \u0026x2, const PairwiseDistanceFuncOptions \u0026options = {})# 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 \u0026input, 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 \u0026input, const InterpolateFuncOptions \u0026options = {})# 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 \u0026theta, const IntArrayRef \u0026size, bool align_corners = false)# inline Tensor torch::nn::functional::grid_sample(const Tensor \u0026input, const Tensor \u0026grid, const GridSampleFuncOptions \u0026options = {})# 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 \u0026input, const PadFuncOptions \u0026options)# 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 \u0026input, const PixelShuffleFuncOptions \u0026options)# 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 \u0026input, const PixelUnshuffleFuncOptions \u0026options)# Fold/Unfold# inline Tensor torch::nn::functional::fold(const Tensor \u0026input, const FoldFuncOptions \u0026options)# 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 \u0026input, const UnfoldFuncOptions \u0026options)# 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 \u003cOperation\u003eFuncOptions. 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\u003c1\u003e# 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\u003c2\u003e# 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\u003c3\u003e# 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\u003c1\u003e# 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\u003c2\u003e# 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\u003c3\u003e# 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));",
"author": {
"@type": "Organization",
"name": "PyTorch Contributors",
"url": "https://pytorch.org"
},
"image": "https://pytorch.org/docs/stable/_static/img/pytorch_seo.png",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "/api/nn/functional.html"
},
"datePublished": "2023-01-01T00:00:00Z",
"dateModified": "2023-01-01T00:00:00Z"
}
| docsearch:language | en |
| llm:site-type | documentation |
| llm:framework | PyTorch |
| llm:description | Functional API in PyTorch C++ — torch::nn::functional stateless operations for neural networks. |
| llm:navigation-file | https://pytorch.org/docs/stable/llms.txt |
| llm:sitemap | https://pytorch.org/docs/stable/sitemap.xml |
| llm:version | main |
| llm:project | PyTorch |
| llm:page-type | documentation |
| og:image | https://docs.pytorch.org/docs/stable/_static/img/pytorch_seo.png |
| None | 3 |
Links:
Viewport: width=device-width, initial-scale=1