Internal Wrappertype to connect the output of the first model with the input of the second model. More...
#include <shark/Models/ConcatenatedModel.h>
Inheritance diagram for shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >:
Collaboration diagram for shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >:Classes | |
| struct | InternalState |
Public Types | |
| typedef base_type::BatchInputType | BatchInputType |
| typedef base_type::BatchOutputType | BatchOutputType |
Public Member Functions | |
| ConcatenatedModelWrapper (AbstractModel< InputType, IntermediateType > *firstModel, AbstractModel< IntermediateType, OutputType > *secondModel) | |
| std::string | name () const |
| From INameable: return the class name. More... | |
| ConcatenatedModelWrapperBase < InputType, OutputType > * | clone () const |
| RealVector | parameterVector () const |
| Return the parameter vector. More... | |
| void | setParameterVector (RealVector const &newParameters) |
| Set the parameter vector. More... | |
| boost::shared_ptr< State > | createState () const |
| Creates an internal state of the model. More... | |
| std::size_t | numberOfParameters () const |
| Return the number of parameters. More... | |
| void | eval (BatchInputType const &patterns, BatchOutputType &outputs) const |
| Standard interface for evaluating the response of the model to a batch of patterns. More... | |
| void | eval (BatchInputType const &patterns, BatchOutputType &outputs, State &state) const |
| void | weightedParameterDerivative (BatchInputType const &patterns, BatchOutputType const &coefficients, State const &state, RealVector &gradient) const |
| void | weightedInputDerivative (BatchInputType const &patterns, BatchOutputType const &coefficients, State const &state, BatchOutputType &gradient) const |
| virtual void | weightedDerivatives (BatchInputType const &patterns, BatchOutputType const &coefficients, State const &state, RealVector ¶meterDerivative, BatchInputType &inputDerivative) const |
| void | read (InArchive &archive) |
| From ISerializable. More... | |
| void | write (OutArchive &archive) const |
| From ISerializable. More... | |
Protected Types | |
| typedef AbstractModel < InputType, IntermediateType > ::BatchOutputType | BatchIntermediateType |
Protected Attributes | |
| AbstractModel< InputType, IntermediateType > * | m_firstModel |
| AbstractModel < IntermediateType, OutputType > * | m_secondModel |
Internal Wrappertype to connect the output of the first model with the input of the second model.
This model is also created when concatenating two models with operator>> (firstModel>>secondModel)
Definition at line 64 of file ConcatenatedModel.h.
| typedef base_type::BatchInputType shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::BatchInputType |
Definition at line 77 of file ConcatenatedModel.h.
|
protected |
Definition at line 66 of file ConcatenatedModel.h.
| typedef base_type::BatchOutputType shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::BatchOutputType |
Definition at line 79 of file ConcatenatedModel.h.
|
inline |
Definition at line 80 of file ConcatenatedModel.h.
References shark::AbstractModel< InputType, OutputType >::HAS_FIRST_INPUT_DERIVATIVE, shark::AbstractModel< InputType, OutputType >::HAS_FIRST_PARAMETER_DERIVATIVE, shark::AbstractModel< InputTypeT, OutputTypeT >::hasFirstInputDerivative(), shark::AbstractModel< InputTypeT, OutputTypeT >::hasFirstParameterDerivative(), and shark::AbstractModel< InputType, OutputType >::m_features.
|
inlinevirtual |
Implements shark::detail::ConcatenatedModelWrapperBase< InputType, OutputType >.
Reimplemented in shark::detail::ConcatenatedModelList< InputType, IntermediateType, OutputType >.
Definition at line 114 of file ConcatenatedModel.h.
|
inlinevirtual |
Creates an internal state of the model.
The state is needed when the derivatives are to be calculated. Eval can store a state which is then reused to speed up the calculations of the derivatives. This also allows eval to be evaluated in parallel!
Reimplemented from shark::AbstractModel< InputType, OutputType >.
Definition at line 128 of file ConcatenatedModel.h.
References shark::AbstractModel< InputTypeT, OutputTypeT >::createState(), shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::InternalState::firstModelState, shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::m_firstModel, shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::m_secondModel, and shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::InternalState::secondModelState.
|
inlinevirtual |
Standard interface for evaluating the response of the model to a batch of patterns.
| patterns | the inputs of the model |
| outputs | the predictions or response of the model to every pattern |
Reimplemented from shark::AbstractModel< InputType, OutputType >.
Definition at line 140 of file ConcatenatedModel.h.
References shark::AbstractModel< InputTypeT, OutputTypeT >::eval(), shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::m_firstModel, and shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::m_secondModel.
|
inlinevirtual |
| patterns | Batch of input patterns over which derivative is computed |
| outputs | Outputs corresponding to input batch |
| state | Internal state (e.g., for passing to derivative computation) holding the internal states of the concatenated models |
Implements shark::AbstractModel< InputType, OutputType >.
Definition at line 150 of file ConcatenatedModel.h.
References shark::AbstractModel< InputTypeT, OutputTypeT >::eval(), shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::InternalState::firstModelState, shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::InternalState::intermediateResult, shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::m_firstModel, shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::m_secondModel, shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::InternalState::secondModelState, and shark::State::toState().
|
inlinevirtual |
From INameable: return the class name.
Reimplemented from shark::INameable.
Reimplemented in shark::detail::ConcatenatedModelList< InputType, IntermediateType, OutputType >.
Definition at line 111 of file ConcatenatedModel.h.
References shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::m_firstModel, shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::m_secondModel, and shark::INameable::name().
|
inlinevirtual |
Return the number of parameters.
Reimplemented from shark::IParameterizable.
Definition at line 136 of file ConcatenatedModel.h.
References shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::m_firstModel, shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::m_secondModel, and shark::IParameterizable::numberOfParameters().
Referenced by shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::parameterVector().
|
inlinevirtual |
Return the parameter vector.
Reimplemented from shark::IParameterizable.
Definition at line 118 of file ConcatenatedModel.h.
References shark::init(), shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::m_firstModel, shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::m_secondModel, shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::numberOfParameters(), and shark::parameters().
|
inlinevirtual |
From ISerializable.
Reimplemented from shark::AbstractModel< InputType, OutputType >.
Definition at line 221 of file ConcatenatedModel.h.
References shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::m_firstModel, shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::m_secondModel, and shark::AbstractModel< InputTypeT, OutputTypeT >::read().
|
inlinevirtual |
Set the parameter vector.
Reimplemented from shark::IParameterizable.
Definition at line 124 of file ConcatenatedModel.h.
References shark::init(), shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::m_firstModel, shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::m_secondModel, and shark::parameters().
|
inlinevirtual |
| patterns | Batch of input patterns over which derivative is computed |
| coefficients | Weights for weighted derivative |
| state | Internal state (e.g., for passing to derivative computation) holding the internal states of the concatenated models |
| parameterDerivative | Return value holding the derivatives w.r.t. the model parameters |
| inputDerivative | Return value holding the derivatives w.r.t. the input |
Reimplemented from shark::AbstractModel< InputType, OutputType >.
Definition at line 194 of file ConcatenatedModel.h.
References shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::InternalState::firstModelState, shark::init(), shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::InternalState::intermediateResult, shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::m_firstModel, shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::m_secondModel, shark::IParameterizable::numberOfParameters(), shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::InternalState::secondModelState, shark::State::toState(), and shark::AbstractModel< InputTypeT, OutputTypeT >::weightedDerivatives().
|
inline |
Definition at line 179 of file ConcatenatedModel.h.
References shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::InternalState::firstModelState, shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::InternalState::intermediateResult, shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::m_firstModel, shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::m_secondModel, shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::InternalState::secondModelState, shark::State::toState(), and shark::AbstractModel< InputTypeT, OutputTypeT >::weightedInputDerivative().
|
inlinevirtual |
| state | Internal state (usually returned from eval()) holding the internal states of the concatenated models |
Reimplemented from shark::AbstractModel< InputType, OutputType >.
Definition at line 157 of file ConcatenatedModel.h.
References shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::InternalState::firstModelState, shark::init(), shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::InternalState::intermediateResult, shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::m_firstModel, shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::m_secondModel, shark::IParameterizable::numberOfParameters(), shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::InternalState::secondModelState, shark::State::toState(), shark::AbstractModel< InputTypeT, OutputTypeT >::weightedDerivatives(), and shark::AbstractModel< InputTypeT, OutputTypeT >::weightedParameterDerivative().
|
inlinevirtual |
From ISerializable.
Reimplemented from shark::AbstractModel< InputType, OutputType >.
Definition at line 227 of file ConcatenatedModel.h.
References shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::m_firstModel, shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::m_secondModel, and shark::AbstractModel< InputTypeT, OutputTypeT >::write().
|
protected |
Definition at line 67 of file ConcatenatedModel.h.
Referenced by shark::detail::ConcatenatedModelList< InputType, IntermediateType, OutputType >::clone(), shark::detail::ConcatenatedModelList< InputType, IntermediateType, OutputType >::ConcatenatedModelList(), shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::createState(), shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::eval(), shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::name(), shark::detail::ConcatenatedModelList< InputType, IntermediateType, OutputType >::name(), shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::numberOfParameters(), shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::parameterVector(), shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::read(), shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::setParameterVector(), shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::weightedDerivatives(), shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::weightedInputDerivative(), shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::weightedParameterDerivative(), shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::write(), and shark::detail::ConcatenatedModelList< InputType, IntermediateType, OutputType >::~ConcatenatedModelList().
|
protected |
Definition at line 68 of file ConcatenatedModel.h.
Referenced by shark::detail::ConcatenatedModelList< InputType, IntermediateType, OutputType >::clone(), shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::createState(), shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::eval(), shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::name(), shark::detail::ConcatenatedModelList< InputType, IntermediateType, OutputType >::name(), shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::numberOfParameters(), shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::parameterVector(), shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::read(), shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::setParameterVector(), shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::weightedDerivatives(), shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::weightedInputDerivative(), shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::weightedParameterDerivative(), and shark::detail::ConcatenatedModelWrapper< InputType, IntermediateType, OutputType >::write().