Loss function interface. More...
#include <shark/ObjectiveFunctions/Loss/AbstractLoss.h>
Public Types | |
typedef OutputT | OutputType |
typedef LabelT | LabelType |
typedef VectorMatrixTraits< OutputType >::DenseMatrixType | MatrixType |
typedef Batch< OutputType >::type | BatchOutputType |
typedef Batch< LabelType >::type | BatchLabelType |
![]() | |
enum | Feature { HAS_FIRST_DERIVATIVE = 1, HAS_SECOND_DERIVATIVE = 2, IS_LOSS_FUNCTION = 4 } |
list of features a cost function can have More... | |
typedef OutputT | OutputType |
typedef LabelT | LabelType |
typedef Batch< OutputType >::type | BatchOutputType |
typedef Batch< LabelType >::type | BatchLabelType |
typedef TypedFlags< Feature > | Features |
typedef TypedFeatureNotAvailableException< Feature > | FeatureNotAvailableException |
Public Member Functions | |
AbstractLoss () | |
virtual double | eval (BatchLabelType const &target, BatchOutputType const &prediction) const =0 |
evaluate the loss for a batch of targets and a prediction More... | |
virtual double | eval (LabelType const &target, OutputType const &prediction) const |
evaluate the loss for a target and a prediction More... | |
virtual double | evalDerivative (LabelType const &target, OutputType const &prediction, OutputType &gradient) const |
evaluate the loss and its derivative for a target and a prediction More... | |
virtual double | evalDerivative (LabelType const &target, OutputType const &prediction, OutputType &gradient, MatrixType &hessian) const |
evaluate the loss and its first and second derivative for a target and a prediction More... | |
virtual double | evalDerivative (BatchLabelType const &target, BatchOutputType const &prediction, BatchOutputType &gradient) const |
evaluate the loss and the derivative w.r.t. the prediction More... | |
double | eval (Data< LabelType > const &targets, Data< OutputType > const &predictions) const |
double | operator() (LabelType const &target, OutputType const &prediction) const |
evaluate the loss for a target and a prediction More... | |
double | operator() (BatchLabelType const &target, BatchOutputType const &prediction) const |
![]() | |
virtual | ~AbstractCost () |
const Features & | features () const |
virtual void | updateFeatures () |
bool | hasFirstDerivative () const |
returns true when the first parameter derivative is implemented More... | |
bool | isLossFunction () const |
returns true when the cost function is in fact a loss function More... | |
double | operator() (Data< LabelType > const &targets, Data< OutputType > const &predictions) const |
![]() | |
virtual | ~INameable () |
virtual std::string | name () const |
returns the name of the object More... | |
Additional Inherited Members | |
![]() | |
Features | m_features |
Loss function interface.
Definition at line 58 of file AbstractLoss.h.
typedef Batch<LabelType>::type shark::AbstractLoss< LabelT, OutputT >::BatchLabelType |
Definition at line 67 of file AbstractLoss.h.
typedef Batch<OutputType>::type shark::AbstractLoss< LabelT, OutputT >::BatchOutputType |
Definition at line 66 of file AbstractLoss.h.
typedef LabelT shark::AbstractLoss< LabelT, OutputT >::LabelType |
Definition at line 63 of file AbstractLoss.h.
typedef VectorMatrixTraits<OutputType>::DenseMatrixType shark::AbstractLoss< LabelT, OutputT >::MatrixType |
Definition at line 64 of file AbstractLoss.h.
typedef OutputT shark::AbstractLoss< LabelT, OutputT >::OutputType |
Definition at line 62 of file AbstractLoss.h.
|
inline |
Definition at line 69 of file AbstractLoss.h.
|
pure virtual |
evaluate the loss for a batch of targets and a prediction
target | target values |
prediction | predictions, typically made by a model |
Implemented in shark::SquaredLoss< Sequence, Sequence >, shark::ZeroOneLoss< unsigned int, RealVector >, shark::SquaredLoss< OutputType, unsigned int >, shark::AbsoluteLoss< VectorType >, shark::DiscreteLoss, shark::HingeLoss, shark::SquaredHingeLoss, shark::ZeroOneLoss< LabelType, OutputType >, shark::SquaredLoss< OutputType, LabelType >, shark::EpsilonHingeLoss, shark::SquaredEpsilonHingeLoss, shark::TukeyBiweightLoss, and shark::HuberLoss.
Referenced by shark::AbstractLoss< unsigned int, RealVector >::AbstractLoss(), shark::AbstractLoss< unsigned int, RealVector >::eval(), shark::LooError< ModelTypeT, LabelType >::eval(), and shark::AbstractLoss< unsigned int, RealVector >::operator()().
|
inlinevirtual |
evaluate the loss for a target and a prediction
target | target value |
prediction | prediction, typically made by a model |
Reimplemented in shark::CrossEntropyIndependent.
Definition at line 83 of file AbstractLoss.h.
|
inlinevirtual |
from AbstractCost
targets | target values |
predictions | predictions, typically made by a model |
Implements shark::AbstractCost< LabelT, OutputT >.
Definition at line 160 of file AbstractLoss.h.
|
inlinevirtual |
evaluate the loss and its derivative for a target and a prediction
target | target value |
prediction | prediction, typically made by a model |
gradient | the gradient of the loss function with respect to the prediction |
Reimplemented in shark::CrossEntropyIndependent.
Definition at line 96 of file AbstractLoss.h.
Referenced by shark::AbstractLoss< unsigned int, RealVector >::evalDerivative(), and shark::KernelSGDTrainer< InputType, CacheType >::train().
|
inlinevirtual |
evaluate the loss and its first and second derivative for a target and a prediction
target | target value |
prediction | prediction, typically made by a model |
gradient | the gradient of the loss function with respect to the prediction |
hessian | the hessian of the loss function with respect to the prediction |
Reimplemented in shark::CrossEntropy, and shark::CrossEntropyIndependent.
Definition at line 113 of file AbstractLoss.h.
|
inlinevirtual |
evaluate the loss and the derivative w.r.t. the prediction
target | target value |
prediction | prediction, typically made by a model |
gradient | the gradient of the loss function with respect to the prediction |
Reimplemented in shark::SquaredLoss< Sequence, Sequence >, shark::SquaredLoss< OutputType, unsigned int >, shark::HingeLoss, shark::SquaredHingeLoss, shark::TukeyBiweightLoss, shark::HuberLoss, shark::SquaredLoss< OutputType, LabelType >, shark::SquaredEpsilonHingeLoss, and shark::EpsilonHingeLoss.
Definition at line 130 of file AbstractLoss.h.
|
inline |
evaluate the loss for a target and a prediction
target | target value |
prediction | prediction, typically made by a model |
Definition at line 181 of file AbstractLoss.h.
|
inline |
Definition at line 184 of file AbstractLoss.h.