23 #include <boost/thread/thread.hpp>
24 #include <boost/bind.hpp>
32 #include <logger/Log.hpp>
33 #include <logger/ConsoleOutput.hpp>
34 using namespace mic::logger;
36 #include <application/ApplicationState.hpp>
48 int main(
int argc,
char* argv[]) {
50 LOGGER->addOutput(
new ConsoleOutput());
51 LOG(LINFO) <<
"Logger initialized. Starting application";
54 size_t sdr_size = 128;
55 size_t batch_size = 2;
62 importer.
setDataFilename(
"/Users/tkornut/Documents/workspace/machine-intelligence-core/data/txt/pl/ep-06-01-16-003.txt");
68 LOG(LINFO)<<
"There were " << importer.
classes() <<
" distinctive classes imported";
71 while (!APP_STATE->Quit()) {
74 if (!APP_STATE->isPaused()) {
77 if (APP_STATE->isSingleStepModeOn())
78 APP_STATE->pressPause();
84 std::shared_ptr<mic::types::MatrixXf> sdr = encoder.
encodeSample(sample.
data());
87 std::shared_ptr<char> dec_char = encoder.
decodeSample(sdr);
90 LOG(LINFO)<<
" Orig = '" << *(sample.
data()) <<
"' decoded SDR = '" << (*dec_char) <<
"' label = '" << *(sample.
label()) <<
"'";
94 LOG(LINFO)<<
" Batch: ";
95 for (
size_t i=0; i < batch.
size(); i++ ) {
96 LOG(LINFO)<<
" ["<<i<<
"] = '" << *(batch.
data(i)) <<
"'";
101 std::shared_ptr<mic::types::MatrixXf> batch_matrix = encoder.
encodeBatch(batch.
data());
102 LOG(LDEBUG)<<
" Batched matrix: ";
103 LOG(LDEBUG) << (*batch_matrix);
106 std::vector<std::shared_ptr<char> > decoded_batch = encoder.
decodeBatch(batch_matrix);
109 LOG(LINFO)<<
" Decoded batch: ";
110 for (
size_t i=0; i < decoded_batch.size(); i++ ) {
111 LOG(LINFO)<<
" ["<<i<<
"] = '" << *(decoded_batch[i]) <<
"'";
126 LOG(LINFO) <<
"Terminating application";
std::vector< std::shared_ptr< DataType > > & data()
Returns sample data.
void setBatchSize(size_t batch_size_)
int main(int argc, char *argv[])
Main program function - tests character importer and encoder.
mic::types::Batch< DataType, LabelType > getNextBatch()
virtual std::shared_ptr< char > decodeSample(const mic::types::MatrixXfPtr &sdr_)
void setDataFilename(std::string data_filename_)
virtual std::vector< std::shared_ptr< inputDataType > > decodeBatch(const std::shared_ptr< mic::types::Matrix< outputDataType > > &sdrs_)
Template class storing the data-label pairs. Additionally it stores the the index of the sample (main...
std::shared_ptr< LabelType > label() const
Returns the returns the sample label.
Encoder responsible for encoding character into Matrix SDRs. A 1-of-k encoder, i.e. it simply encodes char to ASCII and turns on that bit, i.e. there is no learning.
Importer responsible for importing/loading raw text files and returning characters one by one...
virtual mic::types::MatrixXfPtr encodeSample(const std::shared_ptr< char > &sample_)
Method responsible for encoding of input data sample into SDR (a vector of floats).
virtual std::shared_ptr< mic::types::Matrix< outputDataType > > encodeBatch(const std::vector< std::shared_ptr< inputDataType > > &batch_)
mic::types::Sample< DataType, LabelType > getRandomSample()
std::shared_ptr< DataType > data() const
Returns the sample data.