32 #ifndef SHARK_MODELS_LINEARMODEL_H 33 #define SHARK_MODELS_LINEARMODEL_H 52 template <
class InputType = RealVector>
72 : m_matrix(outputs,inputs,0.0),m_offset(
offset?outputs:0,0.0){
78 :m_matrix(model.m_matrix),m_offset(model.m_offset){
85 {
return "LinearModel"; }
89 swap(model1.m_matrix,model2.m_matrix);
90 swap(model1.m_offset,model2.m_offset);
95 self_type tempModel(model);
96 swap(*
this,tempModel);
102 :m_matrix(matrix),m_offset(
offset){
109 return m_offset.size() != 0;
114 return m_matrix.size2();
119 return m_matrix.size1();
138 return m_matrix.size1()*m_matrix.size2()+m_offset.size();
171 return boost::shared_ptr<State>(
new EmptyState());
177 void eval(BatchInputType
const& inputs, BatchOutputType& outputs)
const{
178 outputs.resize(inputs.size1(),m_matrix.size1());
186 void eval(BatchInputType
const& inputs, BatchOutputType& outputs,
State& state)
const{
187 eval(inputs,outputs);
192 BatchInputType
const& patterns, RealMatrix
const& coefficients,
State const& state, RealVector& gradient
195 SIZE_CHECK(coefficients.size1()==patterns.size1());
207 std::size_t start = inputs*outputs;
213 BatchInputType
const & patterns,
214 BatchOutputType
const & coefficients,
216 BatchInputType& derivative
219 SIZE_CHECK(coefficients.size1() == patterns.size1());
221 derivative.resize(patterns.size1(),
inputSize());