Introduction
This is a simple C++ template library of Extreme Learning Machine implemented by Shuo Jin.
In current version, basic ELM method is implemented in the library.
Date Structure:
Basic ELM: three types of activation functions are defined - Gaussian, sigmoid, and multi-quadric. More can be specified if necessary by following the template definition of activation function. Please refer to the comments in basic_elm.h for more information.
Example
#include "elm.h"
#include <random>
#define SAMPLENUMBER 20
#define INPUTDIM 3
#define TARGETDIM 2
int main()
{
elm::basic_elm<double, INPUTDIM, TARGETDIM> belm;
std::uniform_real_distribution<double> rand_generator(0.0, 1.0);
std::default_random_engine dre;
elm::elm_sample<double, INPUTDIM, TARGETDIM> samples[SAMPLENUMBER];
// generate random samples for testing
for (size_t i = 0; i < SAMPLENUMBER; ++i)
{
for (size_t j = 0; j < INPUTDIM; ++j)
{
samples[i].i_data[j] = rand_generator(dre);
}
for (size_t j = 0; j < TARGETDIM; ++j)
{
samples[i].t_data[j] = rand_generator(dre);
}
belm.add_sample(samples[i]);
samples[i].output_on_console();
}
// set the number of hidden nodes
belm.set_hidden_nodes_num(2 * SAMPLENUMBER);
// basic elm training
belm.train(0.0);
// output
for (size_t i = 0; i < SAMPLENUMBER; ++i)
{
elm::elm_sample<double, INPUTDIM, TARGETDIM> sample(samples[i]);
belm.predict(sample);
sample.output_on_console();
}
return 0;
}
Dependency
Eigen Library should be configured properly to use this template. You can specify the path at the beginning of elm_base.h
Download
The code is available here.
Reference