Struct NLLLossImpl¶
Defined in File loss.h
Page Contents
Inheritance Relationships¶
Base Type¶
public torch::nn::Cloneable< NLLLossImpl >
(Template Class Cloneable)
Struct Documentation¶
-
struct NLLLossImpl : public torch::nn::Cloneable<NLLLossImpl>¶
The negative log likelihood loss.
It is useful to train a classification problem with
C
classes. See https://pytorch.org/docs/main/nn.html#torch.nn.NLLLoss to learn about the exact behavior of this module.See the documentation for
torch::nn::NLLLossOptions
class to learn what constructor arguments are supported for this module.Example:
NLLLoss model(NLLLossOptions().ignore_index(-100).reduction(torch::kMean));
Public Functions
-
explicit NLLLossImpl(NLLLossOptions options_ = {})¶
-
virtual void pretty_print(std::ostream &stream) const override¶
Pretty prints the
NLLLoss
module into the givenstream
.
-
virtual void reset() override¶
reset()
must perform initialization of all members with reference semantics, most importantly parameters, buffers and submodules.
-
Tensor forward(const Tensor &input, const Tensor &target)¶
Public Members
-
NLLLossOptions options¶
The options with which this
Module
was constructed.
-
Tensor weight¶
A manual rescaling weight given to to each class.
-
explicit NLLLossImpl(NLLLossOptions options_ = {})¶