Shortcuts

Struct NLLLossImpl

Inheritance Relationships

Base Type

Struct Documentation

struct torch::nn::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/master/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

NLLLossImpl(const NLLLossOptions &options_ = {})
void pretty_print(std::ostream &stream) const override

Pretty prints the NLLLoss module into the given stream.

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.

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources