Program Listing for File loss.h¶
↰ Return to documentation for file (torch/csrc/api/include/torch/nn/options/loss.h
)
#pragma once
#include <torch/arg.h>
#include <torch/csrc/Export.h>
#include <torch/enum.h>
#include <torch/types.h>
namespace torch {
namespace nn {
struct TORCH_API L1LossOptions {
typedef c10::variant<enumtype::kNone, enumtype::kMean, enumtype::kSum>
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 c10::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 c10::variant<enumtype::kNone, enumtype::kMean, enumtype::kSum>
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 c10::variant<enumtype::kNone, enumtype::kMean, enumtype::kSum>
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 c10::variant<enumtype::kNone, enumtype::kMean, enumtype::kSum>
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 c10::variant<enumtype::kNone, enumtype::kMean, enumtype::kSum>
reduction_t;
TORCH_ARG(int64_t, p) = 1;
TORCH_ARG(double, margin) = 1.0;
TORCH_ARG(Tensor, weight) = Tensor();
TORCH_ARG(reduction_t, reduction) = torch::kMean;
};
namespace functional {
using MultiMarginLossFuncOptions = MultiMarginLossOptions;
} // namespace functional
// ============================================================================
struct TORCH_API CosineEmbeddingLossOptions {
typedef c10::variant<enumtype::kNone, enumtype::kMean, enumtype::kSum>
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 c10::variant<enumtype::kNone, enumtype::kMean, enumtype::kSum>
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 c10::variant<enumtype::kNone, enumtype::kMean, enumtype::kSum>
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 c10::variant<enumtype::kNone, enumtype::kMean, enumtype::kSum>
reduction_t;
TORCH_ARG(Tensor, weight) = Tensor();
TORCH_ARG(reduction_t, reduction) = torch::kMean;
};
namespace functional {
using MultilabelSoftMarginLossFuncOptions = MultiLabelSoftMarginLossOptions;
} // namespace functional
// ============================================================================
struct TORCH_API TripletMarginLossOptions {
typedef c10::variant<enumtype::kNone, enumtype::kMean, enumtype::kSum>
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 c10::variant<enumtype::kNone, enumtype::kMean, enumtype::kSum>
reduction_t;
typedef std::function<Tensor(const Tensor&, const Tensor&)>
distance_function_t;
TORCH_ARG(c10::optional<distance_function_t>, distance_function) =
c10::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 c10::variant<enumtype::kNone, enumtype::kMean, enumtype::kSum>
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 c10::variant<enumtype::kNone, enumtype::kMean, enumtype::kSum>
reduction_t;
TORCH_OPTIONS_CTOR_VARIANT_ARG3(
SmoothL1LossOptions,
reduction,
kNone,
kMean,
kSum)
TORCH_ARG(reduction_t, reduction) = torch::kMean;
TORCH_ARG(double, beta) = 1.0;
};
namespace functional {
using SmoothL1LossFuncOptions = SmoothL1LossOptions;
} // namespace functional
// ============================================================================
struct TORCH_API HuberLossOptions {
typedef c10::variant<enumtype::kNone, enumtype::kMean, enumtype::kSum>
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 c10::variant<enumtype::kNone, enumtype::kMean, enumtype::kSum>
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 c10::variant<enumtype::kNone, enumtype::kMean, enumtype::kSum>
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 c10::variant<enumtype::kNone, enumtype::kMean, enumtype::kSum>
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 c10::variant<enumtype::kNone, enumtype::kMean, enumtype::kSum>
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 c10::variant<enumtype::kNone, enumtype::kMean, enumtype::kSum>
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 nn
} // namespace torch