Programming a feed-forward neural network
Hi, I want to know which of two options is a standard when coding neural networks.
As I see it, I have two ways of making a network iterate through and finding the end result:
1) I set the inputs, and then run each layer consecutively: I run the input layer, which sets the inputs of the hidden layer, I run the hidden layer(s), which sets the inputs of the output layer, I run the output layer, and finally query the network to see what the final values of the output layer are.
2) I ask the output layer what it's values are. By asking any neuron what it's value is, it checks to see what it's inputs are, and thus asks the neurons below it what their values are. This trickles down to the input layer, at which point the input neurons give their answer and this is fed back up.
The first method seems more intuitive, and seems more realistic: each neuron is fed a value and this iterates up towards the top. The second method, however, is one that we used when designing virtual circuits in a college programming class, and seems perhaps to be a little more elegant. Also, it seems that it's easier to create free-form circuits this way.
Obviously, I think that both give the same final result(?), but it would be good to know if there is some standard, or reason to pick one over the other.
Thanks for any recommendations!
Maybe I misunderstood, but it sounds like the second would be more of a recursive function whereas the first is more easily written with iteration. If multiple output nodes recieve data from the same hidden or input node then that node may be queried more than once and you might end up with a classic duplicate branch/tree issue. You can work around that, but as a rule of thumb I try to avoid recursion when possible. Even if the second method isn't recursive wouldn't it still need to create a stack of some sort just to hold the paths as it works up the layers? You move up getting all the stuff you need and then have to move back down to get back to the output. I'd go with (and have gone with actually) the first method. It makes since and it doesn't have to use any extra space. If you implement them right I don't think there will be a significant time difference though.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement