Advertisement

When programming a ANN, do you just store the weights or...

Started by February 13, 2005 07:43 PM
6 comments, last by johnnyBravo 20 years ago
Hi, I'm learning about neural networks from the book "C++ Neural Networks and Fuzzy Logic by Valluru B. Rao". Anyway there was an example to program a hopefield network with 4 neurons. I thought I would program one to make sure i had a good understanding of the example. And when I made it I stored the weights in a 4 by 4 matrix. And then later on the author writes actually writes a program on the same example but instead of storing the weights in a matrix he makes a neuron class that stores 4 connections(including one to itself which is 0). So basically I was wondering what people usually do, do you store the weights in a matrix or inidvidually in a Neuron class? Thanks btw, if anyone's read this book, I think the author's c++ coding style is atrocious!
I prefer to have an actual Neuron class which stores weights of inputs. something like this is appropriate:

class Connection {public:   float weight;   Neuron * source;};class Neuron {private:   std::vector<Connection> inputs;   bool fireState;public:   Neuron(std::vector<Connection> &);   bool getState();   void processInput();   void addInput(Neuron *, float);   void dropInput(Neuron *);   void adjustWeight(Neuron *, float);};
(http://www.ironfroggy.com/)(http://www.ironfroggy.com/pinch)
Advertisement
actually I guess that makes alot more sense then just storing the weights in a matrix, because later on when I'm going to be doing feedforward etc networks, it isn't as simple as the hopfield network.

thx
In reply to the AP:
That is exactly why using a Neuron class is such a good idea. If you have reason to prefer grid-matrix later on, you can store matrices in a static matrix member of the class, and just rewrite the accesors to use the matrix, so none of the code actually using the Neurons needs to change.
(http://www.ironfroggy.com/)(http://www.ironfroggy.com/pinch)
All of these questions really boil down to what you want to get out of your neural network. Do you want it to be re-usable? Is performance important? Are you looking to solve a specific problem or just write a generic neural network library?

Some designs will be great for one set of needs but poor for another set of needs.
I guess right now Im just writing pretty much generic ANN's. So i may just go with the weights stored in the neuron class for now

This topic is closed to new replies.

Advertisement