23 #ifndef SRC_ENCODERS_UINTMATRIXENCODER_HPP_
24 #define SRC_ENCODERS_UINTMATRIXENCODER_HPP_
28 #include <logger/Log.hpp>
44 template<
typename T =
float>
69 unsigned int index = (*sample_);
72 LOG(LERROR) <<
"The SDR is too short for proper encoding of "<<index<<
"!";
85 assert(sdr_->cols() == 1);
89 float max_value = sdr_->maxCoeff(&maxRow, &maxCol);
90 LOG(LDEBUG) <<
"(maxRow, maxCol) = max_value [ (" << maxRow <<
"," << maxCol <<
") = " << max_value <<
"]";
93 unsigned int decoded = maxRow;
95 return std::make_shared<unsigned int>(decoded);
Encoder responsible for encoding unsigned integers into Matrix SDRs. A 1-of-k encoder, i.e. it simply turns on the adequate, i.e. there is no learning.
Abstract parent class for all encoders using MatrixXf as SDR datatype.
~UIntMatrixEncoder()
Default destructor - empty.
virtual std::shared_ptr< unsigned int > decodeSample(const mic::types::MatrixPtr< T > &sdr_)
size_t sdr_length
Length of SDR.
typename std::shared_ptr< mic::types::Matrix< T > > MatrixPtr
Typedef for a shared pointer to template-typed dynamic matrices.
virtual mic::types::MatrixPtr< T > encodeSample(const std::shared_ptr< unsigned int > &sample_)
Method responsible for encoding of input data sample into SDR (a vector of floats).
UIntMatrixEncoder(size_t sdr_length_)
Template-typed Matrix of dynamic size. Uses OpenBLAS if found by CMAKE - overloaded, specializations of * operator for types: float, double.