43 return forward(predictions, targets);
61 explicit MSELoss(
const std::string& reduction =
"mean") : reduction_(reduction) {}
72 std::string reduction_;
89 explicit CrossEntropyLoss(
const std::string& reduction =
"mean") : reduction_(reduction) {}
100 std::string reduction_;
127 explicit BCELoss(
const std::string& reduction =
"mean") : reduction_(reduction) {}
138 std::string reduction_;
165 std::string reduction_;
182 explicit HingeLoss(
const std::string& reduction =
"mean") : reduction_(reduction) {}
193 std::string reduction_;
214 explicit HuberLoss(T delta = 1.0,
const std::string& reduction =
"mean")
215 : delta_(delta), reduction_(reduction) {}
227 std::string reduction_;
PyTorch-like automatic differentiation engine.
Base class for autograd-compatible loss functions.
Variable< T > operator()(const Variable< T > &predictions, const Variable< T > &targets)
Convenience operator for computing loss.
virtual ~AutogradLoss()=default
virtual Variable< T > forward(const Variable< T > &predictions, const Variable< T > &targets)=0
Compute loss between predictions and targets.
Binary Cross Entropy Loss with autograd support.
Variable< T > forward(const Variable< T > &predictions, const Variable< T > &targets) override
Forward pass: compute binary cross entropy loss.
BCELoss(const std::string &reduction="mean")
Constructor.
Binary Cross Entropy with Logits Loss.
BCEWithLogitsLoss(const std::string &reduction="mean")
Constructor.
Variable< T > forward(const Variable< T > &predictions, const Variable< T > &targets) override
Forward pass: compute BCE loss from logits.
Cross Entropy Loss with autograd support.
CrossEntropyLoss(const std::string &reduction="mean")
Constructor.
Variable< T > forward(const Variable< T > &predictions, const Variable< T > &targets) override
Forward pass: compute cross entropy loss.
Hinge Loss with autograd support.
HingeLoss(const std::string &reduction="mean")
Constructor.
Variable< T > forward(const Variable< T > &predictions, const Variable< T > &targets) override
Forward pass: compute hinge loss.
Huber Loss with autograd support.
Variable< T > forward(const Variable< T > &predictions, const Variable< T > &targets) override
Forward pass: compute Huber loss.
HuberLoss(T delta=1.0, const std::string &reduction="mean")
Constructor.
Mean Squared Error Loss with autograd support.
MSELoss(const std::string &reduction="mean")
Constructor.
Variable< T > forward(const Variable< T > &predictions, const Variable< T > &targets) override
Forward pass: compute MSE loss.
Variable class that supports automatic differentiation.
Matrix utility class for deep learning operations.