"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< VectorType, VectorType > | |
enum | Feature |
typedef VectorType | InputType |
Defines the input type of the model. More... | |
typedef VectorType | OutputType |
Defines the output type of the model. More... | |
typedef AbstractModel< VectorType, VectorType, RealVector > | ModelBaseType |
Defines the BaseType used by the model (this type). Useful for creating derived models. More... | |
typedef Batch< InputType >::type | BatchInputType |
defines the batch type of the input type. More... | |
typedef Batch< OutputType >::type | BatchOutputType |
defines the batch type of the output type More... | |
typedef TypedFlags< Feature > | Features |
typedef TypedFeatureNotAvailableException< Feature > | FeatureNotAvailableException |
Public Types inherited from shark::IParameterizable< RealVector > | |
typedef RealVector | ParameterVectorType |
Public Member Functions | |
Normalizer (std::size_t dimension=0, bool hasOffset=false) | |
Construction from dimension. More... | |
Normalizer (VectorType const &diagonal, VectorType const &offset=VectorType()) | |
Construction from matrix and and optional offset vector. More... | |
std::string | name () const |
From INameable: return the class name. More... | |
boost::shared_ptr< State > | createState () const |
derivative storage object (empty for this model) More... | |
bool | hasOffset () const |
check for the presence of an offset term More... | |
Shape | inputShape () const |
obtain the input dimension More... | |
Shape | outputShape () const |
obtain the output dimension More... | |
VectorType const & | diagonal () const |
return the diagonal of the matrix More... | |
VectorType const & | offset () const |
return the offset vector More... | |
VectorType | parameterVector () const |
obtain the parameter vector More... | |
void | setParameterVector (VectorType const &newParameters) |
overwrite the parameter vector More... | |
std::size_t | numberOfParameters () const |
return the number of parameter More... | |
void | setStructure (VectorType const &diagonal, VectorType const &offset=VectorType()) |
overwrite structure and parameters More... | |
void | setStructure (std::size_t dimension, bool hasOffset=false) |
overwrite structure and parameters More... | |
void | eval (BatchInputType const &input, BatchOutputType &output) const |
Evaluate the model: output = matrix * input + offset. More... | |
void | eval (BatchInputType const &input, BatchOutputType &output, State &state) const |
Evaluate the model: output = matrix * input + offset. More... | |
void | read (InArchive &archive) |
from ISerializable More... | |
void | write (OutArchive &archive) const |
from ISerializable More... | |
Public Member Functions inherited from shark::AbstractModel< VectorType, VectorType > | |
AbstractModel () | |
virtual | ~AbstractModel () |
const Features & | features () const |
virtual void | updateFeatures () |
bool | hasFirstParameterDerivative () const |
Returns true when the first parameter derivative is implemented. More... | |
bool | hasFirstInputDerivative () const |
Returns true when the first input derivative is implemented. More... | |
virtual void | eval (InputType const &pattern, OutputType &output) const |
Standard interface for evaluating the response of the model to a single pattern. More... | |
Data< OutputType > | operator() (Data< InputType > const &patterns) const |
Model evaluation as an operator for a whole dataset. This is a convenience function. More... | |
OutputType | operator() (InputType const &pattern) const |
Model evaluation as an operator for a single pattern. This is a convenience function. More... | |
BatchOutputType | operator() (BatchInputType const &patterns) const |
Model evaluation as an operator for a single pattern. This is a convenience function. More... | |
virtual void | weightedParameterDerivative (BatchInputType const &pattern, BatchOutputType const &outputs, BatchOutputType const &coefficients, State const &state, RealVector &derivative) const |
calculates the weighted sum of derivatives w.r.t the parameters. More... | |
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 More... | |
virtual void | weightedDerivatives (BatchInputType const &patterns, BatchOutputType const &outputs, BatchOutputType const &coefficients, State const &state, RealVector ¶meterDerivative, BatchInputType &inputDerivative) const |
calculates weighted input and parameter derivative at the same time More... | |
Public Member Functions inherited from shark::IParameterizable< RealVector > | |
virtual | ~IParameterizable () |
Public Member Functions inherited from shark::INameable | |
virtual | ~INameable () |
Public Member Functions inherited from shark::ISerializable | |
virtual | ~ISerializable () |
Virtual d'tor. More... | |
void | load (InArchive &archive, unsigned int version) |
Versioned loading of components, calls read(...). More... | |
void | save (OutArchive &archive, unsigned int version) const |
Versioned storing of components, calls write(...). More... | |
BOOST_SERIALIZATION_SPLIT_MEMBER () | |
Protected Attributes | |
VectorType | m_A |
matrix A (see class documentation) More... | |
VectorType | m_b |
vector b (see class documentation) More... | |
Protected Attributes inherited from shark::AbstractModel< VectorType, VectorType > | |
Features | m_features |
"Diagonal" linear model for data normalization.
Definition at line 57 of file Normalizer.h.
typedef base_type::BatchInputType shark::Normalizer< VectorType >::BatchInputType |
Definition at line 63 of file Normalizer.h.
typedef base_type::BatchOutputType shark::Normalizer< VectorType >::BatchOutputType |
Definition at line 64 of file Normalizer.h.
|
inline |
Construction from dimension.
Definition at line 67 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 71 of file Normalizer.h.
References shark::Normalizer< VectorType >::offset(), and shark::Normalizer< VectorType >::setStructure().
|
inlinevirtual |
derivative storage object (empty for this model)
Reimplemented from shark::AbstractModel< VectorType, VectorType >.
Definition at line 80 of file Normalizer.h.
|
inline |
return the diagonal of the matrix
Definition at line 100 of file Normalizer.h.
References shark::Normalizer< VectorType >::m_A.
Referenced by shark::Normalizer< VectorType >::setStructure().
|
inlinevirtual |
Evaluate the model: output = matrix * input + offset.
Reimplemented from shark::AbstractModel< VectorType, VectorType >.
Definition at line 142 of file Normalizer.h.
References shark::Normalizer< VectorType >::m_A, and SIZE_CHECK.
Referenced by shark::Normalizer< VectorType >::eval().
|
inlinevirtual |
Evaluate the model: output = matrix * input + offset.
Implements shark::AbstractModel< VectorType, VectorType >.
Definition at line 152 of file Normalizer.h.
References shark::Normalizer< VectorType >::eval().
|
inline |
check for the presence of an offset term
Definition at line 85 of file Normalizer.h.
References shark::Normalizer< VectorType >::m_b.
Referenced by shark::Normalizer< VectorType >::Normalizer(), and shark::Normalizer< VectorType >::setStructure().
|
inlinevirtual |
obtain the input dimension
Implements shark::AbstractModel< VectorType, VectorType >.
Definition at line 90 of file Normalizer.h.
References shark::Normalizer< VectorType >::m_A.
|
inlinevirtual |
From INameable: return the class name.
Reimplemented from shark::INameable.
Definition at line 76 of file Normalizer.h.
|
inlinevirtual |
return the number of parameter
Reimplemented from shark::IParameterizable< RealVector >.
Definition at line 123 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 105 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< VectorType, VectorType >.
Definition at line 95 of file Normalizer.h.
References shark::Normalizer< VectorType >::m_A.
|
inlinevirtual |
obtain the parameter vector
Reimplemented from shark::IParameterizable< RealVector >.
Definition at line 110 of file Normalizer.h.
References shark::Normalizer< VectorType >::m_A, and shark::Normalizer< VectorType >::m_b.
|
inlinevirtual |
from ISerializable
Reimplemented from shark::AbstractModel< VectorType, VectorType >.
Definition at line 157 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< RealVector >.
Definition at line 115 of file Normalizer.h.
References shark::Normalizer< VectorType >::m_A, shark::Normalizer< VectorType >::numberOfParameters(), and SIZE_CHECK.
|
inline |
overwrite structure and parameters
Definition at line 128 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(), and shark::NormalizeComponentsUnitVariance< DataType >::train().
|
inline |
overwrite structure and parameters
Definition at line 134 of file Normalizer.h.
References shark::AbstractModel< VectorType, VectorType, VectorType >::eval(), shark::Normalizer< VectorType >::hasOffset(), shark::Normalizer< VectorType >::m_A, and shark::Normalizer< VectorType >::m_b.
|
inlinevirtual |
from ISerializable
Reimplemented from shark::AbstractModel< VectorType, VectorType >.
Definition at line 163 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 169 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(), and shark::Normalizer< VectorType >::write().
|
protected |
vector b (see class documentation)
Definition at line 170 of file Normalizer.h.
Referenced by shark::Normalizer< VectorType >::hasOffset(), shark::Normalizer< VectorType >::numberOfParameters(), shark::Normalizer< VectorType >::offset(), shark::Normalizer< VectorType >::parameterVector(), shark::Normalizer< VectorType >::read(), shark::Normalizer< VectorType >::setStructure(), and shark::Normalizer< VectorType >::write().