"Diagonal" linear model for data normalization. More...
#include <shark/Models/Normalizer.h>
Public Types | |
typedef base_type::BatchInputType | BatchInputType |
typedef base_type::BatchOutputType | BatchOutputType |
Public Types inherited from shark::AbstractModel< InputTypeT, OutputTypeT, ParameterVectorType > | |
enum | Feature { HAS_FIRST_PARAMETER_DERIVATIVE = 1 , HAS_FIRST_INPUT_DERIVATIVE = 4 } |
typedef InputTypeT | InputType |
Defines the input type of the model. | |
typedef OutputTypeT | OutputType |
Defines the output type of the model. | |
typedef AbstractModel< InputTypeT, OutputTypeT, ParameterVectorType > | ModelBaseType |
Defines the BaseType used by the model (this type). Useful for creating derived models. | |
typedef Batch< InputType >::type | BatchInputType |
defines the batch type of the input type. | |
typedef Batch< OutputType >::type | BatchOutputType |
defines the batch type of the output type | |
typedef TypedFlags< Feature > | Features |
typedef TypedFeatureNotAvailableException< Feature > | FeatureNotAvailableException |
Public Types inherited from shark::IParameterizable< VectorType > | |
typedef VectorType | ParameterVectorType |
Public Member Functions | |
Normalizer (std::size_t dimension=0, bool hasOffset=false) | |
Construction from dimension. | |
Normalizer (VectorType const &diagonal, VectorType const &offset=VectorType()) | |
Construction from matrix and and optional offset vector. | |
std::string | name () const |
From INameable: return the class name. | |
boost::shared_ptr< State > | createState () const |
derivative storage object (empty for this model) | |
bool | hasOffset () const |
check for the presence of an offset term | |
Shape | inputShape () const |
obtain the input dimension | |
Shape | outputShape () const |
obtain the output dimension | |
VectorType const & | diagonal () const |
return the diagonal of the matrix | |
VectorType const & | offset () const |
return the offset vector | |
VectorType | parameterVector () const |
obtain the parameter vector | |
void | setParameterVector (VectorType const &newParameters) |
overwrite the parameter vector | |
std::size_t | numberOfParameters () const |
return the number of parameter | |
void | setStructure (VectorType const &diagonal, VectorType const &offset=VectorType()) |
overwrite structure and parameters | |
void | setStructure (std::size_t dimension, bool hasOffset=false) |
overwrite structure and parameters | |
void | eval (BatchInputType const &input, BatchOutputType &output) const |
Evaluate the model: output = matrix * input + offset. | |
void | eval (BatchInputType const &input, BatchOutputType &output, State &state) const |
Evaluate the model: output = matrix * input + offset. | |
void | read (InArchive &archive) |
from ISerializable | |
void | write (OutArchive &archive) const |
from ISerializable | |
Public Member Functions inherited from shark::AbstractModel< InputTypeT, OutputTypeT, ParameterVectorType > | |
AbstractModel () | |
virtual | ~AbstractModel () |
const Features & | features () const |
virtual void | updateFeatures () |
bool | hasFirstParameterDerivative () const |
Returns true when the first parameter derivative is implemented. | |
bool | hasFirstInputDerivative () const |
Returns true when the first input derivative is implemented. | |
virtual void | eval (InputType const &pattern, OutputType &output) const |
Standard interface for evaluating the response of the model to a single pattern. | |
Data< OutputType > | operator() (Data< InputType > const &patterns) const |
Model evaluation as an operator for a whole dataset. This is a convenience function. | |
OutputType | operator() (InputType const &pattern) const |
Model evaluation as an operator for a single pattern. This is a convenience function. | |
BatchOutputType | operator() (BatchInputType const &patterns) const |
Model evaluation as an operator for a single pattern. This is a convenience function. | |
virtual void | weightedParameterDerivative (BatchInputType const &pattern, BatchOutputType const &outputs, BatchOutputType const &coefficients, State const &state, ParameterVectorType &derivative) const |
calculates the weighted sum of derivatives w.r.t the parameters. | |
virtual void | weightedInputDerivative (BatchInputType const &pattern, BatchOutputType const &outputs, BatchOutputType const &coefficients, State const &state, BatchInputType &derivative) const |
calculates the weighted sum of derivatives w.r.t the inputs | |
virtual void | weightedDerivatives (BatchInputType const &patterns, BatchOutputType const &outputs, BatchOutputType const &coefficients, State const &state, ParameterVectorType ¶meterDerivative, BatchInputType &inputDerivative) const |
calculates weighted input and parameter derivative at the same time | |
Public Member Functions inherited from shark::IParameterizable< VectorType > | |
virtual | ~IParameterizable () |
Public Member Functions inherited from shark::INameable | |
virtual | ~INameable () |
Public Member Functions inherited from shark::ISerializable | |
virtual | ~ISerializable () |
Virtual d'tor. | |
void | load (InArchive &archive, unsigned int version) |
Versioned loading of components, calls read(...). | |
void | save (OutArchive &archive, unsigned int version) const |
Versioned storing of components, calls write(...). | |
BOOST_SERIALIZATION_SPLIT_MEMBER () | |
Protected Attributes | |
VectorType | m_A |
matrix A (see class documentation) | |
VectorType | m_b |
vector b (see class documentation) | |
Protected Attributes inherited from shark::AbstractModel< InputTypeT, OutputTypeT, ParameterVectorType > | |
Features | m_features |
"Diagonal" linear model for data normalization.
Definition at line 59 of file Normalizer.h.
typedef base_type::BatchInputType shark::Normalizer< VectorType >::BatchInputType |
Definition at line 65 of file Normalizer.h.
typedef base_type::BatchOutputType shark::Normalizer< VectorType >::BatchOutputType |
Definition at line 66 of file Normalizer.h.
|
inline |
Construction from dimension.
Definition at line 69 of file Normalizer.h.
References shark::Normalizer< VectorType >::hasOffset(), and shark::Normalizer< VectorType >::setStructure().
|
inline |
Construction from matrix and and optional offset vector.
Definition at line 73 of file Normalizer.h.
References shark::Normalizer< VectorType >::diagonal(), shark::Normalizer< VectorType >::offset(), and shark::Normalizer< VectorType >::setStructure().
|
inlinevirtual |
derivative storage object (empty for this model)
Reimplemented from shark::AbstractModel< InputTypeT, OutputTypeT, ParameterVectorType >.
Definition at line 82 of file Normalizer.h.
|
inline |
return the diagonal of the matrix
Definition at line 102 of file Normalizer.h.
References shark::Normalizer< VectorType >::m_A.
Referenced by shark::Normalizer< VectorType >::Normalizer(), and shark::Normalizer< VectorType >::setStructure().
|
inlinevirtual |
Evaluate the model: output = matrix * input + offset.
Reimplemented from shark::AbstractModel< InputTypeT, OutputTypeT, ParameterVectorType >.
Definition at line 144 of file Normalizer.h.
References shark::Normalizer< VectorType >::hasOffset(), shark::Normalizer< VectorType >::m_A, shark::Normalizer< VectorType >::m_b, and SIZE_CHECK.
Referenced by shark::Normalizer< VectorType >::eval().
|
inlinevirtual |
Evaluate the model: output = matrix * input + offset.
Implements shark::AbstractModel< InputTypeT, OutputTypeT, ParameterVectorType >.
Definition at line 154 of file Normalizer.h.
References shark::Normalizer< VectorType >::eval().
|
inline |
check for the presence of an offset term
Definition at line 87 of file Normalizer.h.
References shark::Normalizer< VectorType >::m_b.
Referenced by shark::Normalizer< VectorType >::eval(), shark::Normalizer< VectorType >::Normalizer(), and shark::Normalizer< VectorType >::setStructure().
|
inlinevirtual |
obtain the input dimension
Implements shark::AbstractModel< InputTypeT, OutputTypeT, ParameterVectorType >.
Definition at line 92 of file Normalizer.h.
References shark::Normalizer< VectorType >::m_A, and shark::Shape::size().
|
inlinevirtual |
From INameable: return the class name.
Reimplemented from shark::INameable.
Definition at line 78 of file Normalizer.h.
|
inlinevirtual |
return the number of parameter
Reimplemented from shark::IParameterizable< VectorType >.
Definition at line 125 of file Normalizer.h.
References shark::Normalizer< VectorType >::m_A, and shark::Normalizer< VectorType >::m_b.
Referenced by shark::Normalizer< VectorType >::setParameterVector().
|
inline |
return the offset vector
Definition at line 107 of file Normalizer.h.
References shark::Normalizer< VectorType >::m_b.
Referenced by shark::Normalizer< VectorType >::Normalizer(), and shark::Normalizer< VectorType >::setStructure().
|
inlinevirtual |
obtain the output dimension
Implements shark::AbstractModel< InputTypeT, OutputTypeT, ParameterVectorType >.
Definition at line 97 of file Normalizer.h.
References shark::Normalizer< VectorType >::m_A, and shark::Shape::size().
|
inlinevirtual |
obtain the parameter vector
Reimplemented from shark::IParameterizable< VectorType >.
Definition at line 112 of file Normalizer.h.
References shark::Normalizer< VectorType >::m_A, and shark::Normalizer< VectorType >::m_b.
|
inlinevirtual |
from ISerializable
Reimplemented from shark::AbstractModel< InputTypeT, OutputTypeT, ParameterVectorType >.
Definition at line 159 of file Normalizer.h.
References shark::Normalizer< VectorType >::m_A, and shark::Normalizer< VectorType >::m_b.
|
inlinevirtual |
overwrite the parameter vector
Reimplemented from shark::IParameterizable< VectorType >.
Definition at line 117 of file Normalizer.h.
References shark::Normalizer< VectorType >::m_A, shark::Normalizer< VectorType >::m_b, shark::Normalizer< VectorType >::numberOfParameters(), and SIZE_CHECK.
|
inline |
overwrite structure and parameters
Definition at line 136 of file Normalizer.h.
References shark::Normalizer< VectorType >::hasOffset(), shark::Normalizer< VectorType >::m_A, and shark::Normalizer< VectorType >::m_b.
|
inline |
overwrite structure and parameters
Definition at line 130 of file Normalizer.h.
References shark::Normalizer< VectorType >::diagonal(), shark::Normalizer< VectorType >::m_A, shark::Normalizer< VectorType >::m_b, and shark::Normalizer< VectorType >::offset().
Referenced by shark::Normalizer< VectorType >::Normalizer(), shark::Normalizer< VectorType >::Normalizer(), shark::NormalizeComponentsUnitInterval< DataType >::train(), and shark::NormalizeComponentsUnitVariance< DataType >::train().
|
inlinevirtual |
from ISerializable
Reimplemented from shark::AbstractModel< InputTypeT, OutputTypeT, ParameterVectorType >.
Definition at line 165 of file Normalizer.h.
References shark::Normalizer< VectorType >::m_A, and shark::Normalizer< VectorType >::m_b.
|
protected |
matrix A (see class documentation)
Definition at line 171 of file Normalizer.h.
Referenced by shark::Normalizer< VectorType >::diagonal(), shark::Normalizer< VectorType >::eval(), shark::Normalizer< VectorType >::inputShape(), shark::Normalizer< VectorType >::numberOfParameters(), shark::Normalizer< VectorType >::outputShape(), shark::Normalizer< VectorType >::parameterVector(), shark::Normalizer< VectorType >::read(), shark::Normalizer< VectorType >::setParameterVector(), shark::Normalizer< VectorType >::setStructure(), shark::Normalizer< VectorType >::setStructure(), and shark::Normalizer< VectorType >::write().
|
protected |
vector b (see class documentation)
Definition at line 172 of file Normalizer.h.
Referenced by shark::Normalizer< VectorType >::eval(), shark::Normalizer< VectorType >::hasOffset(), shark::Normalizer< VectorType >::numberOfParameters(), shark::Normalizer< VectorType >::offset(), shark::Normalizer< VectorType >::parameterVector(), shark::Normalizer< VectorType >::read(), shark::Normalizer< VectorType >::setParameterVector(), shark::Normalizer< VectorType >::setStructure(), shark::Normalizer< VectorType >::setStructure(), and shark::Normalizer< VectorType >::write().