public void createFromTopology() { neuralLayers = new NeuralLayer <T> [topology.LayerCount]; if (!topology.Verified) { topology.verify(); } NeuralNode <T> currentNode; TopologyEntry currentEntry; int currentLayer; for (int i = 0; i < topology.Count; i++) { currentEntry = topology.adj_M[i]; currentLayer = currentEntry.layer; if (neuralLayers[currentLayer] == null) { if (currentLayer == 0) { neuralLayers[currentLayer] = new InputLayer <T>(); } else { neuralLayers[currentLayer] = new NeuralLayer <T>(); } } if (topology.adj_M[i].layer == 0) { currentNode = new ConstInputNeuralNode <T>(); } else { if (topology.adj_M[i].memoryDepth > 0) { currentNode = new MemoryNode <T>(topology.adj_M[i].memoryDepth); } else { currentNode = new NeuralNode <T>(); } foreach (float w in currentEntry.adj_V) { if (!float.IsNaN(w)) { currentNode.InputWeigths.Add(w); } } } neuralLayers[currentLayer].addNode(currentNode); } for (int i = 1; i < topology.LayerCount; i++) { neuralLayers[i].inputLayer = neuralLayers[i - 1]; } }
public virtual object Clone() { var ret = new NeuralNode <T>(); ret.neuralFunction = neuralFunction; ret.weigthingFunction = weigthingFunction; ret.InputWeigths = InputWeigths.ToList(); ret.output = output; return(ret); }
public void setNode(int nodeIdx, NeuralNode <T> .NeuralFunction neuralFunction, NeuralNode <T> .WeigthingFunction weigthingFunction) { if (nodeIdx < NodeCount) { if (nodeIdx < 0) { foreach (NeuralNode <T> node in nodes) { node.setFunctions(neuralFunction, weigthingFunction); } } else { nodes[nodeIdx].setFunctions(neuralFunction, weigthingFunction); } } }
public void setLayerFunctions(int layerIdx, int nodeIdx, NeuralNode <T> .NeuralFunction neuralFunction, NeuralNode <T> .WeigthingFunction weigthingFunction) { if (layerIdx < 0) { foreach (NeuralLayer <T> layer in neuralLayers) { layer.setNode(nodeIdx, neuralFunction, weigthingFunction); } } else if (layerIdx < LayerCount) { neuralLayers[layerIdx].setNode(nodeIdx, neuralFunction, weigthingFunction); } else { throw new IndexOutOfRangeException(); } }
public void addNode(NeuralNode <T> node) { nodes.Add(node); verified = false; }
public void setNetworkFunctions(int layerIdx, int nodeIdx, NeuralNode <T> .NeuralFunction neuralFunction, NeuralNode <T> .WeigthingFunction weigthingFunction) { neuralNet.setLayerFunctions(layerIdx, nodeIdx, neuralFunction, weigthingFunction); }