本文整理匯總了Golang中github.com/maxxk/neurgo.Cortex.NeuronLayerMap方法的典型用法代碼示例。如果您正苦於以下問題:Golang Cortex.NeuronLayerMap方法的具體用法?Golang Cortex.NeuronLayerMap怎麽用?Golang Cortex.NeuronLayerMap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/maxxk/neurgo.Cortex
的用法示例。
在下文中一共展示了Cortex.NeuronLayerMap方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: AddNeuronNonRecurrent
func AddNeuronNonRecurrent(cortex *ng.Cortex) (bool, MutateResult) {
numAttempts := len(cortex.AllNodeIds()) * 5
for i := 0; i < numAttempts; i++ {
nodeIdLayerMap := cortex.NodeIdLayerMap()
neuronLayerMap := cortex.NeuronLayerMap()
randomLayer := neuronLayerMap.ChooseRandomLayer()
upstreamNodeId := nodeIdLayerMap.ChooseNodeIdPrecedingLayer(randomLayer)
if upstreamNodeId == nil {
continue
}
downstreamNodeId := findDownstreamNodeId(cortex, nodeIdLayerMap, randomLayer)
if downstreamNodeId == nil {
continue
}
neuron := cortex.CreateNeuronInLayer(randomLayer)
neuronAddInlinkFrom(neuron, upstreamNodeId)
neuronAddOutlinkTo(neuron, downstreamNodeId)
return true, neuron
}
return false, nil
}
示例2: AddNeuronRecurrent
func AddNeuronRecurrent(cortex *ng.Cortex) (bool, MutateResult) {
numAttempts := len(cortex.AllNodeIds()) * 5
for i := 0; i < numAttempts; i++ {
nodeIdLayerMap := cortex.NodeIdLayerMap()
neuronLayerMap := cortex.NeuronLayerMap()
randomLayer := neuronLayerMap.ChooseRandomLayer()
inboundNodeId := findRecurrentInboundNodeId(cortex,
nodeIdLayerMap,
randomLayer)
if inboundNodeId == nil {
log.Printf("Warn: unable to find inbound node id")
continue
}
if randomLayer == inboundNodeId.LayerIndex {
continue
}
neuron := cortex.CreateNeuronInLayer(randomLayer)
outboundNodeId := findRecurrentOutboundNodeId(cortex,
nodeIdLayerMap,
randomLayer)
if outboundNodeId == nil {
log.Printf("Warn: unable to find outbound node id")
continue
}
neuronAddInlinkFrom(neuron, inboundNodeId)
neuronAddOutlinkTo(neuron, outboundNodeId)
return true, neuron
}
logg.LogTo("NEURVOLVE", "return false, nil")
return false, nil
}