0

I have trained a basic back-propagation neural network in R using a training data set and validated using a test set. The neural net is giving me satisfactory results.

Now what I want to do is to use this trained neural network (and the determined weights ) in a C++ code, so that I can put the input variables in the C++ code and it gives me the prediction output.

Most of the tutorial I find regarding the implementation of Neural Network in C++ is about training a network itself, and not really using for prediction.

How do I do this? I feel since the hard part(training the NN) is already done in R, implementing the NN in C++ shouldn't be very difficult. Maybe I'm missing some key concepts?

AKum
  • 3
  • 1
  • I'm not a ML expert, but I would assume you would need to export the trained network to some kind of file and load it back into C++. Obviously there is no native support for this so you would need a third party library or have to write your own parser – Tom Jul 31 '19 at 12:07
  • you may want to look into PMML (http://dmg.org/pmml/v4-4/GeneralStructure.html). In general it allows you to export ML models into a markup format which then can be used across different languages. This post might be helpful: https://stackoverflow.com/questions/30477094/how-to-use-a-pmml-model-in-c – jludewig Jul 31 '19 at 12:45

1 Answers1

0

When training an ANN:-

1) Present input pattern

2) Forward propagate to get the current ANNs answer

3) Compare the ANNs answer with the correct answer

4) Find the difference (error), and backprop the error to train the network.

When using a trained network, just do 1) & 2) and hope the ANNs answer is correct (!).

Pete D.
  • 165
  • 1
  • 12