Krotos Modules 3
Loading...
Searching...
No Matches
krotos::LinearModel Class Reference

class that infers linear model it supports multiple fully connected hidden layers and calculates multiple outputs focusing on classification It features an optional sigmoid and a relu activation function More...

#include <LinearModel.h>

Public Member Functions

 LinearModel (const std::vector< Eigen::MatrixXf > &weights, const std::vector< Eigen::VectorXf > &biases, const Eigen::MatrixXf &weightsOutput, const Eigen::VectorXf &biasOutput, const StringArray &categories)
 Constructor for the linear model this will be called to set manually the parametrs of the model.
 
 LinearModel ()
 Constructor for the linear model, this will automatically load a model that is expected to exist in the binary data.
 
Eigen::VectorXf infer (const Eigen::VectorXf &input)
 infers the model to predict output
 
Eigen::VectorXf inferSingle (const Eigen::VectorXf &input)
 
String getProminentCategory ()
 returns the prominent category name
 
StringArray getOutputCategories ()
 returns the output categories
 
void loadModelData ()
 

Private Member Functions

Eigen::VectorXf sigmoid (const Eigen::VectorXf &lOut)
 sigmoid activation function
 
Eigen::VectorXf relu (const Eigen::VectorXf &lOut)
 relu activation function
 

Private Attributes

std::vector< Eigen::MatrixXf > m_weights
 
Eigen::MatrixXf m_weightsOutput
 
std::vector< Eigen::VectorXf > m_bias
 
Eigen::VectorXf m_biasOutput
 
StringArray m_outputCategories
 
std::vector< Eigen::VectorXf > m_layerOutput
 
Eigen::VectorXf m_outputs
 
int m_numLayers {0}
 
int m_layerSize {0}
 
int m_outputSize {0}
 
var m_weightsVar
 
Eigen::VectorXf m_workingBuffer
 
int m_prominentCategoryIndex = {0}
 

Detailed Description

class that infers linear model it supports multiple fully connected hidden layers and calculates multiple outputs focusing on classification It features an optional sigmoid and a relu activation function

Constructor & Destructor Documentation

◆ LinearModel() [1/2]

krotos::LinearModel::LinearModel ( const std::vector< Eigen::MatrixXf > & weights,
const std::vector< Eigen::VectorXf > & biases,
const Eigen::MatrixXf & weightsOutput,
const Eigen::VectorXf & biasOutput,
const StringArray & categories )

Constructor for the linear model this will be called to set manually the parametrs of the model.

Parameters
wthe weights vector
blayer bias

◆ LinearModel() [2/2]

krotos::LinearModel::LinearModel ( )

Constructor for the linear model, this will automatically load a model that is expected to exist in the binary data.

Member Function Documentation

◆ getOutputCategories()

StringArray krotos::LinearModel::getOutputCategories ( )

returns the output categories

◆ getProminentCategory()

String krotos::LinearModel::getProminentCategory ( )

returns the prominent category name

◆ infer()

Eigen::VectorXf krotos::LinearModel::infer ( const Eigen::VectorXf & input)

infers the model to predict output

Parameters
inputthe input data to predict
Returns
output scores for each category

◆ inferSingle()

Eigen::VectorXf krotos::LinearModel::inferSingle ( const Eigen::VectorXf & input)

◆ loadModelData()

void krotos::LinearModel::loadModelData ( )

@rief loads the model data from binary data and sets up the relevant variables

◆ relu()

Eigen::VectorXf krotos::LinearModel::relu ( const Eigen::VectorXf & lOut)
private

relu activation function

◆ sigmoid()

Eigen::VectorXf krotos::LinearModel::sigmoid ( const Eigen::VectorXf & lOut)
private

sigmoid activation function

Member Data Documentation

◆ m_bias

std::vector<Eigen::VectorXf> krotos::LinearModel::m_bias
private

◆ m_biasOutput

Eigen::VectorXf krotos::LinearModel::m_biasOutput
private

◆ m_layerOutput

std::vector<Eigen::VectorXf> krotos::LinearModel::m_layerOutput
private

◆ m_layerSize

int krotos::LinearModel::m_layerSize {0}
private

◆ m_numLayers

int krotos::LinearModel::m_numLayers {0}
private

◆ m_outputCategories

StringArray krotos::LinearModel::m_outputCategories
private

◆ m_outputs

Eigen::VectorXf krotos::LinearModel::m_outputs
private

◆ m_outputSize

int krotos::LinearModel::m_outputSize {0}
private

◆ m_prominentCategoryIndex

int krotos::LinearModel::m_prominentCategoryIndex = {0}
private

◆ m_weights

std::vector<Eigen::MatrixXf> krotos::LinearModel::m_weights
private

◆ m_weightsOutput

Eigen::MatrixXf krotos::LinearModel::m_weightsOutput
private

◆ m_weightsVar

var krotos::LinearModel::m_weightsVar
private

◆ m_workingBuffer

Eigen::VectorXf krotos::LinearModel::m_workingBuffer
private

The documentation for this class was generated from the following files: