:github_url: https://github.com/pytorch/pytorch .. _program_listing_file_torch_csrc_api_include_torch_nn_options_loss.h: Program Listing for File loss.h =============================== |exhale_lsh| :ref:`Return to documentation for file ` (``torch/csrc/api/include/torch/nn/options/loss.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #pragma once #include #include #include #include namespace torch::nn { struct TORCH_API L1LossOptions { typedef std::variant reduction_t; TORCH_OPTIONS_CTOR_VARIANT_ARG3(L1LossOptions, reduction, kNone, kMean, kSum) TORCH_ARG(reduction_t, reduction) = torch::kMean; }; namespace functional { using L1LossFuncOptions = L1LossOptions; } // namespace functional // ============================================================================ struct TORCH_API KLDivLossOptions { typedef std::variant< enumtype::kNone, enumtype::kBatchMean, enumtype::kSum, enumtype::kMean> reduction_t; TORCH_OPTIONS_CTOR_VARIANT_ARG4( KLDivLossOptions, reduction, kNone, kBatchMean, kSum, kMean) TORCH_ARG(reduction_t, reduction) = torch::kMean; TORCH_ARG(bool, log_target) = false; }; namespace functional { using KLDivFuncOptions = KLDivLossOptions; } // namespace functional // ============================================================================ struct TORCH_API MSELossOptions { typedef std::variant reduction_t; TORCH_OPTIONS_CTOR_VARIANT_ARG3(MSELossOptions, reduction, kNone, kMean, kSum) TORCH_ARG(reduction_t, reduction) = torch::kMean; }; namespace functional { using MSELossFuncOptions = MSELossOptions; } // namespace functional // ============================================================================ struct TORCH_API BCELossOptions { typedef std::variant reduction_t; TORCH_ARG(Tensor, weight); TORCH_ARG(reduction_t, reduction) = torch::kMean; }; namespace functional { using BinaryCrossEntropyFuncOptions = BCELossOptions; } // namespace functional // ============================================================================ struct TORCH_API HingeEmbeddingLossOptions { typedef std::variant reduction_t; TORCH_ARG(double, margin) = 1.0; TORCH_ARG(reduction_t, reduction) = torch::kMean; }; namespace functional { using HingeEmbeddingLossFuncOptions = HingeEmbeddingLossOptions; } // namespace functional // ============================================================================ struct TORCH_API MultiMarginLossOptions { typedef std::variant reduction_t; TORCH_ARG(int64_t, p) = 1; TORCH_ARG(double, margin) = 1.0; TORCH_ARG(Tensor, weight); TORCH_ARG(reduction_t, reduction) = torch::kMean; }; namespace functional { using MultiMarginLossFuncOptions = MultiMarginLossOptions; } // namespace functional // ============================================================================ struct TORCH_API CosineEmbeddingLossOptions { typedef std::variant reduction_t; TORCH_ARG(double, margin) = 0.0; TORCH_ARG(reduction_t, reduction) = torch::kMean; }; namespace functional { using CosineEmbeddingLossFuncOptions = CosineEmbeddingLossOptions; } // namespace functional // ============================================================================ struct TORCH_API MultiLabelMarginLossOptions { typedef std::variant reduction_t; TORCH_OPTIONS_CTOR_VARIANT_ARG3( MultiLabelMarginLossOptions, reduction, kNone, kMean, kSum) TORCH_ARG(reduction_t, reduction) = torch::kMean; }; namespace functional { using MultilabelMarginLossFuncOptions = MultiLabelMarginLossOptions; } // namespace functional // ============================================================================ struct TORCH_API SoftMarginLossOptions { typedef std::variant reduction_t; TORCH_OPTIONS_CTOR_VARIANT_ARG3( SoftMarginLossOptions, reduction, kNone, kMean, kSum) TORCH_ARG(reduction_t, reduction) = torch::kMean; }; namespace functional { using SoftMarginLossFuncOptions = SoftMarginLossOptions; } // namespace functional // ============================================================================ struct TORCH_API MultiLabelSoftMarginLossOptions { typedef std::variant reduction_t; TORCH_ARG(Tensor, weight); TORCH_ARG(reduction_t, reduction) = torch::kMean; }; namespace functional { using MultilabelSoftMarginLossFuncOptions = MultiLabelSoftMarginLossOptions; } // namespace functional // ============================================================================ struct TORCH_API TripletMarginLossOptions { typedef std::variant reduction_t; TORCH_ARG(double, margin) = 1.0; TORCH_ARG(double, p) = 2.0; TORCH_ARG(double, eps) = 1e-6; TORCH_ARG(bool, swap) = false; TORCH_ARG(reduction_t, reduction) = torch::kMean; }; namespace functional { using TripletMarginLossFuncOptions = TripletMarginLossOptions; } // namespace functional // ============================================================================ struct TORCH_API TripletMarginWithDistanceLossOptions { typedef std::variant reduction_t; typedef std::function distance_function_t; TORCH_ARG(std::optional, distance_function) = std::nullopt; TORCH_ARG(double, margin) = 1.0; TORCH_ARG(bool, swap) = false; TORCH_ARG(reduction_t, reduction) = torch::kMean; }; namespace functional { using TripletMarginWithDistanceLossFuncOptions = TripletMarginWithDistanceLossOptions; } // namespace functional // ============================================================================ struct TORCH_API CTCLossOptions { typedef std::variant reduction_t; TORCH_ARG(int64_t, blank) = 0; TORCH_ARG(reduction_t, reduction) = torch::kMean; TORCH_ARG(bool, zero_infinity) = false; }; namespace functional { using CTCLossFuncOptions = CTCLossOptions; } // namespace functional // ============================================================================ struct TORCH_API SmoothL1LossOptions { typedef std::variant reduction_t; TORCH_OPTIONS_CTOR_VARIANT_ARG3( SmoothL1LossOptions, reduction, kNone, kMean, kSum) TORCH_ARG(reduction_t, reduction) = torch::kMean; TORCH_ARG(std::optional, beta) = std::nullopt; }; namespace functional { using SmoothL1LossFuncOptions = SmoothL1LossOptions; } // namespace functional // ============================================================================ struct TORCH_API HuberLossOptions { typedef std::variant reduction_t; TORCH_OPTIONS_CTOR_VARIANT_ARG3( HuberLossOptions, reduction, kNone, kMean, kSum) TORCH_ARG(reduction_t, reduction) = torch::kMean; TORCH_ARG(double, delta) = 1.0; }; namespace functional { using HuberLossFuncOptions = HuberLossOptions; } // namespace functional // ============================================================================ struct TORCH_API PoissonNLLLossOptions { typedef std::variant reduction_t; TORCH_ARG(bool, log_input) = true; TORCH_ARG(bool, full) = false; TORCH_ARG(double, eps) = 1e-8; TORCH_ARG(reduction_t, reduction) = torch::kMean; }; namespace functional { using PoissonNLLLossFuncOptions = PoissonNLLLossOptions; } // namespace functional // ============================================================================ struct TORCH_API MarginRankingLossOptions { typedef std::variant reduction_t; TORCH_ARG(double, margin) = 0; TORCH_ARG(reduction_t, reduction) = torch::kMean; }; namespace functional { using MarginRankingLossFuncOptions = MarginRankingLossOptions; } // namespace functional // ============================================================================ struct TORCH_API NLLLossOptions { typedef std::variant reduction_t; TORCH_ARG(Tensor, weight); TORCH_ARG(int64_t, ignore_index) = -100; TORCH_ARG(reduction_t, reduction) = torch::kMean; }; namespace functional { using NLLLossFuncOptions = NLLLossOptions; } // namespace functional // ============================================================================ struct TORCH_API CrossEntropyLossOptions { typedef std::variant reduction_t; TORCH_ARG(Tensor, weight); TORCH_ARG(int64_t, ignore_index) = -100; TORCH_ARG(reduction_t, reduction) = torch::kMean; TORCH_ARG(double, label_smoothing) = 0.0; }; namespace functional { using CrossEntropyFuncOptions = CrossEntropyLossOptions; } // namespace functional // ============================================================================ struct TORCH_API BCEWithLogitsLossOptions { typedef std::variant reduction_t; TORCH_ARG(Tensor, weight); TORCH_ARG(reduction_t, reduction) = torch::kMean; TORCH_ARG(Tensor, pos_weight); }; namespace functional { using BinaryCrossEntropyWithLogitsFuncOptions = BCEWithLogitsLossOptions; } // namespace functional } // namespace torch::nn