Struct BCEWithLogitsLossOptions

Page Contents

Struct Documentation

struct torch::nn::BCEWithLogitsLossOptions

Options for the BCEWithLogitsLoss module.


BCEWithLogitsLoss model(BCEWithLogitsLossOptions().reduction(torch::kNone).weight(weight));

Public Types

typedef c10::variant<enumtype::kNone, enumtype::kMean, enumtype::kSum> reduction_t

Public Functions

auto weight(const Tensor &new_weight) -> decltype(*this)

A manual rescaling weight given to the loss of each batch element.

If given, has to be a Tensor of size nbatch.

auto weight(Tensor &&new_weight) -> decltype(*this)
const Tensor &weight() const noexcept
Tensor &weight() noexcept
auto reduction(const reduction_t &new_reduction) -> decltype(*this)

Specifies the reduction to apply to the output. Default: Mean.

auto reduction(reduction_t &&new_reduction) -> decltype(*this)
const reduction_t &reduction() const noexcept
reduction_t &reduction() noexcept
auto pos_weight(const Tensor &new_pos_weight) -> decltype(*this)

A weight of positive examples.

Must be a vector with length equal to the number of classes.

auto pos_weight(Tensor &&new_pos_weight) -> decltype(*this)
const Tensor &pos_weight() const noexcept
Tensor &pos_weight() noexcept


Access comprehensive developer documentation for PyTorch

View Docs


Get in-depth tutorials for beginners and advanced developers

View Tutorials


Find development resources and get your questions answered

View Resources