Struct CrossEntropyLossImpl#
Defined in File loss.h
Inheritance Relationships#
Base Type#
public torch::nn::Cloneable< CrossEntropyLossImpl >(Template Class Cloneable)
Struct Documentation#
-
struct CrossEntropyLossImpl : public torch::nn::Cloneable<CrossEntropyLossImpl>#
Creates a criterion that computes cross entropy loss between input and target.
See https://pytorch.org/docs/main/nn.html#torch.nn.CrossEntropyLoss to learn about the exact behavior of this module.
See the documentation for
torch::nn::CrossEntropyLossOptionsclass to learn what constructor arguments are supported for this module.Example:
CrossEntropyLoss model(CrossEntropyLossOptions().ignore_index(-100).reduction(torch::kMean));
Public Functions
-
explicit CrossEntropyLossImpl(CrossEntropyLossOptions options_ = {})#
-
virtual void reset() override#
reset()must perform initialization of all members with reference semantics, most importantly parameters, buffers and submodules.
-
virtual void pretty_print(std::ostream &stream) const override#
Pretty prints the
CrossEntropyLossmodule into the givenstream.
-
Tensor forward(const Tensor &input, const Tensor &target)#
Public Members
-
CrossEntropyLossOptions options#
The options with which this
Modulewas constructed.
-
Tensor weight#
A manual rescaling weight given to each class.
-
explicit CrossEntropyLossImpl(CrossEntropyLossOptions options_ = {})#