In order to train a neural network, we need a training set consisting of inputs and outputs of an underlying unknown function we want to approximate.
There are two ways to pass a data set to the neural network:
- You can arrange your data in matrices.
- You can subclass the abstract class OpenANN::DataSet and create an object of it.
Arranging data in matrices
using namespace OpenANN;
{
Eigen::MatrixXf
X = Eigen::MatrixXf::Random(N, D);
Eigen::MatrixXf
T = Eigen::MatrixXf::Random(N, F);
...
...
train(net,
"LMA", SSE, stop);
}
Subclassing OpenANN::DataSet
using namespace OpenANN;
{
public:
MyDataSet(...)
{
...
}
virtual MyDataSet()
{
...
}
virtual int samples()
{
}
virtual int inputs()
{
}
virtual int outputs()
{
}
virtual Eigen::VectorXd& getInstance(int i)
{
}
virtual Eigen::VectorXd& getTarget(int i);
{
}
virtual void finishIteration(
Learner& learner)
{
}
};
{
MyDataSet dataSet = ...;
...
...
train(net,
"LMA", SSE, stop);
}