"Diagonal" linear model for data normalization. More...
#include <shark/Models/Normalizer.h>
Public Types | |
typedef base_type::BatchInputType | BatchInputType |
typedef base_type::BatchOutputType | BatchOutputType |
![]() | |
enum | Feature |
typedef DataType | InputType |
Defines the input type of the model. More... | |
typedef DataType | OutputType |
Defines the output type of the model. 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 Member Functions | |
Normalizer () | |
Constructor of an invalid model; use setStructure later. More... | |
Normalizer (const self_type &model) | |
copy constructor More... | |
Normalizer (std::size_t dimension, bool hasOffset=false) | |
Construction from dimension. More... | |
Normalizer (RealVector diagonal) | |
Construction from matrix. More... | |
Normalizer (RealVector diagonal, RealVector vector) | |
Construction from matrix and vector. More... | |
std::string | name () const |
From INameable: return the class name. More... | |
const self_type | operator= (const self_type &model) |
assignment operator More... | |
boost::shared_ptr< State > | createState () const |
derivative storage object (empty for this model) More... | |
bool | isValid () const |
check if the model is properly initialized More... | |
bool | hasOffset () const |
check for the presence of an offset term More... | |
RealVector const & | diagonal () const |
return the diagonal of the matrix More... | |
RealVector const & | offset () const |
return the offset vector More... | |
std::size_t | inputSize () const |
obtain the input dimension More... | |
std::size_t | outputSize () const |
obtain the output dimension More... | |
RealVector | parameterVector () const |
obtain the parameter vector More... | |
void | setParameterVector (RealVector const &newParameters) |
overwrite the parameter vector More... | |
std::size_t | numberOfParameters () const |
return the number of parameter More... | |
void | setStructure (RealVector const &diagonal) |
overwrite structure and parameters More... | |
void | setStructure (std::size_t dimension, bool hasOffset=false) |
overwrite structure and parameters More... | |
void | setStructure (RealVector const &diagonal, RealVector const &offset) |
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... | |
![]() | |
AbstractModel () | |
virtual | ~AbstractModel () |
const Features & | features () const |
virtual void | updateFeatures () |
bool | hasFirstParameterDerivative () const |
Returns true when the first parameter derivative is implemented. More... | |
bool | hasSecondParameterDerivative () const |
Returns true when the second parameter derivative is implemented. More... | |
bool | hasFirstInputDerivative () const |
Returns true when the first input derivative is implemented. More... | |
bool | hasSecondInputDerivative () const |
Returns true when the second parameter derivative is implemented. More... | |
bool | isSequential () const |
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 &coefficients, State const &state, RealVector &derivative) const |
calculates the weighted sum of derivatives w.r.t the parameters. More... | |
virtual void | weightedParameterDerivative (BatchInputType const &pattern, BatchOutputType const &coefficients, Batch< RealMatrix >::type const &errorHessian, State const &state, RealVector &derivative, RealMatrix &hessian) const |
calculates the weighted sum of derivatives w.r.t the parameters More... | |
virtual void | weightedInputDerivative (BatchInputType const &pattern, BatchOutputType const &coefficients, State const &state, BatchInputType &derivative) const |
calculates the weighted sum of derivatives w.r.t the inputs More... | |
virtual void | weightedInputDerivative (BatchInputType const &pattern, BatchOutputType const &coefficients, typename Batch< RealMatrix >::type const &errorHessian, State const &state, RealMatrix &derivative, Batch< RealMatrix >::type &hessian) const |
calculates the weighted sum of derivatives w.r.t the inputs More... | |
virtual void | weightedDerivatives (BatchInputType const &patterns, BatchOutputType const &coefficients, State const &state, RealVector ¶meterDerivative, BatchInputType &inputDerivative) const |
calculates weighted input and parameter derivative at the same time More... | |
![]() | |
virtual | ~IParameterizable () |
![]() | |
virtual | ~INameable () |
![]() | |
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 | |
RealVector | m_A |
matrix A (see class documentation) More... | |
RealVector | m_b |
vector b (see class documentation) More... | |
bool | m_hasOffset |
if true: add offset therm b; if false: don't. More... | |
![]() | |
Features | m_features |
Friends | |
void | swap (const Normalizer &model1, const Normalizer &model2) |
swap More... | |
"Diagonal" linear model for data normalization.
Definition at line 57 of file Normalizer.h.
typedef base_type::BatchInputType shark::Normalizer< DataType >::BatchInputType |
Definition at line 63 of file Normalizer.h.
typedef base_type::BatchOutputType shark::Normalizer< DataType >::BatchOutputType |
Definition at line 64 of file Normalizer.h.
|
inline |
Constructor of an invalid model; use setStructure later.
Definition at line 67 of file Normalizer.h.
|
inline |
copy constructor
Definition at line 71 of file Normalizer.h.
|
inline |
Construction from dimension.
Definition at line 78 of file Normalizer.h.
|
inline |
Construction from matrix.
Definition at line 85 of file Normalizer.h.
|
inline |
Construction from matrix and vector.
Definition at line 91 of file Normalizer.h.
|
inlinevirtual |
derivative storage object (empty for this model)
Reimplemented from shark::AbstractModel< DataType, DataType >.
Definition at line 119 of file Normalizer.h.
|
inline |
return the diagonal of the matrix
Definition at line 138 of file Normalizer.h.
References shark::Normalizer< DataType >::isValid(), shark::Normalizer< DataType >::m_A, and SHARK_CHECK.
Referenced by shark::Normalizer< DataType >::setStructure().
|
inlinevirtual |
Evaluate the model: output = matrix * input + offset.
Reimplemented from shark::AbstractModel< DataType, DataType >.
Definition at line 235 of file Normalizer.h.
References shark::Normalizer< DataType >::hasOffset(), shark::Normalizer< DataType >::isValid(), shark::Normalizer< DataType >::m_A, shark::Normalizer< DataType >::m_b, shark::blas::noalias(), shark::blas::repeat(), and SHARK_CHECK.
Referenced by shark::Normalizer< DataType >::eval().
|
inlinevirtual |
Evaluate the model: output = matrix * input + offset.
Implements shark::AbstractModel< DataType, DataType >.
Definition at line 247 of file Normalizer.h.
References shark::Normalizer< DataType >::eval().
|
inline |
check for the presence of an offset term
Definition at line 132 of file Normalizer.h.
References shark::Normalizer< DataType >::m_hasOffset.
Referenced by shark::Normalizer< DataType >::eval(), shark::Normalizer< DataType >::parameterVector(), shark::Normalizer< DataType >::setParameterVector(), and shark::Normalizer< DataType >::setStructure().
|
inline |
obtain the input dimension
Definition at line 152 of file Normalizer.h.
References shark::Normalizer< DataType >::isValid(), shark::Normalizer< DataType >::m_A, and SHARK_CHECK.
|
inline |
check if the model is properly initialized
Definition at line 126 of file Normalizer.h.
References shark::Normalizer< DataType >::m_A.
Referenced by shark::Normalizer< DataType >::diagonal(), shark::Normalizer< DataType >::eval(), shark::Normalizer< DataType >::inputSize(), shark::Normalizer< DataType >::numberOfParameters(), shark::Normalizer< DataType >::offset(), shark::Normalizer< DataType >::outputSize(), shark::Normalizer< DataType >::parameterVector(), and shark::Normalizer< DataType >::setParameterVector().
|
inlinevirtual |
From INameable: return the class name.
Reimplemented from shark::INameable.
Definition at line 99 of file Normalizer.h.
|
inlinevirtual |
return the number of parameter
Reimplemented from shark::IParameterizable.
Definition at line 202 of file Normalizer.h.
References shark::Normalizer< DataType >::isValid(), shark::Normalizer< DataType >::m_A, shark::Normalizer< DataType >::m_b, shark::Normalizer< DataType >::m_hasOffset, and SHARK_CHECK.
|
inline |
return the offset vector
Definition at line 145 of file Normalizer.h.
References shark::Normalizer< DataType >::isValid(), shark::Normalizer< DataType >::m_b, and SHARK_CHECK.
Referenced by shark::Normalizer< DataType >::setStructure().
|
inline |
assignment operator
Definition at line 111 of file Normalizer.h.
References shark::Normalizer< DataType >::m_A, shark::Normalizer< DataType >::m_b, and shark::Normalizer< DataType >::m_hasOffset.
|
inline |
obtain the output dimension
Definition at line 159 of file Normalizer.h.
References shark::Normalizer< DataType >::isValid(), shark::Normalizer< DataType >::m_A, and SHARK_CHECK.
|
inlinevirtual |
obtain the parameter vector
Reimplemented from shark::IParameterizable.
Definition at line 166 of file Normalizer.h.
References shark::Normalizer< DataType >::hasOffset(), shark::blas::init(), shark::Normalizer< DataType >::isValid(), shark::Normalizer< DataType >::m_A, shark::Normalizer< DataType >::m_b, and SHARK_CHECK.
|
inlinevirtual |
from ISerializable
Reimplemented from shark::AbstractModel< DataType, DataType >.
Definition at line 253 of file Normalizer.h.
References shark::Normalizer< DataType >::m_A, shark::Normalizer< DataType >::m_b, and shark::Normalizer< DataType >::m_hasOffset.
|
inlinevirtual |
overwrite the parameter vector
Reimplemented from shark::IParameterizable.
Definition at line 185 of file Normalizer.h.
References shark::Normalizer< DataType >::hasOffset(), shark::blas::init(), shark::Normalizer< DataType >::isValid(), shark::Normalizer< DataType >::m_A, shark::Normalizer< DataType >::m_b, SHARK_CHECK, and SIZE_CHECK.
|
inline |
overwrite structure and parameters
Definition at line 209 of file Normalizer.h.
References shark::Normalizer< DataType >::diagonal(), shark::Normalizer< DataType >::m_A, and shark::Normalizer< DataType >::m_hasOffset.
Referenced by shark::NormalizeComponentsUnitInterval< DataType >::train(), and shark::NormalizeComponentsUnitVariance< DataType >::train().
|
inline |
overwrite structure and parameters
Definition at line 216 of file Normalizer.h.
References shark::Normalizer< DataType >::hasOffset(), shark::Normalizer< DataType >::m_A, shark::Normalizer< DataType >::m_b, and shark::Normalizer< DataType >::m_hasOffset.
|
inline |
overwrite structure and parameters
Definition at line 224 of file Normalizer.h.
References shark::Normalizer< DataType >::diagonal(), shark::AbstractModel< DataType, DataType >::eval(), shark::Normalizer< DataType >::m_A, shark::Normalizer< DataType >::m_b, shark::Normalizer< DataType >::m_hasOffset, shark::Normalizer< DataType >::offset(), and SHARK_CHECK.
|
inlinevirtual |
from ISerializable
Reimplemented from shark::AbstractModel< DataType, DataType >.
Definition at line 261 of file Normalizer.h.
References shark::Normalizer< DataType >::m_A, shark::Normalizer< DataType >::m_b, and shark::Normalizer< DataType >::m_hasOffset.
|
friend |
swap
Definition at line 103 of file Normalizer.h.
|
protected |
matrix A (see class documentation)
Definition at line 269 of file Normalizer.h.
Referenced by shark::Normalizer< DataType >::diagonal(), shark::Normalizer< DataType >::eval(), shark::Normalizer< DataType >::inputSize(), shark::Normalizer< DataType >::isValid(), shark::Normalizer< DataType >::numberOfParameters(), shark::Normalizer< DataType >::operator=(), shark::Normalizer< DataType >::outputSize(), shark::Normalizer< DataType >::parameterVector(), shark::Normalizer< DataType >::read(), shark::Normalizer< DataType >::setParameterVector(), shark::Normalizer< DataType >::setStructure(), and shark::Normalizer< DataType >::write().
|
protected |
vector b (see class documentation)
Definition at line 270 of file Normalizer.h.
Referenced by shark::Normalizer< DataType >::eval(), shark::Normalizer< DataType >::numberOfParameters(), shark::Normalizer< DataType >::offset(), shark::Normalizer< DataType >::operator=(), shark::Normalizer< DataType >::parameterVector(), shark::Normalizer< DataType >::read(), shark::Normalizer< DataType >::setParameterVector(), shark::Normalizer< DataType >::setStructure(), and shark::Normalizer< DataType >::write().
|
protected |
if true: add offset therm b; if false: don't.
Definition at line 271 of file Normalizer.h.
Referenced by shark::Normalizer< DataType >::hasOffset(), shark::Normalizer< DataType >::numberOfParameters(), shark::Normalizer< DataType >::operator=(), shark::Normalizer< DataType >::read(), shark::Normalizer< DataType >::setStructure(), and shark::Normalizer< DataType >::write().