1
votes

How can I apply a trained Matlab neural network from C++ without call to Matlab?. I think maybe it is possible read all the variable values of a trained network and export it to a file, then knowing the internal data processing of the neural network program a function in C++ can read all this data (the training result), and when a user introduces his test data, then the function gives an answer. The signature of the function could be something like:

double estimate_frequency(<neural_network_config_file>, <user_params>) {
    ...
    return frequency;
}

but all this without call any Matlab dll nor Matlab program. I think the evaluation process is simpler than the training process.

It is that possible?

Thanks!

1

1 Answers

3
votes

Of course it is possible - neural networks are clear mathematical models. All you need is a compatible representation, where you have stored:

  • network topology (number of neurons in particuluar layers)
  • network weights (between all neurons)
  • network activation functions (for each neuron)

And that's all. The exact solution depends on what matlab library you are using for neural networks. There is a "standard" for prediction models called PMML, which can be loaded by for example Weka libraries. Either way - it is easy operation, so you can also implement it by hand by simply storing all the numbers in the text file and simulating network in the C++ (as the "forward" phase of the neural network is just few lines of code - the training part is the long one).