public override void SetupOutputConnections(bool randomWeights = true) { base.SetupOutputConnections(randomWeights); List <ANNHiddenNode> nextLayer = network.GetHiddenNodesFromLayerOrder((int)ANNLayerOrders.HiddenBegin); if (nextLayer.Count == 0) { foreach (ANNOutputNode nextNode in network.OutputNodes) { ANNConnection con = new ANNConnection( randomWeights ? Random.Range(ANNProperties.RandomWeightsRange.x, ANNProperties.RandomWeightsRange.y) : ANNProperties.NonRandomWeightDefaultValue , this , nextNode , ConnectionType.FeedForward); con.OnEnable(); this.outputConnections.Add(con); nextNode.inputConnections.Add(con); } } else { foreach (ANNHiddenNode nextNode in nextLayer) { ANNConnection con = new ANNConnection( randomWeights ? Random.Range(ANNProperties.RandomWeightsRange.x, ANNProperties.RandomWeightsRange.y) : ANNProperties.NonRandomWeightDefaultValue , this , nextNode , ConnectionType.FeedForward); con.OnEnable(); this.outputConnections.Add(con); nextNode.inputConnections.Add(con); } } }
/// Methods /// public override void SetupOutputConnections(bool randomWeights = true) { base.SetupOutputConnections(randomWeights); if (layer < (int)ANNLayerOrders.HiddenBegin) { Debug.LogWarning(this.name + " => Trying to SetupOutputConnections(bool) but layerOrder is unknown"); return; } int nextLayerOrder = layer + 1; if (network.NHiddenLayers + (int)ANNLayerOrders.HiddenBegin == nextLayerOrder) { nextLayerOrder = (int)ANNLayerOrders.Output; List <ANNOutputNode> nextLayer = network.OutputNodes; foreach (ANNOutputNode nextNode in nextLayer) { ANNConnection con = new ANNConnection( randomWeights ? Random.Range(ANNProperties.RandomWeightsRange.x, ANNProperties.RandomWeightsRange.y) : ANNProperties.NonRandomWeightDefaultValue , this , nextNode , ConnectionType.FeedForward); con.OnEnable(); this.outputConnections.Add(con); nextNode.inputConnections.Add(con); } } else { List <ANNHiddenNode> nextLayer = network.GetHiddenNodesFromLayerOrder(nextLayerOrder); foreach (ANNHiddenNode nextNode in nextLayer) { ANNConnection con = new ANNConnection( randomWeights ? Random.Range(ANNProperties.RandomWeightsRange.x, ANNProperties.RandomWeightsRange.y) : ANNProperties.NonRandomWeightDefaultValue , this , nextNode , ConnectionType.FeedForward); con.OnEnable(); this.outputConnections.Add(con); nextNode.inputConnections.Add(con); } } }