Loss function interface. More...
#include <shark/ObjectiveFunctions/Loss/AbstractLoss.h>
Public Types | |
typedef OutputT | OutputType |
typedef LabelT | LabelType |
typedef RealMatrix | MatrixType |
typedef Batch< OutputType >::type | BatchOutputType |
typedef Batch< LabelType >::type | BatchLabelType |
typedef ConstProxyReference< LabelType const >::type | ConstLabelReference |
Const references to LabelType. More... | |
typedef ConstProxyReference< OutputType const >::type | ConstOutputReference |
Const references to OutputType. More... | |
Public Types inherited from shark::AbstractCost< LabelT, OutputT > | |
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 (ConstLabelReference target, ConstOutputReference prediction) const |
evaluate the loss for a target and a prediction More... | |
virtual double | evalDerivative (ConstLabelReference target, ConstOutputReference prediction, OutputType &gradient) const |
evaluate the loss and its derivative for a target and a prediction More... | |
virtual double | evalDerivative (ConstLabelReference target, ConstOutputReference 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 |
Public Member Functions inherited from shark::AbstractCost< LabelT, OutputT > | |
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 |
Public Member Functions inherited from shark::INameable | |
virtual | ~INameable () |
virtual std::string | name () const |
returns the name of the object More... | |
Additional Inherited Members | |
Protected Attributes inherited from shark::AbstractCost< LabelT, OutputT > | |
Features | m_features |
Loss function interface.
Definition at line 59 of file AbstractLoss.h.
typedef Batch<LabelType>::type shark::AbstractLoss< LabelT, OutputT >::BatchLabelType |
Definition at line 68 of file AbstractLoss.h.
typedef Batch<OutputType>::type shark::AbstractLoss< LabelT, OutputT >::BatchOutputType |
Definition at line 67 of file AbstractLoss.h.
typedef ConstProxyReference<LabelType const>::type shark::AbstractLoss< LabelT, OutputT >::ConstLabelReference |
Const references to LabelType.
Definition at line 71 of file AbstractLoss.h.
typedef ConstProxyReference<OutputType const>::type shark::AbstractLoss< LabelT, OutputT >::ConstOutputReference |
Const references to OutputType.
Definition at line 73 of file AbstractLoss.h.
typedef LabelT shark::AbstractLoss< LabelT, OutputT >::LabelType |
Definition at line 64 of file AbstractLoss.h.
typedef RealMatrix shark::AbstractLoss< LabelT, OutputT >::MatrixType |
Definition at line 65 of file AbstractLoss.h.
typedef OutputT shark::AbstractLoss< LabelT, OutputT >::OutputType |
Definition at line 63 of file AbstractLoss.h.
|
inline |
Definition at line 75 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(), 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::CrossEntropy.
Definition at line 89 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 166 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::CrossEntropy.
Definition at line 102 of file AbstractLoss.h.
Referenced by shark::AbstractLoss< unsigned int, RealVector >::evalDerivative().
|
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.
Definition at line 119 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 136 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 187 of file AbstractLoss.h.
|
inline |
Definition at line 190 of file AbstractLoss.h.