Simple tutorial for MLP in C++

asked 2018-01-06 13:02:56 -0500

hirnfrei gravatar image


I try to use an MLP for a reinforcement learning. In all tutorials I found, they are used with pictures. But I need an MLP with other input data. Like position (x,y), rotation...

Is there an tutorial that explain a simple MLP? Or is anybody here how can help me?

edit retag flag offensive close merge delete


Using multi layer perceptron (MLP) artificial neural network (ANN) to solve for the XOR operation:

sjhalayka gravatar imagesjhalayka ( 2018-01-06 13:55:04 -0500 )edit

Sorry man. Is there no support for reinforcement learning in OpenCV?

sjhalayka gravatar imagesjhalayka ( 2018-01-06 14:55:37 -0500 )edit

@sjhalayka apologies for the previous grumpyness...

berak gravatar imageberak ( 2018-01-07 09:43:08 -0500 )edit

It's all good.

sjhalayka gravatar imagesjhalayka ( 2018-01-07 11:19:48 -0500 )edit

The link from berak shows what I try to do. But the code isnt C/C++ :(

What I try to do first is, convert a number to binar. For this one I take the code from the post os sjhalayka and modify them.

Is it possible to use this code to a MLP with one input and 10 output neurons so that they learn to convert?

At the moment I have change the input and output in the code. Input is a single neuron for the number, output is 10 neurons. I train the mlp with 100 random generated numbers for input and 100x10 calculated 0 or 1 for the output.

If I run the programm, all looks good but the results are wrong. There must be an problem. But I dont know how I can find it :(

I do that to become more experience with MLP.

hirnfrei gravatar imagehirnfrei ( 2018-01-07 14:14:51 -0500 )edit

Can you post your code in your question?

sjhalayka gravatar imagesjhalayka ( 2018-01-07 15:38:45 -0500 )edit
hirnfrei gravatar imagehirnfrei ( 2018-01-07 15:46:45 -0500 )edit

I solve the problem. But now I have a new question. Is it right that train() needs all trainingdata? If a mlp is trained, a new train() destroy all training before?

hirnfrei gravatar imagehirnfrei ( 2018-01-23 02:13:00 -0500 )edit

@hirnfrei no, you can set an update flag in the train() method, so it won't reinitialize the weights (and you can train it with small batches

berak gravatar imageberak ( 2018-01-23 02:50:14 -0500 )edit