Neural Nets in C++

Started by
10 comments, last by Athos 18 years, 10 months ago
Is there any good article out there witch has applied a neural net in c++ program code? I have heaps of truble of how i should structure up the program. And i have a relativ simpel net. 2 output neurons 4 inputs. donno if i even need a hidden layer. Any tips? any links please? when i serch for it i only get maths =/ Greetings Athos
-Truth is out there-
Advertisement
My latest ANN implementation in C++ is done using a matrix library. Inputs and outputs can thus be encoded as vectors and weights as a matrix. Since all operations can be expressed using vector and matrix operations, this can make the code rather clean.
Yes i have heard this too but but how?

i mean were to put each value? so it becomes correct?
And how to map it to the input values and output values?
How do you structure it within the ANN class?


I have the problem making a program of the theori.
=/

-Athos
-Truth is out there-
Start by creating the matrixes for your weights. For a common fully connected feed-forward net you create one matrix for each hidden or output layer. This is of size (m+1)*n where m is the number of nodes in layer i plus one for the bias, and n is the number of nodes in layer i+1. So if you create a net without a hidden layer such as you describe, the weight matrix would be a 5x2 matrix.

Then you create a vector from your input, adding a 1-input as the bias node at the end to get you a vector of size 5. Taking the transpose of this, you get a 1x5 matrix. Then you can multiply this by the weight matrix to get a 1x2 matrix which you can feed to the activation function for your output nodes. Each element of this transposed vector will be a sum of all the output*weights going in to a node.

Let your activation function produce a similar output vector and you can noe compare this to your target output (also a vector), and do error correction in a similar manner.

I hope this helped.
The tutorial's at my website have C++ implementations of feedforward ANNs and SOMs

(edited by Mod to clean up repeated text and include hyperlink)

[Edited by - Timkin on May 23, 2005 12:04:31 AM]
fup


struct SNeuronLayer{  //the number of neurons in this layer  int m_NumNeurons;   //the layer of neurons  vector<SNeuron> m_vecNeurons;   SNeuronLayer(int NumNeurons, int NumInputsPerNeuron);};


you havent written out SNeuronLayer funktion in your tutorial.
Just wondering how you think you should add static objects to the SNeuron Vector? Becouse i cant really see a good way to do this unless i make it a vector array of sneuron pointers.

Might be something to look into.

-Athos
-Truth is out there-
Athos: I haven't written out all the code because you can download it using the link at the beginning of the tutorial.

Also, the code is kept very simple since I want it to be as easy to understand as possible, not only to C++ programmers but to programmers of other languages. This is why I avoid using pointers and allocating heap memory. It's up to the reader to customize it to suit their own requirements.

Timkin: What duplicated text? (also the hyperlink to the tutorials was in my sig)
Thank you for fast replys.

If you are considering doing more on your site i would recomend maby hyperlinking funktions to were thay are explained so you have the option to look at it. But over all a good page.




-Truth is out there-
Quote:Timkin: What duplicated text? (also the hyperlink to the tutorials was in my sig)


Your original post looked like the following:

"The tutorial's at my website have C++ implementations of feedforward ANNThe tutorial's at my website have C++ implementations of feedforward ANNs and SOMs."


Quote:Your original post looked like the following:

"The tutorial's at my website have C++ implementations of feedforward ANNThe tutorial's at my website have C++ implementations of feedforward ANNs and SOMs."


ah! Weird. Cheers.

This topic is closed to new replies.

Advertisement