I'm having a crack at making a neural net again.
I'm feeding the dendrites of each Cell with the outputs of four axons below.
Basically each layer of Cells feeds a grid layer above it that measures half the width and half the height. So In order to feed the next layer I need a method for the section of brain (I've dubbed the class Lobe) to pass the info to the next layer.
The layer[i][j] array is simply a multi-dimensional array whose second dimension can be calculated as sq(2^i) (layer 0 = 1, layer 2 = 4, layer 3 = 16, etc.).
So far so good. I even managed to write in an equation to derive the layers from the logarithm of the base layer.
When it came to feeding the dendrites however I came a little unstuck. Each cell has the properties of id and layerSize - so I can determine rows and columns. But my final solution is really clunky:
Code:
void synapse(int i){
//read axons from layer i+1 and enter values into dendrites of layer i
for(int j = 0; j < layer[i].length; j++){
for(int k = 0; k < layer[i][j].dendrite.length; k++){
int r = layer[i][j].row();
int c = layer[i][j].column();
int nextLayerSize = int(sqrt(layer[i+1].length));
//int pos0 = (r*2)+((c*2)*nextLayerSize);
switch(k){
case 0:
layer[i][j].dendrite[k] = layer[i+1][(r*2)+((c*2)*nextLayerSize)].axon;
break;
case 1:
layer[i][j].dendrite[k] = layer[i+1][(r*2)+1+((c*2)*nextLayerSize)].axon;
break;
case 2:
layer[i][j].dendrite[k] = layer[i+1][(r*2)+((c*2)+1*nextLayerSize)].axon;
break;
case 3:
layer[i][j].dendrite[k] = layer[i+1][(r*2)+1+((c*2)+1*nextLayerSize)].axon;
break;
}
}
}
}
-update: whoops - shoulda tested the syntax - it works now
I'm pretty sure there's a shorthand equation for referencing those axons in the layer below with out having to do the longhand version of doubling up the rows and columns and using a switch to access each bit. I'm fine for testing of course - I'd just like some smooth equations instead of this booger code.
Anybody with a math education capable of helping me please?