Oh god I forgot those Learn classes.
In my code, the difference between hidden and and a output layers is the way the gradients are calculated, Also the output layer doesn't have connections or as i called it in my code 'Axons'
Each type of neuron needs different variables.
1 2 3 4 5 6
|
Output needs:
vector<axon> axons
double target
double out
double gradient
double WeightSum
|
Note: WeightSum is needed because the structure of my class and way of calculating an output. Since each layer may not be fully connected, i felt a need to include that variable
because i couldn't find a better solution for calculating output that way.
1 2 3
|
Input needs:
vector<axon> axons
double input
|
I am assuming that I could save memory by making different data types for different neurons.
The best way i could came up with is
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
struct dataone{
double a
double b
};
struct datatwo{
double a
};
class myclass
{
void *datax
myclass( int datatype )
{
switch(datatype)
{
case 1:
datax = new dataone();
break;
case 2:
datax = new datatwo();
break;
}
}
};
|
I knew existent of inheritance and polymorphism but i haven't used them ever
and also i don't really know how to apply them so that my data situation would be better,
Based on these examples:
http://www.tutorialspoint.com/cplusplus/cpp_inheritance.htm
http://www.cplusplus.com/doc/tutorial/polymorphism/
In my neural network class,
one neuron could be conneccted to a neuron what is further than one layer away.
It only makes sense when first neuron is connected to higher layer neuron.
I want to experiment few things.
I invented a memory neuron what works in followings:
Layer 0: input, memory1<target:input>, memory2<target:memory1>
the first feedforward with input being 1 would set their values followings:
layer 0: input<1>, memory1<1>, memory2<0>
second feedforward with input being 2:
layer 0: input<2>, memory1<2>, memory2<1>
First memory neuron always just copies the value.
The reason why first memory neuron just copies the current value and not having old value is cause i couln't work out the code for it to work.
About bias being in middle layer.
I think that each layers must or could have bias without going crazy like my network does
cause i had a network where all layers where fully connected and each layer having one bias.
( expect the last layer, cause it wouldn't make sense )
I debugged the gradients and everything, the way weight is calculated for last bias but
i think there might be something wrong with my model here:
http://www.upload.ee/image/5591007/1.png
While getting to calculate last bias weight then variables having the value they should have.
1 2
|
delta = 1.0 * eta * gradient + alpha * delta;
weight += delta;
|
Gradient will be output neuron's one, i tested and printed out values and it was how it should.
I think the output gradient is calculate the right way as well.
I'm lost, everything seems right in my code.
Removing the last bias makes everything work fine again but that bias needs to be there because what if i'm having a problem for a neural network where hidden layer needs bias?
Also i will be using something what will be pretty much randomly create neurons and layers and it would remove neurons or layers what doesn't seem to belong or in case something else is needed it is a random type of neuron and sees if it made it better.