public override void CreateNetwork() { Nodes = new NeuralNodeBase[NodeCount]; Links = new NeuralLink[LinkCount]; var curr = 0; for (var i = 0; i < NodeCounts[0]; i++) // Input layer nodes { Nodes[curr++] = new InputNode(); } FirstMiddleNode = curr; // Middle layer nodes for (var i = 1; i < NumLayers - 1; i++) { for (var j = 0; j < NodeCounts[i]; j++) { Nodes[curr++] = new BPMiddleNode(LearningRate, MomentumTerm); } } FirstOutputNode = curr; // Output layer nodes for (var i = 0; i < NodeCounts[NumLayers - 1]; i++) { Nodes[curr++] = new BPOutputNode(LearningRate, MomentumTerm); } for (var i = 0; i < LinkCount; i++) // Create Links { Links[i] = new BackPropagationLink(); } curr = 0; int layer1 = 0, layer2 = FirstMiddleNode; for (var i = 0; i < NumLayers - 1; i++) // Connect Layers { for (var j = 0; j < NodeCounts[i + 1]; j++) { for (var k = 0; k < NodeCounts[i]; k++) { Links[curr].InNode = Nodes[layer1 + k]; Links[curr].OutNode = Nodes[layer2 + j]; var link = Links[curr++]; var inNode = Nodes[layer1 + k]; var outNode = Nodes[layer2 + j]; inNode.OutLinks.Add(link); outNode.InLinks.Add(link); link.InNode = inNode; link.OutNode = outNode; } } layer1 = layer2; layer2 += NodeCounts[i + 1]; } }
protected override void createNetwork() { nodes = new NeuralNodeBase[nodeCount]; links = new NeuralLink[linkCount]; for (int i = 0; i < nodeCount - 2; i++) // Create Input Nodes { nodes[i] = new InputNode(); } nodes[nodeCount - 2] = new BiasNode(); // Create Bias Node nodes[nodeCount - 1] = new AdalineNode(learningRate); for (int i = 0; i < linkCount; i++) { AdalineLink l = new AdalineLink(nodes[i], nodes[nodeCount - 1]); // Create links //l.InNode = nodes[i]; //l.OutNode = nodes[nodeCount-1]; links[i] = l; } for (int i = 0; i < linkCount; i++) // Connect inputs to ADALINE { Link(nodes[i], nodes[nodeCount - 1], links[i]); } }
protected override void loadInputs() { // If network node has any input links, if (InLinks.Count > 0) // load the connected node's input values { for (int i = 0; i < InLinks.Count; i++) { NeuralLink link = InLinks[i]; setNodeValue(i, link.InNode.getNodeValue()); } } }
protected int OutputCount; // Number of Output Layer Nodes public override void CreateNetwork() { Nodes = new NeuralNodeBase[NodeCount]; Links = new NeuralLink[LinkCount]; for (var i = 0; i < InputCount; i++) // Create Input Nodes { Nodes[i] = new BAMInputNode(); } for (var i = InputCount; i < InputCount + OutputCount; i++) // Create Output Nodes { Nodes[i] = new BAMNode(); } for (var i = 0; i < LinkCount; i++) // Create links { Links[i] = new BAMLink(); } var currLink = 0; for (var i = 0; i < InputCount; i++) // Connect inputs to ADALINE { for (var j = InputCount; j < InputCount + OutputCount; j++) { Links[currLink].InNode = Nodes[i]; Links[currLink].OutNode = Nodes[j]; var inNode = Nodes[i]; var outNode = Nodes[j]; var link = Links[currLink++]; outNode.InLinks.Add(link); inNode.OutLinks.Add(link); link.InNode = inNode; link.OutNode = outNode; } } }