private WeightChangeTreeElement(bool isRoot, SlimRnnNeuronWithWeight neuronWithWeight, uint weightWithPropabilityTableIndex, WeightChangeTreeElement parent) { this.isRoot = isRoot; this.neuronWithWeight = neuronWithWeight; this.weightWithPropabilityTableIndex = weightWithPropabilityTableIndex; this.parent = parent; }
// called from the SLIM RNN if it reads a weight which was not jet used // we can here decide to change the weight and to which value we have to change it void ISlimRnnLearningAlgorithm.opportunityToAdjustWeight(SlimRnnNeuronWithWeight neuronWithWeight) { if (currentWeightChangeTreeElement == null) { // do nothing if the current weight change tree element is not set return; } Debug.Assert(!currentWeightChangeTreeElement.isRoot); // root node doesn't have any changed weights, so is invalid // do not add a new tree element if this connection was already added Tuple <uint, uint> connectionNeuronIndexTupleToCheck = new Tuple <uint, uint>( currentWeightChangeTreeElement.neuronWithWeight.source.neuronIndex, currentWeightChangeTreeElement.neuronWithWeight.target.neuronIndex); if (globalConnectionNeuronIndices.Contains(connectionNeuronIndexTupleToCheck)) { return; } // do not add a new tree element if this connection was already added as a children of the current tree element if (currentWeightChangeTreeElement.childrenConnectionNeuronIndices.Contains(connectionNeuronIndexTupleToCheck)) { return; } // add new tree elements for the connection createWeightChangeTreeElementsForConnectionAndAddToParent(neuronWithWeight, currentWeightChangeTreeElement); // add connection to global // commented because it seems to be wrong, because it is not undone by the depth-first search globalConnectionNeuronIndices.Add(connectionNeuronIndexTupleToCheck); }
public static WeightChangeTreeElement make(SlimRnnNeuronWithWeight neuronWithWeight, uint weightWithPropabilityTableIndex, WeightChangeTreeElement parent = null) { return(new WeightChangeTreeElement(false, neuronWithWeight, weightWithPropabilityTableIndex, parent)); }
IList <WeightChangeTreeElement> createWeightChangeTreeElementsForConnectionAndAddToParent(SlimRnnNeuronWithWeight connection, WeightChangeTreeElement parent) { IList <WeightChangeTreeElement> createdWeightChangeElements = new List <WeightChangeTreeElement>(weightWithPropabilityTable.Count); for ( uint weightWithPropabilityTableIndex = 0; weightWithPropabilityTableIndex < weightWithPropabilityTable.Count; weightWithPropabilityTableIndex++ ) { WeightChangeTreeElement createdWeightChangeTreeElement = WeightChangeTreeElement.make(connection, weightWithPropabilityTableIndex, parent); parent.children.Add(createdWeightChangeTreeElement); parent.childrenConnectionNeuronIndices.Add(new Tuple <uint, uint>(connection.source.neuronIndex, connection.target.neuronIndex)); createdWeightChangeElements.Add(createdWeightChangeTreeElement); } return(createdWeightChangeElements); }