diff --git a/axon/act-layer.go b/axon/act-layer.go index 1864d8a4..1d1d8edd 100644 --- a/axon/act-layer.go +++ b/axon/act-layer.go @@ -186,7 +186,7 @@ func (ly *LayerParams) GiFromSpikes(ctx *Context, ni, di uint32) { geExt := Neurons.Value(int(ni), int(di), int(GeExt)) PoolInhibRawIncrInt(pi, di, spk, geRaw, geExt) PoolAvgMaxUpdate(pi, di, ni) - if PoolsInt.Value(int(pi), int(PoolIsLayer), int(di)) == 0 { // also update layer pool if I am a subpool + if PoolsInt.Value(int(pi), int(di), int(PoolIsLayer)) == 0 { // also update layer pool if I am a subpool lpi := ly.PoolIndex(0) PoolInhibRawIncrInt(lpi, di, spk, geRaw, geExt) PoolAvgMaxUpdate(lpi, di, ni) @@ -204,12 +204,12 @@ func (ly *LayerParams) LayerGi(ctx *Context, li, di uint32) { // BetweenGi computes inhibition Gi between layers. func (ly *LayerParams) BetweenGi(ctx *Context, di uint32) { lpi := ly.PoolIndex(0) - maxGi := Pools.Value(int(lpi), int(fsfffb.TotalGi), int(di)) + maxGi := Pools.Value(int(lpi), int(di), int(fsfffb.TotalGi)) maxGi = ly.BetweenLayerGiMax(di, maxGi, ly.LayInhib.Index1) maxGi = ly.BetweenLayerGiMax(di, maxGi, ly.LayInhib.Index2) maxGi = ly.BetweenLayerGiMax(di, maxGi, ly.LayInhib.Index3) maxGi = ly.BetweenLayerGiMax(di, maxGi, ly.LayInhib.Index4) - Pools.Set(maxGi, int(lpi), int(fsfffb.TotalGi), int(di)) // our inhib is max of us and everyone in the layer pool + Pools.Set(maxGi, int(lpi), int(di), int(fsfffb.TotalGi)) // our inhib is max of us and everyone in the layer pool } // BetweenLayerGiMax returns max gi value for input maxGi vs @@ -220,7 +220,7 @@ func (ly *LayerParams) BetweenLayerGiMax(di uint32, maxGi float32, layIndex int3 } oly := GetLayers(uint32(layIndex)) opi := oly.PoolIndex(0) - ogi := Pools.Value(int(opi), int(fsfffb.TotalGi), int(di)) + ogi := Pools.Value(int(opi), int(di), int(fsfffb.TotalGi)) if ogi > maxGi { return ogi } @@ -230,7 +230,7 @@ func (ly *LayerParams) BetweenLayerGiMax(di uint32, maxGi float32, layIndex int3 // LayPoolGiFromSpikes computes inhibition Gi from Spikes for layer-level pool. func (ly *LayerParams) LayPoolGiFromSpikes(ctx *Context, lpi, di uint32) { PoolInhibSpikesFromRaw(lpi, di) - PoolInhib(&ly.Inhib.Layer, lpi, di, LayerStates.Value(int(ly.Index), int(LayerGiMult), int(di))) + PoolInhib(&ly.Inhib.Layer, lpi, di, LayerStates.Value(int(ly.Index), int(di), int(LayerGiMult))) } // SubPoolGiFromSpikes computes inhibition Gi from Spikes within a sub-pool @@ -239,9 +239,9 @@ func (ly *LayerParams) SubPoolGiFromSpikes(ctx *Context, lpi, pi, di uint32, lyI PoolInhibSpikesFromRaw(pi, di) PoolInhib(&ly.Inhib.Pool, pi, di, giMult) if lyInhib { - PoolInhibLayerMax(pi, di, Pools.Value(int(lpi), int(fsfffb.TotalGi), int(di))) // note: this requires lpl inhib to have been computed before! + PoolInhibLayerMax(pi, di, Pools.Value(int(lpi), int(di), int(fsfffb.TotalGi))) // note: this requires lpl inhib to have been computed before! } else { - PoolInhibPoolMax(pi, di, Pools.Value(int(pi), int(fsfffb.TotalGi), int(di))) // display only + PoolInhibPoolMax(pi, di, Pools.Value(int(pi), int(di), int(fsfffb.TotalGi))) // display only PoolInhibSaveOrig(lpi, di) // effective GiOrig } } @@ -294,7 +294,7 @@ func (ly *LayerParams) SpecialPreGs(ctx *Context, pi, ni, di uint32, drvGe float saveVal := float32(0) // sometimes we need to use a value computed here, for the post Gs step pil := pi - ly.PoolSt pnn := uint32(PoolNNeurons(pi)) - pni := NeuronIxs.Value(int(ni), int(NrnNeurIndex)) - uint32(PoolsInt.Value(int(pi), int(PoolNeurSt), int(di))) + pni := NeuronIxs.Value(int(ni), int(NrnNeurIndex)) - uint32(PoolsInt.Value(int(pi), int(di), int(PoolNeurSt))) nrnCtxtGe := Neurons.Value(int(ni), int(di), int(CtxtGe)) nrnGeRaw := Neurons.Value(int(ni), int(di), int(GeRaw)) hasRew := GlobalScalars.Value(int(GvHasRew), int(di)) > 0 @@ -488,9 +488,9 @@ func (ly *LayerParams) GFromRawSyn(ctx *Context, ni, di uint32) { // GiInteg adds Gi values from all sources including SubPool computed inhib // and updates GABAB as well func (ly *LayerParams) GiInteg(ctx *Context, pi, ni, di uint32) { - giMult := LayerStates.Value(int(ly.Index), int(LayerGiMult), int(di)) - gi := giMult*Pools.Value(int(pi), int(fsfffb.TotalGi), int(di)) + Neurons.Value(int(ni), int(di), int(GiSyn)) + Neurons.Value(int(ni), int(di), int(GiNoise)) + ly.Learn.NeuroMod.GiFromACh(GlobalScalars.Value(int(GvACh), int(di))) - ssgi := Pools.Value(int(pi), int(fsfffb.SSGi), int(di)) + giMult := LayerStates.Value(int(ly.Index), int(di), int(LayerGiMult)) + gi := giMult*Pools.Value(int(pi), int(di), int(fsfffb.TotalGi)) + Neurons.Value(int(ni), int(di), int(GiSyn)) + Neurons.Value(int(ni), int(di), int(GiNoise)) + ly.Learn.NeuroMod.GiFromACh(GlobalScalars.Value(int(GvACh), int(di))) + ssgi := Pools.Value(int(pi), int(di), int(fsfffb.SSGi)) Neurons.Set(gi, int(ni), int(di), int(Gi)) Neurons.Set(0.0, int(ni), int(di), int(SSGiDend)) if ctx.PlusPhase.IsTrue() && ly.Type == PulvinarLayer { @@ -570,7 +570,7 @@ func (ly *LayerParams) PostSpikeSpecial(ctx *Context, lpi, pi, ni, di uint32) { li := ly.Index pil := pi - ly.PoolSt // 0-n pool index pnn := uint32(PoolNNeurons(pi)) - pni := NeuronIxs.Value(int(ni), int(NrnNeurIndex)) - uint32(PoolsInt.Value(int(pi), int(PoolNeurSt), int(di))) + pni := NeuronIxs.Value(int(ni), int(NrnNeurIndex)) - uint32(PoolsInt.Value(int(pi), int(di), int(PoolNeurSt))) hasRew := GlobalScalars.Value(int(GvHasRew), int(di)) > 0 switch ly.Type { case SuperLayer: @@ -665,9 +665,9 @@ func (ly *LayerParams) PostSpikeSpecial(ctx *Context, lpi, pi, ni, di uint32) { // clipped linear Neurons.Set(ly.RWPred.PredRange.ClipValue(Neurons.Value(int(ni), int(di), int(Ge))), int(ni), int(di), int(Act)) if pni == 0 { - LayerStates.Set(Neurons.Value(int(ni), int(di), int(ActInt)), int(li), int(LayerRewPredPos), int(di)) + LayerStates.Set(Neurons.Value(int(ni), int(di), int(ActInt)), int(li), int(di), int(LayerRewPredPos)) } else { - LayerStates.Set(Neurons.Value(int(ni), int(di), int(ActInt)), int(li), int(LayerRewPredNeg), int(di)) + LayerStates.Set(Neurons.Value(int(ni), int(di), int(ActInt)), int(li), int(di), int(LayerRewPredNeg)) } case RWDaLayer: // I set this in CyclePost @@ -676,9 +676,9 @@ func (ly *LayerParams) PostSpikeSpecial(ctx *Context, lpi, pi, ni, di uint32) { // linear Neurons.Set(Neurons.Value(int(ni), int(di), int(Ge)), int(ni), int(di), int(Act)) if pni == 0 { - LayerStates.Set(Neurons.Value(int(ni), int(di), int(ActInt)), int(li), int(LayerRewPredPos), int(di)) + LayerStates.Set(Neurons.Value(int(ni), int(di), int(ActInt)), int(li), int(di), int(LayerRewPredPos)) } else { - LayerStates.Set(Neurons.Value(int(ni), int(di), int(ActInt)), int(li), int(LayerRewPredNeg), int(di)) + LayerStates.Set(Neurons.Value(int(ni), int(di), int(ActInt)), int(li), int(di), int(LayerRewPredNeg)) } case TDIntegLayer: Neurons.Set(GlobalScalars.Value(int(GvRewPred), int(di)), int(ni), int(di), int(Act)) @@ -748,8 +748,8 @@ func (ly *LayerParams) CyclePost(ctx *Context, di uint32) { func (ly *LayerParams) CyclePostLayer(ctx *Context, lpi, di uint32) { casp := PoolAvgMax(AMCaSpkP, AMCycle, Max, lpi, di) if ctx.Cycle >= ly.Acts.Dt.MaxCycStart && casp > 0.5 { // todo: param - if LayerStates.Value(int(ly.Index), int(LayerRT), int(di)) <= 0 { - LayerStates.Set(float32(ctx.Cycle), int(ly.Index), int(LayerRT), int(di)) + if LayerStates.Value(int(ly.Index), int(di), int(LayerRT)) <= 0 { + LayerStates.Set(float32(ctx.Cycle), int(ly.Index), int(di), int(LayerRT)) } } } @@ -781,7 +781,7 @@ func (ly *LayerParams) CyclePostLDTLayer(ctx *Context, di uint32, srcLay1Act, sr func (ly *LayerParams) CyclePostRWDaLayer(ctx *Context, di uint32) { pli := uint32(ly.RWDa.RWPredLayIndex) - pred := LayerStates.Value(int(pli), int(LayerRewPredPos), int(di)) - LayerStates.Value(int(pli), int(LayerRewPredNeg), int(di)) + pred := LayerStates.Value(int(pli), int(di), int(LayerRewPredPos)) - LayerStates.Value(int(pli), int(di), int(LayerRewPredNeg)) GlobalScalars.Set(pred, int(GvRewPred), int(di)) // record da := float32(0) if GlobalScalars.Value(int(GvHasRew), int(di)) > 0 { @@ -794,7 +794,7 @@ func (ly *LayerParams) CyclePostTDPredLayer(ctx *Context, di uint32) { if ctx.PlusPhase.IsFalse() { return } - pred := LayerStates.Value(int(ly.Index), int(LayerRewPredPos), int(di)) - LayerStates.Value(int(ly.Index), int(LayerRewPredNeg), int(di)) + pred := LayerStates.Value(int(ly.Index), int(di), int(LayerRewPredPos)) - LayerStates.Value(int(ly.Index), int(di), int(LayerRewPredNeg)) GlobalScalars.Set(pred, int(GvPrevPred), int(di)) } @@ -806,19 +806,19 @@ func (ly *LayerParams) CyclePostTDIntegLayer(ctx *Context, di uint32) { rpval := float32(0) if ctx.PlusPhase.IsTrue() { pli := uint32(ly.TDInteg.TDPredLayIndex) - pred := LayerStates.Value(int(pli), int(LayerRewPredPos), int(di)) - LayerStates.Value(int(pli), int(LayerRewPredNeg), int(di)) + pred := LayerStates.Value(int(pli), int(di), int(LayerRewPredPos)) - LayerStates.Value(int(pli), int(di), int(LayerRewPredNeg)) rpval = rew + ly.TDInteg.Discount*ly.TDInteg.PredGain*pred - LayerStates.Set(rpval, int(ly.Index), int(LayerRewPredPos), int(di)) // our plus phase = new integrated value + LayerStates.Set(rpval, int(ly.Index), int(di), int(LayerRewPredPos)) // our plus phase = new integrated value } else { rpval = ly.TDInteg.PredGain * GlobalScalars.Value(int(GvPrevPred), int(di)) - LayerStates.Set(rpval, int(ly.Index), int(LayerRewPredNeg), int(di)) // our minus phase = prior integrated value + LayerStates.Set(rpval, int(ly.Index), int(di), int(LayerRewPredNeg)) // our minus phase = prior integrated value } GlobalScalars.Set(rpval, int(GvRewPred), int(di)) // global value will be copied to layers next cycle } func (ly *LayerParams) CyclePostTDDaLayer(ctx *Context, di uint32) { ili := uint32(ly.TDDa.TDIntegLayIndex) - da := LayerStates.Value(int(ili), int(LayerRewPredPos), int(di)) - LayerStates.Value(int(ili), int(LayerRewPredNeg), int(di)) + da := LayerStates.Value(int(ili), int(di), int(LayerRewPredPos)) - LayerStates.Value(int(ili), int(di), int(LayerRewPredNeg)) if ctx.PlusPhase.IsFalse() { da = 0 } @@ -864,7 +864,7 @@ func (ly *LayerParams) NewStateLayer(ctx *Context) { ly.Acts.Clamp.IsInput.SetBool(ly.IsInput()) ly.Acts.Clamp.IsTarget.SetBool(ly.IsTarget()) - LayerStates.Set(-1.0, int(ly.Index), int(LayerRT), int(di)) + LayerStates.Set(-1.0, int(ly.Index), int(di), int(LayerRT)) for spi := uint32(0); spi < np; spi++ { pi := ly.PoolIndex(spi) @@ -885,21 +885,21 @@ func (ly *LayerParams) NewStateLayer(ctx *Context) { // NewStateLayerActAvg updates ActAvg.ActMAvg and ActPAvg based on current values // that have been averaged across NData already. func (ly *LayerParams) NewStateLayerActAvg(ctx *Context, di uint32, actMinusAvg, actPlusAvg float32) { - mavg := LayerStates.Value(int(ly.Index), int(LayerActMAvg), int(di)) - pavg := LayerStates.Value(int(ly.Index), int(LayerActPAvg), int(di)) + mavg := LayerStates.Value(int(ly.Index), int(di), int(LayerActMAvg)) + pavg := LayerStates.Value(int(ly.Index), int(di), int(LayerActPAvg)) ly.Inhib.ActAvg.AvgFromAct(&mavg, actMinusAvg, ly.Acts.Dt.LongAvgDt) ly.Inhib.ActAvg.AvgFromAct(&pavg, actPlusAvg, ly.Acts.Dt.LongAvgDt) - LayerStates.Set(mavg, int(ly.Index), int(LayerActMAvg), int(di)) - LayerStates.Set(pavg, int(ly.Index), int(LayerActPAvg), int(di)) + LayerStates.Set(mavg, int(ly.Index), int(di), int(LayerActMAvg)) + LayerStates.Set(pavg, int(ly.Index), int(di), int(LayerActPAvg)) } func (ly *LayerParams) NewStatePool(ctx *Context, pi, di uint32) { - PoolsInt.Set(0, int(pi), int(Clamped), int(di)) + PoolsInt.Set(0, int(pi), int(di), int(Clamped)) if ly.Acts.Clamp.Add.IsFalse() && ly.Acts.Clamp.IsInput.IsTrue() { - PoolsInt.Set(1, int(pi), int(Clamped), int(di)) + PoolsInt.Set(1, int(pi), int(di), int(Clamped)) } PoolInhibDecay(pi, di, ly.Acts.Decay.Act) - PoolsInt.Set(0, int(pi), int(PoolGated), int(di)) + PoolsInt.Set(0, int(pi), int(di), int(PoolGated)) } // NewStateNeuron handles all initialization at start of new input pattern. @@ -917,9 +917,9 @@ func (ly *LayerParams) NewStateNeuron(ctx *Context, ni, di uint32) { func (ly *LayerParams) MinusPhasePool(ctx *Context, pi, di uint32) { PoolCycleToMinus(pi, di) if ly.Acts.Clamp.Add.IsFalse() && ly.Acts.Clamp.IsTarget.IsTrue() { - PoolsInt.Set(1, int(pi), int(Clamped), int(di)) + PoolsInt.Set(1, int(pi), int(di), int(Clamped)) } - if PoolsInt.Value(int(pi), int(PoolIsLayer), int(di)) == 0 { + if PoolsInt.Value(int(pi), int(di), int(PoolIsLayer)) == 0 { return } geIntMinusMax := float32(0) @@ -937,12 +937,12 @@ func (ly *LayerParams) MinusPhasePool(ctx *Context, pi, di uint32) { // (AvgMaxGeM, AvgMaxGiM) stats, updated in MinusPhase, // using values that already max across NData. func (ly *LayerParams) AvgGeM(ctx *Context, di uint32, geIntMinusMax, giIntMinusMax float32) { - gem := LayerStates.Value(int(ly.Index), int(LayerAvgMaxGeM), int(di)) - gim := LayerStates.Value(int(ly.Index), int(LayerAvgMaxGiM), int(di)) + gem := LayerStates.Value(int(ly.Index), int(di), int(LayerAvgMaxGeM)) + gim := LayerStates.Value(int(ly.Index), int(di), int(LayerAvgMaxGiM)) gem += ly.Acts.Dt.LongAvgDt * (geIntMinusMax - gem) gim += ly.Acts.Dt.LongAvgDt * (giIntMinusMax - gim) - LayerStates.Set(gem, int(ly.Index), int(LayerAvgMaxGeM), int(di)) - LayerStates.Set(gim, int(ly.Index), int(LayerAvgMaxGiM), int(di)) + LayerStates.Set(gem, int(ly.Index), int(di), int(LayerAvgMaxGeM)) + LayerStates.Set(gim, int(ly.Index), int(di), int(LayerAvgMaxGiM)) } // MinusPhaseNeuron does neuron level minus-phase updating @@ -986,7 +986,7 @@ func (ly *LayerParams) PlusPhaseNeuron(ctx *Context, ni, di uint32) { switch ly.Type { case BLALayer: dlr = ly.Learn.RLRate.RLRateDiff(nrnCaSpkP, Neurons.Value(int(ni), int(di), int(SpkPrv))) // delta on previous trial - if !ly.Learn.NeuroMod.IsBLAExt() && PoolsInt.Value(int(pi), int(PoolNeurSt), int(0)) == 0 { // first pool + if !ly.Learn.NeuroMod.IsBLAExt() && PoolsInt.Value(int(pi), int(0), int(PoolNeurSt)) == 0 { // first pool dlr = 0 // first pool is novelty / curiosity -- no learn } case VSPatchLayer: diff --git a/axon/act-layer.goal b/axon/act-layer.goal index 9e329ff9..ca792580 100644 --- a/axon/act-layer.goal +++ b/axon/act-layer.goal @@ -184,7 +184,7 @@ func (ly *LayerParams) GiFromSpikes(ctx *Context, ni, di uint32) { geExt := Neurons[ni, di, GeExt] PoolInhibRawIncrInt(pi, di, spk, geRaw, geExt) PoolAvgMaxUpdate(pi, di, ni) - if PoolsInt[pi, PoolIsLayer, di] == 0 { // also update layer pool if I am a subpool + if PoolsInt[pi, di, PoolIsLayer] == 0 { // also update layer pool if I am a subpool lpi := ly.PoolIndex(0) PoolInhibRawIncrInt(lpi, di, spk, geRaw, geExt) PoolAvgMaxUpdate(lpi, di, ni) @@ -202,12 +202,12 @@ func (ly *LayerParams) LayerGi(ctx *Context, li, di uint32) { // BetweenGi computes inhibition Gi between layers. func (ly *LayerParams) BetweenGi(ctx *Context, di uint32) { lpi := ly.PoolIndex(0) - maxGi := Pools[lpi, fsfffb.TotalGi, di] + maxGi := Pools[lpi, di, fsfffb.TotalGi] maxGi = ly.BetweenLayerGiMax(di, maxGi, ly.LayInhib.Index1) maxGi = ly.BetweenLayerGiMax(di, maxGi, ly.LayInhib.Index2) maxGi = ly.BetweenLayerGiMax(di, maxGi, ly.LayInhib.Index3) maxGi = ly.BetweenLayerGiMax(di, maxGi, ly.LayInhib.Index4) - Pools[lpi, fsfffb.TotalGi, di] = maxGi // our inhib is max of us and everyone in the layer pool + Pools[lpi, di, fsfffb.TotalGi] = maxGi // our inhib is max of us and everyone in the layer pool } // BetweenLayerGiMax returns max gi value for input maxGi vs @@ -218,7 +218,7 @@ func (ly *LayerParams) BetweenLayerGiMax(di uint32, maxGi float32, layIndex int3 } oly := GetLayers(uint32(layIndex)) opi := oly.PoolIndex(0) - ogi := Pools[opi, fsfffb.TotalGi, di] + ogi := Pools[opi, di, fsfffb.TotalGi] if ogi > maxGi { return ogi } @@ -228,7 +228,7 @@ func (ly *LayerParams) BetweenLayerGiMax(di uint32, maxGi float32, layIndex int3 // LayPoolGiFromSpikes computes inhibition Gi from Spikes for layer-level pool. func (ly *LayerParams) LayPoolGiFromSpikes(ctx *Context, lpi, di uint32) { PoolInhibSpikesFromRaw(lpi, di) - PoolInhib(&ly.Inhib.Layer, lpi, di, LayerStates[ly.Index, LayerGiMult, di]) + PoolInhib(&ly.Inhib.Layer, lpi, di, LayerStates[ly.Index, di, LayerGiMult]) } // SubPoolGiFromSpikes computes inhibition Gi from Spikes within a sub-pool @@ -237,9 +237,9 @@ func (ly *LayerParams) SubPoolGiFromSpikes(ctx *Context, lpi, pi, di uint32, lyI PoolInhibSpikesFromRaw(pi, di) PoolInhib(&ly.Inhib.Pool, pi, di, giMult) if lyInhib { - PoolInhibLayerMax(pi, di, Pools[lpi, fsfffb.TotalGi, di]) // note: this requires lpl inhib to have been computed before! + PoolInhibLayerMax(pi, di, Pools[lpi, di, fsfffb.TotalGi]) // note: this requires lpl inhib to have been computed before! } else { - PoolInhibPoolMax(pi, di, Pools[pi, fsfffb.TotalGi, di]) // display only + PoolInhibPoolMax(pi, di, Pools[pi, di, fsfffb.TotalGi]) // display only PoolInhibSaveOrig(lpi, di) // effective GiOrig } } @@ -292,7 +292,7 @@ func (ly *LayerParams) SpecialPreGs(ctx *Context, pi, ni, di uint32, drvGe float saveVal := float32(0) // sometimes we need to use a value computed here, for the post Gs step pil := pi - ly.PoolSt pnn := uint32(PoolNNeurons(pi)) - pni := NeuronIxs[ni, NrnNeurIndex] - uint32(PoolsInt[pi, PoolNeurSt, di]) + pni := NeuronIxs[ni, NrnNeurIndex] - uint32(PoolsInt[pi, di, PoolNeurSt]) nrnCtxtGe := Neurons[ni, di, CtxtGe] nrnGeRaw := Neurons[ni, di, GeRaw] hasRew := GlobalScalars[GvHasRew, di] > 0 @@ -486,9 +486,9 @@ func (ly *LayerParams) GFromRawSyn(ctx *Context, ni, di uint32) { // GiInteg adds Gi values from all sources including SubPool computed inhib // and updates GABAB as well func (ly *LayerParams) GiInteg(ctx *Context, pi, ni, di uint32) { - giMult := LayerStates[ly.Index, LayerGiMult, di] - gi := giMult*Pools[pi, fsfffb.TotalGi, di] + Neurons[ni, di, GiSyn] + Neurons[ni, di, GiNoise] + ly.Learn.NeuroMod.GiFromACh(GlobalScalars[GvACh, di]) - ssgi := Pools[pi, fsfffb.SSGi, di] + giMult := LayerStates[ly.Index, di, LayerGiMult] + gi := giMult*Pools[pi, di, fsfffb.TotalGi] + Neurons[ni, di, GiSyn] + Neurons[ni, di, GiNoise] + ly.Learn.NeuroMod.GiFromACh(GlobalScalars[GvACh, di]) + ssgi := Pools[pi, di, fsfffb.SSGi] Neurons[ni, di, Gi] = gi Neurons[ni, di, SSGiDend] = 0.0 if ctx.PlusPhase.IsTrue() && ly.Type == PulvinarLayer { @@ -568,7 +568,7 @@ func (ly *LayerParams) PostSpikeSpecial(ctx *Context, lpi, pi, ni, di uint32) { li := ly.Index pil := pi - ly.PoolSt // 0-n pool index pnn := uint32(PoolNNeurons(pi)) - pni := NeuronIxs[ni, NrnNeurIndex] - uint32(PoolsInt[pi, PoolNeurSt, di]) + pni := NeuronIxs[ni, NrnNeurIndex] - uint32(PoolsInt[pi, di, PoolNeurSt]) hasRew := GlobalScalars[GvHasRew, di] > 0 switch ly.Type { case SuperLayer: @@ -663,9 +663,9 @@ func (ly *LayerParams) PostSpikeSpecial(ctx *Context, lpi, pi, ni, di uint32) { // clipped linear Neurons[ni, di, Act] = ly.RWPred.PredRange.ClipValue(Neurons[ni, di, Ge]) if pni == 0 { - LayerStates[li, LayerRewPredPos, di] = Neurons[ni, di, ActInt] + LayerStates[li, di, LayerRewPredPos] = Neurons[ni, di, ActInt] } else { - LayerStates[li, LayerRewPredNeg, di] = Neurons[ni, di, ActInt] + LayerStates[li, di, LayerRewPredNeg] = Neurons[ni, di, ActInt] } case RWDaLayer: // I set this in CyclePost @@ -674,9 +674,9 @@ func (ly *LayerParams) PostSpikeSpecial(ctx *Context, lpi, pi, ni, di uint32) { // linear Neurons[ni, di, Act] = Neurons[ni, di, Ge] if pni == 0 { - LayerStates[li, LayerRewPredPos, di] = Neurons[ni, di, ActInt] + LayerStates[li, di, LayerRewPredPos] = Neurons[ni, di, ActInt] } else { - LayerStates[li, LayerRewPredNeg, di] = Neurons[ni, di, ActInt] + LayerStates[li, di, LayerRewPredNeg] = Neurons[ni, di, ActInt] } case TDIntegLayer: Neurons[ni, di, Act] = GlobalScalars[GvRewPred, di] @@ -746,8 +746,8 @@ func (ly *LayerParams) CyclePost(ctx *Context, di uint32) { func (ly *LayerParams) CyclePostLayer(ctx *Context, lpi, di uint32) { casp := PoolAvgMax(AMCaSpkP, AMCycle, Max, lpi, di) if ctx.Cycle >= ly.Acts.Dt.MaxCycStart && casp > 0.5 { // todo: param - if LayerStates[ly.Index, LayerRT, di] <= 0 { - LayerStates[ly.Index, LayerRT, di] = float32(ctx.Cycle) + if LayerStates[ly.Index, di, LayerRT] <= 0 { + LayerStates[ly.Index, di, LayerRT] = float32(ctx.Cycle) } } } @@ -780,7 +780,7 @@ func (ly *LayerParams) CyclePostLDTLayer(ctx *Context, di uint32, srcLay1Act, sr func (ly *LayerParams) CyclePostRWDaLayer(ctx *Context, di uint32) { pli := uint32(ly.RWDa.RWPredLayIndex) - pred := LayerStates[pli, LayerRewPredPos, di] - LayerStates[pli, LayerRewPredNeg, di] + pred := LayerStates[pli, di, LayerRewPredPos] - LayerStates[pli, di, LayerRewPredNeg] GlobalScalars[GvRewPred, di] = pred // record da := float32(0) if GlobalScalars[GvHasRew, di] > 0 { @@ -793,7 +793,7 @@ func (ly *LayerParams) CyclePostTDPredLayer(ctx *Context, di uint32) { if ctx.PlusPhase.IsFalse() { return } - pred := LayerStates[ly.Index, LayerRewPredPos, di] - LayerStates[ly.Index, LayerRewPredNeg, di] + pred := LayerStates[ly.Index, di, LayerRewPredPos] - LayerStates[ly.Index, di, LayerRewPredNeg] GlobalScalars[GvPrevPred, di] = pred } @@ -805,19 +805,19 @@ func (ly *LayerParams) CyclePostTDIntegLayer(ctx *Context, di uint32) { rpval := float32(0) if ctx.PlusPhase.IsTrue() { pli := uint32(ly.TDInteg.TDPredLayIndex) - pred := LayerStates[pli, LayerRewPredPos, di] - LayerStates[pli, LayerRewPredNeg, di] + pred := LayerStates[pli, di, LayerRewPredPos] - LayerStates[pli, di, LayerRewPredNeg] rpval = rew + ly.TDInteg.Discount*ly.TDInteg.PredGain*pred - LayerStates[ly.Index, LayerRewPredPos, di] = rpval // our plus phase = new integrated value + LayerStates[ly.Index, di, LayerRewPredPos] = rpval // our plus phase = new integrated value } else { rpval = ly.TDInteg.PredGain * GlobalScalars[GvPrevPred, di] - LayerStates[ly.Index, LayerRewPredNeg, di] = rpval // our minus phase = prior integrated value + LayerStates[ly.Index, di, LayerRewPredNeg] = rpval // our minus phase = prior integrated value } GlobalScalars[GvRewPred, di] = rpval // global value will be copied to layers next cycle } func (ly *LayerParams) CyclePostTDDaLayer(ctx *Context, di uint32) { ili := uint32(ly.TDDa.TDIntegLayIndex) - da := LayerStates[ili, LayerRewPredPos, di] - LayerStates[ili, LayerRewPredNeg, di] + da := LayerStates[ili, di, LayerRewPredPos] - LayerStates[ili, di, LayerRewPredNeg] if ctx.PlusPhase.IsFalse() { da = 0 } @@ -863,7 +863,7 @@ func (ly *LayerParams) NewStateLayer(ctx *Context) { ly.Acts.Clamp.IsInput.SetBool(ly.IsInput()) ly.Acts.Clamp.IsTarget.SetBool(ly.IsTarget()) - LayerStates[ly.Index, LayerRT, di] = -1.0 + LayerStates[ly.Index, di, LayerRT] = -1.0 for spi := uint32(0); spi < np; spi++ { pi := ly.PoolIndex(spi) @@ -884,21 +884,21 @@ func (ly *LayerParams) NewStateLayer(ctx *Context) { // NewStateLayerActAvg updates ActAvg.ActMAvg and ActPAvg based on current values // that have been averaged across NData already. func (ly *LayerParams) NewStateLayerActAvg(ctx *Context, di uint32, actMinusAvg, actPlusAvg float32) { - mavg := LayerStates[ly.Index, LayerActMAvg, di] - pavg := LayerStates[ly.Index, LayerActPAvg, di] + mavg := LayerStates[ly.Index, di, LayerActMAvg] + pavg := LayerStates[ly.Index, di, LayerActPAvg] ly.Inhib.ActAvg.AvgFromAct(&mavg, actMinusAvg, ly.Acts.Dt.LongAvgDt) ly.Inhib.ActAvg.AvgFromAct(&pavg, actPlusAvg, ly.Acts.Dt.LongAvgDt) - LayerStates[ly.Index, LayerActMAvg, di] = mavg - LayerStates[ly.Index, LayerActPAvg, di] = pavg + LayerStates[ly.Index, di, LayerActMAvg] = mavg + LayerStates[ly.Index, di, LayerActPAvg] = pavg } func (ly *LayerParams) NewStatePool(ctx *Context, pi, di uint32) { - PoolsInt[pi, Clamped, di] = 0 + PoolsInt[pi, di, Clamped] = 0 if ly.Acts.Clamp.Add.IsFalse() && ly.Acts.Clamp.IsInput.IsTrue() { - PoolsInt[pi, Clamped, di] = 1 + PoolsInt[pi, di, Clamped] = 1 } PoolInhibDecay(pi, di, ly.Acts.Decay.Act) - PoolsInt[pi, PoolGated, di] = 0 + PoolsInt[pi, di, PoolGated] = 0 } // NewStateNeuron handles all initialization at start of new input pattern. @@ -916,9 +916,9 @@ func (ly *LayerParams) NewStateNeuron(ctx *Context, ni, di uint32) { func (ly *LayerParams) MinusPhasePool(ctx *Context, pi, di uint32) { PoolCycleToMinus(pi, di) if ly.Acts.Clamp.Add.IsFalse() && ly.Acts.Clamp.IsTarget.IsTrue() { - PoolsInt[pi, Clamped, di] = 1 + PoolsInt[pi, di, Clamped] = 1 } - if PoolsInt[pi, PoolIsLayer, di] == 0 { + if PoolsInt[pi, di, PoolIsLayer] == 0 { return } geIntMinusMax := float32(0) @@ -936,12 +936,12 @@ func (ly *LayerParams) MinusPhasePool(ctx *Context, pi, di uint32) { // (AvgMaxGeM, AvgMaxGiM) stats, updated in MinusPhase, // using values that already max across NData. func (ly *LayerParams) AvgGeM(ctx *Context, di uint32, geIntMinusMax, giIntMinusMax float32) { - gem := LayerStates[ly.Index, LayerAvgMaxGeM, di] - gim := LayerStates[ly.Index, LayerAvgMaxGiM, di] + gem := LayerStates[ly.Index, di, LayerAvgMaxGeM] + gim := LayerStates[ly.Index, di, LayerAvgMaxGiM] gem += ly.Acts.Dt.LongAvgDt * (geIntMinusMax - gem) gim += ly.Acts.Dt.LongAvgDt * (giIntMinusMax - gim) - LayerStates[ly.Index, LayerAvgMaxGeM, di] = gem - LayerStates[ly.Index, LayerAvgMaxGiM, di] = gim + LayerStates[ly.Index, di, LayerAvgMaxGeM] = gem + LayerStates[ly.Index, di, LayerAvgMaxGiM] = gim } // MinusPhaseNeuron does neuron level minus-phase updating @@ -985,7 +985,7 @@ func (ly *LayerParams) PlusPhaseNeuron(ctx *Context, ni, di uint32) { switch ly.Type { case BLALayer: dlr = ly.Learn.RLRate.RLRateDiff(nrnCaSpkP, Neurons[ni, di, SpkPrv]) // delta on previous trial - if !ly.Learn.NeuroMod.IsBLAExt() && PoolsInt[pi, PoolNeurSt, 0] == 0 { // first pool + if !ly.Learn.NeuroMod.IsBLAExt() && PoolsInt[pi, 0, PoolNeurSt] == 0 { // first pool dlr = 0 // first pool is novelty / curiosity -- no learn } case VSPatchLayer: diff --git a/axon/act-net.go b/axon/act-net.go index e58443e1..82e733f0 100644 --- a/axon/act-net.go +++ b/axon/act-net.go @@ -342,7 +342,7 @@ func MinusPhasePool(i uint32) { //gosl:kernel ctx := GetCtx(0) di := ctx.DataIndex(i) pi := ctx.ItemIndex(i) - li := PoolsInt.Value(int(pi), int(PoolLayerIdx), int(di)) + li := PoolsInt.Value(int(pi), int(di), int(PoolLayerIdx)) Layers[li].MinusPhasePool(ctx, pi, di) } @@ -372,7 +372,7 @@ func PlusPhasePool(i uint32) { //gosl:kernel ctx := GetCtx(0) di := ctx.DataIndex(i) pi := ctx.ItemIndex(i) - li := PoolsInt.Value(int(pi), int(PoolLayerIdx), int(di)) + li := PoolsInt.Value(int(pi), int(di), int(PoolLayerIdx)) Layers[li].PlusPhasePool(ctx, pi, di) } diff --git a/axon/act-net.goal b/axon/act-net.goal index bee92dad..43e94819 100644 --- a/axon/act-net.goal +++ b/axon/act-net.goal @@ -336,7 +336,7 @@ func MinusPhasePool(i uint32) { //gosl:kernel ctx := GetCtx(0) di := ctx.DataIndex(i) pi := ctx.ItemIndex(i) - li := PoolsInt[pi, PoolLayerIdx, di] + li := PoolsInt[pi, di, PoolLayerIdx] Layers[li].MinusPhasePool(ctx, pi, di) } @@ -366,7 +366,7 @@ func PlusPhasePool(i uint32) { //gosl:kernel ctx := GetCtx(0) di := ctx.DataIndex(i) pi := ctx.ItemIndex(i) - li := PoolsInt[pi, PoolLayerIdx, di] + li := PoolsInt[pi, di, PoolLayerIdx] Layers[li].PlusPhasePool(ctx, pi, di) } diff --git a/axon/act-path.go b/axon/act-path.go index cd12992e..335d80c9 100644 --- a/axon/act-path.go +++ b/axon/act-path.go @@ -237,8 +237,8 @@ func (pt *PathParams) SynSendLayerIndex(syni uint32) uint32 { func (pt *PathParams) GatherSpikes(ctx *Context, ly *LayerParams, ni, di, lni uint32) { deli := pt.Com.ReadOff(ctx.CyclesTotal) npti := pt.Indexes.NPathNeurSt + lni - gRaw := pt.Com.FloatFromGBuf(PathGBuf.Value(int(npti), int(deli), int(di))) - PathGBuf.Set(0, int(npti), int(deli), int(di)) + gRaw := pt.Com.FloatFromGBuf(PathGBuf.Value(int(npti), int(di), int(deli))) + PathGBuf.Set(0, int(npti), int(di), int(deli)) gsyn := PathGSyns.Value(int(npti), int(di)) pt.GatherSpikesGSyn(ctx, ly, ni, di, gRaw, &gsyn) PathGSyns.Set(gsyn, int(npti), int(di)) @@ -298,7 +298,7 @@ func (pt *PathParams) SendSpike(ctx *Context, ni, di, lni uint32) { npti := npst + (ri - recvNeurSt) deli := pt.Com.WriteOff(ctx.CyclesTotal) sv := int32(sendVal * Synapses.Value(int(syni), int(Wt))) - atomic.AddInt32(PathGBuf.ValuePtr(int(npti), int(deli), int(di)), sv) + atomic.AddInt32(PathGBuf.ValuePtr(int(npti), int(di), int(deli)), sv) } } @@ -312,15 +312,11 @@ func (pt *PathParams) InitGBuffs(ctx *Context) { mdel := nix.MaxDelay + 1 rnn := pt.Indexes.RecvNeurN npst := pt.Indexes.NPathNeurSt - for dl := uint32(0); dl < mdel; dl++ { - for ri := uint32(0); ri < rnn; ri++ { - for di := uint32(0); di < maxd; di++ { - PathGBuf.Set(0, int(npst+ri), int(dl), int(di)) - } - } - } for ri := uint32(0); ri < rnn; ri++ { for di := uint32(0); di < maxd; di++ { + for dl := uint32(0); dl < mdel; dl++ { + PathGBuf.Set(0, int(npst+ri), int(di), int(dl)) + } PathGSyns.Set(0.0, int(npst+ri), int(di)) } } diff --git a/axon/act-path.goal b/axon/act-path.goal index 15c02669..27ed95cf 100644 --- a/axon/act-path.goal +++ b/axon/act-path.goal @@ -235,8 +235,8 @@ func (pt *PathParams) SynSendLayerIndex(syni uint32) uint32 { func (pt *PathParams) GatherSpikes(ctx *Context, ly *LayerParams, ni, di, lni uint32) { deli := pt.Com.ReadOff(ctx.CyclesTotal) npti := pt.Indexes.NPathNeurSt + lni - gRaw := pt.Com.FloatFromGBuf(PathGBuf[npti, deli, di]) - PathGBuf[npti, deli, di] = 0 + gRaw := pt.Com.FloatFromGBuf(PathGBuf[npti, di, deli]) + PathGBuf[npti, di, deli] = 0 gsyn := PathGSyns[npti, di] pt.GatherSpikesGSyn(ctx, ly, ni, di, gRaw, &gsyn) PathGSyns[npti, di] = gsyn @@ -296,7 +296,7 @@ func (pt *PathParams) SendSpike(ctx *Context, ni, di, lni uint32) { npti := npst + (ri - recvNeurSt) deli := pt.Com.WriteOff(ctx.CyclesTotal) sv := int32(sendVal * Synapses[syni, Wt]) - atomic.AddInt32(&PathGBuf[npti, deli, di], sv) + atomic.AddInt32(&PathGBuf[npti, di, deli], sv) } } @@ -310,15 +310,11 @@ func (pt *PathParams) InitGBuffs(ctx *Context) { mdel := nix.MaxDelay + 1 rnn := pt.Indexes.RecvNeurN npst := pt.Indexes.NPathNeurSt - for dl := uint32(0); dl < mdel; dl++ { - for ri := uint32(0); ri < rnn; ri++ { - for di := uint32(0); di < maxd; di++ { - PathGBuf[npst+ri, dl, di] = 0 - } - } - } for ri := uint32(0); ri < rnn; ri++ { for di := uint32(0); di < maxd; di++ { + for dl := uint32(0); dl < mdel; dl++ { + PathGBuf[npst+ri, di, dl] = 0 + } PathGSyns[npst+ri, di] = 0.0 } } diff --git a/axon/basic_test.go b/axon/basic_test.go index 425edbe7..309e27ad 100644 --- a/axon/basic_test.go +++ b/axon/basic_test.go @@ -253,11 +253,11 @@ func TestSpikeProp(t *testing.T) { func poolValues(pi uint32, di int, vals map[string]float32, key string) { for i := range uint32(PoolVarsN) { kk := key + fmt.Sprintf("\t%s", PoolVarName(i)) - vals[kk] = Pools.Value(int(pi), int(i), int(di)) + vals[kk] = Pools.Value(int(pi), int(di), int(i)) } for i := range uint32(PoolIntVarsTot) { kk := key + fmt.Sprintf("\t%s", PoolIntVarName(i)) - vals[kk] = float32(PoolsInt.Value(int(pi), int(i), int(di))) + vals[kk] = float32(PoolsInt.Value(int(pi), int(di), int(i))) } } @@ -265,7 +265,7 @@ func poolValues(pi uint32, di int, vals map[string]float32, key string) { func layerStates(li, di int, vals map[string]float32, key string) { for i := range uint32(LayerVarsN) { kk := key + fmt.Sprintf("\t%s", LayerVars(i).String()) - vals[kk] = LayerStates.Value(int(li), int(i), int(di)) + vals[kk] = LayerStates.Value(int(li), int(di), int(i)) } } diff --git a/axon/basic_test.goal b/axon/basic_test.goal index eb46aa1f..049f3949 100644 --- a/axon/basic_test.goal +++ b/axon/basic_test.goal @@ -253,11 +253,11 @@ func TestSpikeProp(t *testing.T) { func poolValues(pi uint32, di int, vals map[string]float32, key string) { for i := range uint32(PoolVarsN) { kk := key + fmt.Sprintf("\t%s", PoolVarName(i)) - vals[kk] = Pools[pi, i, di] + vals[kk] = Pools[pi, di, i] } for i := range uint32(PoolIntVarsTot) { kk := key + fmt.Sprintf("\t%s", PoolIntVarName(i)) - vals[kk] = float32(PoolsInt[pi, i, di]) + vals[kk] = float32(PoolsInt[pi, di, i]) } } @@ -265,7 +265,7 @@ func poolValues(pi uint32, di int, vals map[string]float32, key string) { func layerStates(li, di int, vals map[string]float32, key string) { for i := range uint32(LayerVarsN) { kk := key + fmt.Sprintf("\t%s", LayerVars(i).String()) - vals[kk] = LayerStates[li, i, di] + vals[kk] = LayerStates[li, di, i] } } diff --git a/axon/inhib.go b/axon/inhib.go index 036880a8..cff0fb2b 100644 --- a/axon/inhib.go +++ b/axon/inhib.go @@ -129,22 +129,22 @@ func PoolInhib(fb *fsfffb.GiParams, pi, di uint32, gimult float32) { PoolInhibZero(pi, di) return } - Pools.SetAdd(fb.FFAvgDt*(Pools.Value(int(pi), int(fsfffb.FFs), int(di))-Pools.Value(int(pi), int(fsfffb.FFAvg), int(di))), int(pi), int(fsfffb.FFAvg), int(di)) - - fsi := Pools.Value(int(pi), int(fsfffb.FSi), int(di)) - fsi = fb.FSiFromFFs(fsi, Pools.Value(int(pi), int(fsfffb.FFs), int(di)), Pools.Value(int(pi), int(fsfffb.FBs), int(di))) - Pools.Set(fsi, int(pi), int(fsfffb.FSi), int(di)) - clamped := PoolsInt.Value(int(pi), int(Clamped), int(di)) > 0 - Pools.Set(fb.Gi*fb.FS(fsi, Pools.Value(int(pi), int(fsfffb.GeExts), int(di)), clamped), int(pi), int(fsfffb.FSGi), int(di)) - - ssf := Pools.Value(int(pi), int(fsfffb.SSf), int(di)) - ssi := Pools.Value(int(pi), int(fsfffb.SSi), int(di)) - fb.SSFromFBs(&ssf, &ssi, Pools.Value(int(pi), int(fsfffb.FBs), int(di))) - Pools.Set(fb.Gi*fb.SS*ssi, int(pi), int(fsfffb.SSGi), int(di)) - Pools.Set(ssf, int(pi), int(fsfffb.SSf), int(di)) - Pools.Set(ssi, int(pi), int(fsfffb.SSi), int(di)) - - Pools.Set(PoolInhibGiFromFSSS(pi, di)+fb.FFPrv*Pools.Value(int(pi), int(fsfffb.FFAvgPrv), int(di)), int(pi), int(fsfffb.TotalGi), int(di)) + Pools.SetAdd(fb.FFAvgDt*(Pools.Value(int(pi), int(di), int(fsfffb.FFs))-Pools.Value(int(pi), int(di), int(fsfffb.FFAvg))), int(pi), int(di), int(fsfffb.FFAvg)) + + fsi := Pools.Value(int(pi), int(di), int(fsfffb.FSi)) + fsi = fb.FSiFromFFs(fsi, Pools.Value(int(pi), int(di), int(fsfffb.FFs)), Pools.Value(int(pi), int(di), int(fsfffb.FBs))) + Pools.Set(fsi, int(pi), int(di), int(fsfffb.FSi)) + clamped := PoolsInt.Value(int(pi), int(di), int(Clamped)) > 0 + Pools.Set(fb.Gi*fb.FS(fsi, Pools.Value(int(pi), int(di), int(fsfffb.GeExts)), clamped), int(pi), int(di), int(fsfffb.FSGi)) + + ssf := Pools.Value(int(pi), int(di), int(fsfffb.SSf)) + ssi := Pools.Value(int(pi), int(di), int(fsfffb.SSi)) + fb.SSFromFBs(&ssf, &ssi, Pools.Value(int(pi), int(di), int(fsfffb.FBs))) + Pools.Set(fb.Gi*fb.SS*ssi, int(pi), int(di), int(fsfffb.SSGi)) + Pools.Set(ssf, int(pi), int(di), int(fsfffb.SSf)) + Pools.Set(ssi, int(pi), int(di), int(fsfffb.SSi)) + + Pools.Set(PoolInhibGiFromFSSS(pi, di)+fb.FFPrv*Pools.Value(int(pi), int(di), int(fsfffb.FFAvgPrv)), int(pi), int(di), int(fsfffb.TotalGi)) PoolInhibSaveOrig(pi, di) } @@ -155,79 +155,79 @@ func PoolInhibInit(pi, di uint32) { // PoolInhibInitRaw clears raw spike counters -- done every cycle prior to accumulating func PoolInhibInitRaw(pi, di uint32) { - Pools.Set(0.0, int(pi), int(fsfffb.FFsRaw), int(di)) - Pools.Set(0.0, int(pi), int(fsfffb.FBsRaw), int(di)) - Pools.Set(0.0, int(pi), int(fsfffb.GeExtRaw), int(di)) + Pools.Set(0.0, int(pi), int(di), int(fsfffb.FFsRaw)) + Pools.Set(0.0, int(pi), int(di), int(fsfffb.FBsRaw)) + Pools.Set(0.0, int(pi), int(di), int(fsfffb.GeExtRaw)) - PoolsInt.Set(0, int(pi), int(FFsRawInt), int(di)) - PoolsInt.Set(0, int(pi), int(FBsRawInt), int(di)) - PoolsInt.Set(0, int(pi), int(GeExtRawInt), int(di)) + PoolsInt.Set(0, int(pi), int(di), int(FFsRawInt)) + PoolsInt.Set(0, int(pi), int(di), int(FBsRawInt)) + PoolsInt.Set(0, int(pi), int(di), int(GeExtRawInt)) } // PoolInhibZero resets all accumulating inhibition factors to 0 func PoolInhibZero(pi, di uint32) { - Pools.Set(0.0, int(pi), int(fsfffb.FFs), int(di)) - Pools.Set(0.0, int(pi), int(fsfffb.FBs), int(di)) - Pools.Set(0.0, int(pi), int(fsfffb.GeExts), int(di)) - Pools.Set(0.0, int(pi), int(fsfffb.FSi), int(di)) - Pools.Set(0.0, int(pi), int(fsfffb.SSi), int(di)) - Pools.Set(0.0, int(pi), int(fsfffb.SSf), int(di)) - Pools.Set(0.0, int(pi), int(fsfffb.FSGi), int(di)) - Pools.Set(0.0, int(pi), int(fsfffb.SSGi), int(di)) - Pools.Set(0.0, int(pi), int(fsfffb.TotalGi), int(di)) - Pools.Set(0.0, int(pi), int(fsfffb.FFAvg), int(di)) - Pools.Set(0.0, int(pi), int(fsfffb.FFAvgPrv), int(di)) - Pools.Set(0.0, int(pi), int(fsfffb.GiOrig), int(di)) - Pools.Set(0.0, int(pi), int(fsfffb.LayGi), int(di)) - PoolsInt.Set(0, int(pi), int(Clamped), int(di)) + Pools.Set(0.0, int(pi), int(di), int(fsfffb.FFs)) + Pools.Set(0.0, int(pi), int(di), int(fsfffb.FBs)) + Pools.Set(0.0, int(pi), int(di), int(fsfffb.GeExts)) + Pools.Set(0.0, int(pi), int(di), int(fsfffb.FSi)) + Pools.Set(0.0, int(pi), int(di), int(fsfffb.SSi)) + Pools.Set(0.0, int(pi), int(di), int(fsfffb.SSf)) + Pools.Set(0.0, int(pi), int(di), int(fsfffb.FSGi)) + Pools.Set(0.0, int(pi), int(di), int(fsfffb.SSGi)) + Pools.Set(0.0, int(pi), int(di), int(fsfffb.TotalGi)) + Pools.Set(0.0, int(pi), int(di), int(fsfffb.FFAvg)) + Pools.Set(0.0, int(pi), int(di), int(fsfffb.FFAvgPrv)) + Pools.Set(0.0, int(pi), int(di), int(fsfffb.GiOrig)) + Pools.Set(0.0, int(pi), int(di), int(fsfffb.LayGi)) + PoolsInt.Set(0, int(pi), int(di), int(Clamped)) } // Decay reduces inhibition values by given decay proportion func PoolInhibDecay(pi, di uint32, decay float32) { - Pools.Set(Pools.Value(int(pi), int(fsfffb.FFAvg), int(di)), int(pi), int(fsfffb.FFAvgPrv), int(di)) // capture prior to decay - - Pools.SetSub(decay*Pools.Value(int(pi), int(fsfffb.FFs), int(di)), int(pi), int(fsfffb.FFs), int(di)) - Pools.SetSub(decay*Pools.Value(int(pi), int(fsfffb.FBs), int(di)), int(pi), int(fsfffb.FBs), int(di)) - Pools.SetSub(decay*Pools.Value(int(pi), int(fsfffb.GeExts), int(di)), int(pi), int(fsfffb.GeExts), int(di)) - Pools.SetSub(decay*Pools.Value(int(pi), int(fsfffb.FSi), int(di)), int(pi), int(fsfffb.FSi), int(di)) - Pools.SetSub(decay*Pools.Value(int(pi), int(fsfffb.SSi), int(di)), int(pi), int(fsfffb.SSi), int(di)) - Pools.SetSub(decay*Pools.Value(int(pi), int(fsfffb.SSf), int(di)), int(pi), int(fsfffb.SSf), int(di)) - Pools.SetSub(decay*Pools.Value(int(pi), int(fsfffb.FSGi), int(di)), int(pi), int(fsfffb.FSGi), int(di)) - Pools.SetSub(decay*Pools.Value(int(pi), int(fsfffb.SSGi), int(di)), int(pi), int(fsfffb.SSGi), int(di)) - Pools.SetSub(decay*Pools.Value(int(pi), int(fsfffb.TotalGi), int(di)), int(pi), int(fsfffb.TotalGi), int(di)) - Pools.SetSub(decay*Pools.Value(int(pi), int(fsfffb.FFAvg), int(di)), int(pi), int(fsfffb.FFAvg), int(di)) + Pools.Set(Pools.Value(int(pi), int(di), int(fsfffb.FFAvg)), int(pi), int(di), int(fsfffb.FFAvgPrv)) // capture prior to decay + + Pools.SetSub(decay*Pools.Value(int(pi), int(di), int(fsfffb.FFs)), int(pi), int(di), int(fsfffb.FFs)) + Pools.SetSub(decay*Pools.Value(int(pi), int(di), int(fsfffb.FBs)), int(pi), int(di), int(fsfffb.FBs)) + Pools.SetSub(decay*Pools.Value(int(pi), int(di), int(fsfffb.GeExts)), int(pi), int(di), int(fsfffb.GeExts)) + Pools.SetSub(decay*Pools.Value(int(pi), int(di), int(fsfffb.FSi)), int(pi), int(di), int(fsfffb.FSi)) + Pools.SetSub(decay*Pools.Value(int(pi), int(di), int(fsfffb.SSi)), int(pi), int(di), int(fsfffb.SSi)) + Pools.SetSub(decay*Pools.Value(int(pi), int(di), int(fsfffb.SSf)), int(pi), int(di), int(fsfffb.SSf)) + Pools.SetSub(decay*Pools.Value(int(pi), int(di), int(fsfffb.FSGi)), int(pi), int(di), int(fsfffb.FSGi)) + Pools.SetSub(decay*Pools.Value(int(pi), int(di), int(fsfffb.SSGi)), int(pi), int(di), int(fsfffb.SSGi)) + Pools.SetSub(decay*Pools.Value(int(pi), int(di), int(fsfffb.TotalGi)), int(pi), int(di), int(fsfffb.TotalGi)) + Pools.SetSub(decay*Pools.Value(int(pi), int(di), int(fsfffb.FFAvg)), int(pi), int(di), int(fsfffb.FFAvg)) } // SpikesFromRaw updates spike values from raw, dividing by given number in pool func PoolInhibSpikesFromRaw(pi, di uint32) { fnn := float32(PoolNNeurons(pi)) - Pools.Set(Pools.Value(int(pi), int(fsfffb.FBsRaw), int(di))/fnn, int(pi), int(fsfffb.FBs), int(di)) - Pools.Set(Pools.Value(int(pi), int(fsfffb.FFsRaw), int(di)), int(pi), int(fsfffb.FFs), int(di)) - Pools.Set(Pools.Value(int(pi), int(fsfffb.GeExtRaw), int(di)), int(pi), int(fsfffb.GeExts), int(di)) + Pools.Set(Pools.Value(int(pi), int(di), int(fsfffb.FBsRaw))/fnn, int(pi), int(di), int(fsfffb.FBs)) + Pools.Set(Pools.Value(int(pi), int(di), int(fsfffb.FFsRaw)), int(pi), int(di), int(fsfffb.FFs)) + Pools.Set(Pools.Value(int(pi), int(di), int(fsfffb.GeExtRaw)), int(pi), int(di), int(fsfffb.GeExts)) PoolInhibInitRaw(pi, di) } // SaveOrig saves the current Gi values as original values func PoolInhibSaveOrig(pi, di uint32) { - Pools.Set(Pools.Value(int(pi), int(fsfffb.TotalGi), int(di)), int(pi), int(fsfffb.GiOrig), int(di)) + Pools.Set(Pools.Value(int(pi), int(di), int(fsfffb.TotalGi)), int(pi), int(di), int(fsfffb.GiOrig)) } // GiFromFSSS returns the sum of FSGi and SSGi as overall inhibition func PoolInhibGiFromFSSS(pi, di uint32) float32 { - return Pools.Value(int(pi), int(fsfffb.FSGi), int(di)) + Pools.Value(int(pi), int(fsfffb.SSGi), int(di)) + return Pools.Value(int(pi), int(di), int(fsfffb.FSGi)) + Pools.Value(int(pi), int(di), int(fsfffb.SSGi)) } // LayerMax updates given pool-level inhib values from given layer-level Gi // with resulting value being the Max of either func PoolInhibLayerMax(pi, di uint32, liGi float32) { - Pools.Set(liGi, int(pi), int(fsfffb.LayGi), int(di)) - Pools.Set(math32.Max(Pools.Value(int(pi), int(fsfffb.TotalGi), int(di)), liGi), int(pi), int(fsfffb.TotalGi), int(di)) + Pools.Set(liGi, int(pi), int(di), int(fsfffb.LayGi)) + Pools.Set(math32.Max(Pools.Value(int(pi), int(di), int(fsfffb.TotalGi)), liGi), int(pi), int(di), int(fsfffb.TotalGi)) } // PoolMax updates given layer-level inhib values from given pool-level // with resulting value being the Max of either func PoolInhibPoolMax(pi, di uint32, piGi float32) { - Pools.Set(math32.Max(Pools.Value(int(pi), int(fsfffb.TotalGi), int(di)), piGi), int(pi), int(fsfffb.TotalGi), int(di)) + Pools.Set(math32.Max(Pools.Value(int(pi), int(di), int(fsfffb.TotalGi)), piGi), int(pi), int(di), int(fsfffb.TotalGi)) } //////// atomic int safe accumulation @@ -237,17 +237,17 @@ func PoolInhibPoolMax(pi, di uint32, piGi float32) { func PoolInhibRawIncrInt(pi, di uint32, spike, geRaw, geExt float32) { floatToInt := float32(uint32(1) << 24) fnn := float32(PoolNNeurons(pi)) - atomic.AddInt32(PoolsInt.ValuePtr(int(pi), int(FBsRawInt), int(di)), int32(spike)) - atomic.AddInt32(PoolsInt.ValuePtr(int(pi), int(FFsRawInt), int(di)), int32((geRaw/fnn)*floatToInt)) - atomic.AddInt32(PoolsInt.ValuePtr(int(pi), int(GeExtRawInt), int(di)), int32((geExt/fnn)*floatToInt)) + atomic.AddInt32(PoolsInt.ValuePtr(int(pi), int(di), int(FBsRawInt)), int32(spike)) + atomic.AddInt32(PoolsInt.ValuePtr(int(pi), int(di), int(FFsRawInt)), int32((geRaw/fnn)*floatToInt)) + atomic.AddInt32(PoolsInt.ValuePtr(int(pi), int(di), int(GeExtRawInt)), int32((geExt/fnn)*floatToInt)) } // IntToRaw computes int values into float32 raw values func PoolInhibIntToRaw(pi, di uint32) { floatFromInt := 1.0 / float32(uint32(1)<<24) - fbs := PoolsInt.Value(int(pi), int(FBsRawInt), int(di)) - ffs := PoolsInt.Value(int(pi), int(FFsRawInt), int(di)) - geExt := PoolsInt.Value(int(pi), int(GeExtRawInt), int(di)) + fbs := PoolsInt.Value(int(pi), int(di), int(FBsRawInt)) + ffs := PoolsInt.Value(int(pi), int(di), int(FFsRawInt)) + geExt := PoolsInt.Value(int(pi), int(di), int(GeExtRawInt)) //gosl:end floatToInt := int32(1) << 24 if ffs < 0 { @@ -259,9 +259,9 @@ func PoolInhibIntToRaw(pi, di uint32) { geExt = floatToInt } //gosl:start - Pools.Set(float32(fbs), int(pi), int(fsfffb.FBsRaw), int(di)) - Pools.Set(float32(ffs)*floatFromInt, int(pi), int(fsfffb.FFsRaw), int(di)) - Pools.Set(float32(geExt)*floatFromInt, int(pi), int(fsfffb.GeExtRaw), int(di)) + Pools.Set(float32(fbs), int(pi), int(di), int(fsfffb.FBsRaw)) + Pools.Set(float32(ffs)*floatFromInt, int(pi), int(di), int(fsfffb.FFsRaw)) + Pools.Set(float32(geExt)*floatFromInt, int(pi), int(di), int(fsfffb.GeExtRaw)) } //gosl:end diff --git a/axon/inhib.goal b/axon/inhib.goal index ff469427..58e5e6b3 100644 --- a/axon/inhib.goal +++ b/axon/inhib.goal @@ -127,22 +127,22 @@ func PoolInhib(fb *fsfffb.GiParams, pi, di uint32, gimult float32) { PoolInhibZero(pi, di) return } - Pools[pi, fsfffb.FFAvg, di] += fb.FFAvgDt * (Pools[pi, fsfffb.FFs, di] - Pools[pi, fsfffb.FFAvg, di]) - - fsi := Pools[pi, fsfffb.FSi, di] - fsi = fb.FSiFromFFs(fsi, Pools[pi, fsfffb.FFs, di], Pools[pi, fsfffb.FBs, di]) - Pools[pi, fsfffb.FSi, di] = fsi - clamped := PoolsInt[pi, Clamped, di] > 0 - Pools[pi, fsfffb.FSGi, di] = fb.Gi * fb.FS(fsi, Pools[pi, fsfffb.GeExts, di], clamped) - - ssf := Pools[pi, fsfffb.SSf, di] - ssi := Pools[pi, fsfffb.SSi, di] - fb.SSFromFBs(&ssf, &ssi, Pools[pi, fsfffb.FBs, di]) - Pools[pi, fsfffb.SSGi, di] = fb.Gi * fb.SS * ssi - Pools[pi, fsfffb.SSf, di] = ssf - Pools[pi, fsfffb.SSi, di] = ssi - - Pools[pi, fsfffb.TotalGi, di] = PoolInhibGiFromFSSS(pi, di) + fb.FFPrv*Pools[pi, fsfffb.FFAvgPrv, di] + Pools[pi, di, fsfffb.FFAvg] += fb.FFAvgDt * (Pools[pi, di, fsfffb.FFs] - Pools[pi, di, fsfffb.FFAvg]) + + fsi := Pools[pi, di, fsfffb.FSi] + fsi = fb.FSiFromFFs(fsi, Pools[pi, di, fsfffb.FFs], Pools[pi, di, fsfffb.FBs]) + Pools[pi, di, fsfffb.FSi] = fsi + clamped := PoolsInt[pi, di, Clamped] > 0 + Pools[pi, di, fsfffb.FSGi] = fb.Gi * fb.FS(fsi, Pools[pi, di, fsfffb.GeExts], clamped) + + ssf := Pools[pi, di, fsfffb.SSf] + ssi := Pools[pi, di, fsfffb.SSi] + fb.SSFromFBs(&ssf, &ssi, Pools[pi, di, fsfffb.FBs]) + Pools[pi, di, fsfffb.SSGi] = fb.Gi * fb.SS * ssi + Pools[pi, di, fsfffb.SSf] = ssf + Pools[pi, di, fsfffb.SSi] = ssi + + Pools[pi, di, fsfffb.TotalGi] = PoolInhibGiFromFSSS(pi, di) + fb.FFPrv*Pools[pi, di, fsfffb.FFAvgPrv] PoolInhibSaveOrig(pi, di) } @@ -153,79 +153,79 @@ func PoolInhibInit(pi, di uint32) { // PoolInhibInitRaw clears raw spike counters -- done every cycle prior to accumulating func PoolInhibInitRaw(pi, di uint32) { - Pools[pi, fsfffb.FFsRaw, di] = 0.0 - Pools[pi, fsfffb.FBsRaw, di] = 0.0 - Pools[pi, fsfffb.GeExtRaw, di] = 0.0 + Pools[pi, di, fsfffb.FFsRaw] = 0.0 + Pools[pi, di, fsfffb.FBsRaw] = 0.0 + Pools[pi, di, fsfffb.GeExtRaw] = 0.0 - PoolsInt[pi, FFsRawInt, di] = 0 - PoolsInt[pi, FBsRawInt, di] = 0 - PoolsInt[pi, GeExtRawInt, di] = 0 + PoolsInt[pi, di, FFsRawInt] = 0 + PoolsInt[pi, di, FBsRawInt] = 0 + PoolsInt[pi, di, GeExtRawInt] = 0 } // PoolInhibZero resets all accumulating inhibition factors to 0 func PoolInhibZero(pi, di uint32) { - Pools[pi, fsfffb.FFs, di] = 0.0 - Pools[pi, fsfffb.FBs, di] = 0.0 - Pools[pi, fsfffb.GeExts, di] = 0.0 - Pools[pi, fsfffb.FSi, di] = 0.0 - Pools[pi, fsfffb.SSi, di] = 0.0 - Pools[pi, fsfffb.SSf, di] = 0.0 - Pools[pi, fsfffb.FSGi, di] = 0.0 - Pools[pi, fsfffb.SSGi, di] = 0.0 - Pools[pi, fsfffb.TotalGi, di] = 0.0 - Pools[pi, fsfffb.FFAvg, di] = 0.0 - Pools[pi, fsfffb.FFAvgPrv, di] = 0.0 - Pools[pi, fsfffb.GiOrig, di] = 0.0 - Pools[pi, fsfffb.LayGi, di] = 0.0 - PoolsInt[pi, Clamped, di] = 0 + Pools[pi, di, fsfffb.FFs] = 0.0 + Pools[pi, di, fsfffb.FBs] = 0.0 + Pools[pi, di, fsfffb.GeExts] = 0.0 + Pools[pi, di, fsfffb.FSi] = 0.0 + Pools[pi, di, fsfffb.SSi] = 0.0 + Pools[pi, di, fsfffb.SSf] = 0.0 + Pools[pi, di, fsfffb.FSGi] = 0.0 + Pools[pi, di, fsfffb.SSGi] = 0.0 + Pools[pi, di, fsfffb.TotalGi] = 0.0 + Pools[pi, di, fsfffb.FFAvg] = 0.0 + Pools[pi, di, fsfffb.FFAvgPrv] = 0.0 + Pools[pi, di, fsfffb.GiOrig] = 0.0 + Pools[pi, di, fsfffb.LayGi] = 0.0 + PoolsInt[pi, di, Clamped] = 0 } // Decay reduces inhibition values by given decay proportion func PoolInhibDecay(pi, di uint32, decay float32) { - Pools[pi, fsfffb.FFAvgPrv, di] = Pools[pi, fsfffb.FFAvg, di] // capture prior to decay - - Pools[pi, fsfffb.FFs, di] -= decay * Pools[pi, fsfffb.FFs, di] - Pools[pi, fsfffb.FBs, di] -= decay * Pools[pi, fsfffb.FBs, di] - Pools[pi, fsfffb.GeExts, di] -= decay * Pools[pi, fsfffb.GeExts, di] - Pools[pi, fsfffb.FSi, di] -= decay * Pools[pi, fsfffb.FSi, di] - Pools[pi, fsfffb.SSi, di] -= decay * Pools[pi, fsfffb.SSi, di] - Pools[pi, fsfffb.SSf, di] -= decay * Pools[pi, fsfffb.SSf, di] - Pools[pi, fsfffb.FSGi, di] -= decay * Pools[pi, fsfffb.FSGi, di] - Pools[pi, fsfffb.SSGi, di] -= decay * Pools[pi, fsfffb.SSGi, di] - Pools[pi, fsfffb.TotalGi, di] -= decay * Pools[pi, fsfffb.TotalGi, di] - Pools[pi, fsfffb.FFAvg, di] -= decay * Pools[pi, fsfffb.FFAvg, di] + Pools[pi, di, fsfffb.FFAvgPrv] = Pools[pi, di, fsfffb.FFAvg] // capture prior to decay + + Pools[pi, di, fsfffb.FFs] -= decay * Pools[pi, di, fsfffb.FFs] + Pools[pi, di, fsfffb.FBs] -= decay * Pools[pi, di, fsfffb.FBs] + Pools[pi, di, fsfffb.GeExts] -= decay * Pools[pi, di, fsfffb.GeExts] + Pools[pi, di, fsfffb.FSi] -= decay * Pools[pi, di, fsfffb.FSi] + Pools[pi, di, fsfffb.SSi] -= decay * Pools[pi, di, fsfffb.SSi] + Pools[pi, di, fsfffb.SSf] -= decay * Pools[pi, di, fsfffb.SSf] + Pools[pi, di, fsfffb.FSGi] -= decay * Pools[pi, di, fsfffb.FSGi] + Pools[pi, di, fsfffb.SSGi] -= decay * Pools[pi, di, fsfffb.SSGi] + Pools[pi, di, fsfffb.TotalGi] -= decay * Pools[pi, di, fsfffb.TotalGi] + Pools[pi, di, fsfffb.FFAvg] -= decay * Pools[pi, di, fsfffb.FFAvg] } // SpikesFromRaw updates spike values from raw, dividing by given number in pool func PoolInhibSpikesFromRaw(pi, di uint32) { fnn := float32(PoolNNeurons(pi)) - Pools[pi, fsfffb.FBs, di] = Pools[pi, fsfffb.FBsRaw, di] / fnn - Pools[pi, fsfffb.FFs, di] = Pools[pi, fsfffb.FFsRaw, di] - Pools[pi, fsfffb.GeExts, di] = Pools[pi, fsfffb.GeExtRaw, di] + Pools[pi, di, fsfffb.FBs] = Pools[pi, di, fsfffb.FBsRaw] / fnn + Pools[pi, di, fsfffb.FFs] = Pools[pi, di, fsfffb.FFsRaw] + Pools[pi, di, fsfffb.GeExts] = Pools[pi, di, fsfffb.GeExtRaw] PoolInhibInitRaw(pi, di) } // SaveOrig saves the current Gi values as original values func PoolInhibSaveOrig(pi, di uint32) { - Pools[pi, fsfffb.GiOrig, di] = Pools[pi, fsfffb.TotalGi, di] + Pools[pi, di, fsfffb.GiOrig] = Pools[pi, di, fsfffb.TotalGi] } // GiFromFSSS returns the sum of FSGi and SSGi as overall inhibition func PoolInhibGiFromFSSS(pi, di uint32) float32 { - return Pools[pi, fsfffb.FSGi, di] + Pools[pi, fsfffb.SSGi, di] + return Pools[pi, di, fsfffb.FSGi] + Pools[pi, di, fsfffb.SSGi] } // LayerMax updates given pool-level inhib values from given layer-level Gi // with resulting value being the Max of either func PoolInhibLayerMax(pi, di uint32, liGi float32) { - Pools[pi, fsfffb.LayGi, di] = liGi - Pools[pi, fsfffb.TotalGi, di] = math32.Max(Pools[pi, fsfffb.TotalGi, di], liGi) + Pools[pi, di, fsfffb.LayGi] = liGi + Pools[pi, di, fsfffb.TotalGi] = math32.Max(Pools[pi, di, fsfffb.TotalGi], liGi) } // PoolMax updates given layer-level inhib values from given pool-level // with resulting value being the Max of either func PoolInhibPoolMax(pi, di uint32, piGi float32) { - Pools[pi, fsfffb.TotalGi, di] = math32.Max(Pools[pi, fsfffb.TotalGi, di], piGi) + Pools[pi, di, fsfffb.TotalGi] = math32.Max(Pools[pi, di, fsfffb.TotalGi], piGi) } //////// atomic int safe accumulation @@ -235,17 +235,17 @@ func PoolInhibPoolMax(pi, di uint32, piGi float32) { func PoolInhibRawIncrInt(pi, di uint32, spike, geRaw, geExt float32) { floatToInt := float32(uint32(1) << 24) fnn := float32(PoolNNeurons(pi)) - atomic.AddInt32(&PoolsInt[pi, FBsRawInt, di], int32(spike)) - atomic.AddInt32(&PoolsInt[pi, FFsRawInt, di], int32((geRaw/fnn)*floatToInt)) - atomic.AddInt32(&PoolsInt[pi, GeExtRawInt, di], int32((geExt/fnn)*floatToInt)) + atomic.AddInt32(&PoolsInt[pi, di, FBsRawInt], int32(spike)) + atomic.AddInt32(&PoolsInt[pi, di, FFsRawInt], int32((geRaw/fnn)*floatToInt)) + atomic.AddInt32(&PoolsInt[pi, di, GeExtRawInt], int32((geExt/fnn)*floatToInt)) } // IntToRaw computes int values into float32 raw values func PoolInhibIntToRaw(pi, di uint32) { floatFromInt := 1.0 / float32(uint32(1)<<24) - fbs := PoolsInt[pi, FBsRawInt, di] - ffs := PoolsInt[pi, FFsRawInt, di] - geExt := PoolsInt[pi, GeExtRawInt, di] + fbs := PoolsInt[pi, di, FBsRawInt] + ffs := PoolsInt[pi, di, FFsRawInt] + geExt := PoolsInt[pi, di, GeExtRawInt] //gosl:end floatToInt := int32(1) << 24 if ffs < 0 { @@ -257,9 +257,9 @@ func PoolInhibIntToRaw(pi, di uint32) { geExt = floatToInt } //gosl:start - Pools[pi, fsfffb.FBsRaw, di] = float32(fbs) - Pools[pi, fsfffb.FFsRaw, di] = float32(ffs) * floatFromInt - Pools[pi, fsfffb.GeExtRaw, di] = float32(geExt) * floatFromInt + Pools[pi, di, fsfffb.FBsRaw] = float32(fbs) + Pools[pi, di, fsfffb.FFsRaw] = float32(ffs) * floatFromInt + Pools[pi, di, fsfffb.GeExtRaw] = float32(geExt) * floatFromInt } //gosl:end diff --git a/axon/init-layer.go b/axon/init-layer.go index d6ee7822..a4859fd6 100644 --- a/axon/init-layer.go +++ b/axon/init-layer.go @@ -17,17 +17,17 @@ func (ly *Layer) InitWeights(ctx *Context, nt *Network) { //types:add ly.Params.Acts.Dend.HasMod.SetBool(false) li := ly.Index for di := uint32(0); di < ly.MaxData; di++ { - LayerStates.Set(ly.Params.Inhib.ActAvg.Nominal, int(li), int(LayerActMAvg), int(di)) - LayerStates.Set(ly.Params.Inhib.ActAvg.Nominal, int(li), int(LayerActPAvg), int(di)) - LayerStates.Set(1, int(li), int(LayerAvgMaxGeM), int(di)) - LayerStates.Set(1, int(li), int(LayerAvgMaxGiM), int(di)) - LayerStates.Set(1, int(li), int(LayerGiMult), int(di)) - LayerStates.Set(0, int(li), int(LayerPhaseDiff), int(di)) - LayerStates.Set(0, int(li), int(LayerPhaseDiffAvg), int(di)) - LayerStates.Set(0, int(li), int(LayerPhaseDiffVar), int(di)) - LayerStates.Set(-1, int(li), int(LayerRT), int(di)) - LayerStates.Set(0, int(li), int(LayerRewPredPos), int(di)) - LayerStates.Set(0, int(li), int(LayerRewPredNeg), int(di)) + LayerStates.Set(ly.Params.Inhib.ActAvg.Nominal, int(li), int(di), int(LayerActMAvg)) + LayerStates.Set(ly.Params.Inhib.ActAvg.Nominal, int(li), int(di), int(LayerActPAvg)) + LayerStates.Set(1, int(li), int(di), int(LayerAvgMaxGeM)) + LayerStates.Set(1, int(li), int(di), int(LayerAvgMaxGiM)) + LayerStates.Set(1, int(li), int(di), int(LayerGiMult)) + LayerStates.Set(0, int(li), int(di), int(LayerPhaseDiff)) + LayerStates.Set(0, int(li), int(di), int(LayerPhaseDiffAvg)) + LayerStates.Set(0, int(li), int(di), int(LayerPhaseDiffVar)) + LayerStates.Set(-1, int(li), int(di), int(LayerRT)) + LayerStates.Set(0, int(li), int(di), int(LayerRewPredPos)) + LayerStates.Set(0, int(li), int(di), int(LayerRewPredNeg)) } ly.InitActAvg(ctx) ly.InitActs(ctx) @@ -133,8 +133,8 @@ func (ly *Layer) InitActAvgPools(ctx *Context) { randx.PermuteInts(porder, &ly.Network.Rand) } pi := ly.Params.PoolIndex(spi) // only using for idxs - nsi := PoolsInt.Value(int(pi), int(PoolNeurSt), int(0)) - nei := PoolsInt.Value(int(pi), int(PoolNeurEd), int(0)) + nsi := PoolsInt.Value(int(pi), int(0), int(PoolNeurSt)) + nei := PoolsInt.Value(int(pi), int(0), int(PoolNeurEd)) for lni := nsi; lni < nei; lni++ { ni := ly.NeurStIndex + uint32(lni) if NeuronIsOff(ni) { @@ -177,7 +177,7 @@ func (ly *Layer) InitActs(ctx *Context) { //types:add pi := ly.Params.PoolIndex(spi) PoolInit(pi, di) if ly.Params.Acts.Clamp.Add.IsFalse() && ly.Params.Acts.Clamp.IsInput.IsTrue() { - PoolsInt.Set(1, int(pi), int(Clamped), int(di)) + PoolsInt.Set(1, int(pi), int(di), int(Clamped)) } // Target layers are dynamically updated } @@ -333,8 +333,8 @@ func (ly *Layer) DecayStatePool(ctx *Context, pool int, decay, glong, ahp float3 spi := uint32(pool + 1) // 1 based for di := uint32(0); di < ctx.NData; di++ { pi := ly.Params.PoolIndex(spi) - nsi := PoolsInt.Value(int(pi), int(PoolNeurSt), int(di)) - nei := PoolsInt.Value(int(pi), int(PoolNeurEd), int(di)) + nsi := PoolsInt.Value(int(pi), int(di), int(PoolNeurSt)) + nei := PoolsInt.Value(int(pi), int(di), int(PoolNeurEd)) for lni := nsi; lni < nei; lni++ { ni := ly.NeurStIndex + uint32(lni) if NeuronIsOff(ni) { diff --git a/axon/init-layer.goal b/axon/init-layer.goal index ab4598ab..cac47af0 100644 --- a/axon/init-layer.goal +++ b/axon/init-layer.goal @@ -15,17 +15,17 @@ func (ly *Layer) InitWeights(ctx *Context, nt *Network) { //types:add ly.Params.Acts.Dend.HasMod.SetBool(false) li := ly.Index for di := uint32(0); di < ly.MaxData; di++ { - LayerStates[li, LayerActMAvg, di] = ly.Params.Inhib.ActAvg.Nominal - LayerStates[li, LayerActPAvg, di] = ly.Params.Inhib.ActAvg.Nominal - LayerStates[li, LayerAvgMaxGeM, di] = 1 - LayerStates[li, LayerAvgMaxGiM, di] = 1 - LayerStates[li, LayerGiMult, di] = 1 - LayerStates[li, LayerPhaseDiff, di] = 0 - LayerStates[li, LayerPhaseDiffAvg, di] = 0 - LayerStates[li, LayerPhaseDiffVar, di] = 0 - LayerStates[li, LayerRT, di] = -1 - LayerStates[li, LayerRewPredPos, di] = 0 - LayerStates[li, LayerRewPredNeg, di] = 0 + LayerStates[li, di, LayerActMAvg] = ly.Params.Inhib.ActAvg.Nominal + LayerStates[li, di, LayerActPAvg] = ly.Params.Inhib.ActAvg.Nominal + LayerStates[li, di, LayerAvgMaxGeM] = 1 + LayerStates[li, di, LayerAvgMaxGiM] = 1 + LayerStates[li, di, LayerGiMult] = 1 + LayerStates[li, di, LayerPhaseDiff] = 0 + LayerStates[li, di, LayerPhaseDiffAvg] = 0 + LayerStates[li, di, LayerPhaseDiffVar] = 0 + LayerStates[li, di, LayerRT] = -1 + LayerStates[li, di, LayerRewPredPos] = 0 + LayerStates[li, di, LayerRewPredNeg] = 0 } ly.InitActAvg(ctx) ly.InitActs(ctx) @@ -131,8 +131,8 @@ func (ly *Layer) InitActAvgPools(ctx *Context) { randx.PermuteInts(porder, &ly.Network.Rand) } pi := ly.Params.PoolIndex(spi) // only using for idxs - nsi := PoolsInt[pi, PoolNeurSt, 0] - nei := PoolsInt[pi, PoolNeurEd, 0] + nsi := PoolsInt[pi, 0, PoolNeurSt] + nei := PoolsInt[pi, 0, PoolNeurEd] for lni := nsi; lni < nei; lni++ { ni := ly.NeurStIndex + uint32(lni) if NeuronIsOff(ni) { @@ -175,7 +175,7 @@ func (ly *Layer) InitActs(ctx *Context) { //types:add pi := ly.Params.PoolIndex(spi) PoolInit(pi, di) if ly.Params.Acts.Clamp.Add.IsFalse() && ly.Params.Acts.Clamp.IsInput.IsTrue() { - PoolsInt[pi, Clamped, di] = 1 + PoolsInt[pi, di, Clamped] = 1 } // Target layers are dynamically updated } @@ -330,8 +330,8 @@ func (ly *Layer) DecayStatePool(ctx *Context, pool int, decay, glong, ahp float3 spi := uint32(pool + 1) // 1 based for di := uint32(0); di < ctx.NData; di++ { pi := ly.Params.PoolIndex(spi) - nsi := PoolsInt[pi, PoolNeurSt, di] - nei := PoolsInt[pi, PoolNeurEd, di] + nsi := PoolsInt[pi, di, PoolNeurSt] + nei := PoolsInt[pi, di, PoolNeurEd] for lni := nsi; lni < nei; lni++ { ni := ly.NeurStIndex + uint32(lni) if NeuronIsOff(ni) { diff --git a/axon/layer.go b/axon/layer.go index d38891e5..4dbb046a 100644 --- a/axon/layer.go +++ b/axon/layer.go @@ -99,7 +99,7 @@ func (ly *Layer) Defaults() { //types:add ly.Params.Type = ly.Type ly.Params.Defaults() for di := uint32(0); di < ly.MaxData; di++ { - LayerStates.Set(1, int(li), int(LayerGiMult), int(di)) + LayerStates.Set(1, int(li), int(di), int(LayerGiMult)) } ly.Params.Learn.CaLearn.Dt.PDTauForNCycles(int(ctx.ThetaCycles)) ly.Params.Learn.CaSpk.Dt.PDTauForNCycles(int(ctx.ThetaCycles)) @@ -333,8 +333,8 @@ func (ly *Layer) BuildSubPools(ctx *Context) { eoff := int32(ly.Shape.IndexTo1D(py, px, sh[2]-1, sh[3]-1) + 1) for di := uint32(0); di < ly.MaxData; di++ { pi := ly.Params.PoolIndex(spi) - PoolsInt.Set(soff, int(pi), int(PoolNeurSt), int(di)) - PoolsInt.Set(eoff, int(pi), int(PoolNeurEd), int(di)) + PoolsInt.Set(soff, int(pi), int(di), int(PoolNeurSt)) + PoolsInt.Set(eoff, int(pi), int(di), int(PoolNeurEd)) } for lni := soff; lni < eoff; lni++ { ni := ly.NeurStIndex + uint32(lni) @@ -350,9 +350,9 @@ func (ly *Layer) BuildPools(ctx *Context, nn uint32) error { np := 1 + ly.NumPools() for di := uint32(0); di < ly.MaxData; di++ { lpi := ly.Params.PoolIndex(0) - PoolsInt.Set(0, int(lpi), int(PoolNeurSt), int(di)) - PoolsInt.Set(int32(nn), int(lpi), int(PoolNeurEd), int(di)) - PoolsInt.Set(1, int(lpi), int(PoolIsLayer), int(di)) + PoolsInt.Set(0, int(lpi), int(di), int(PoolNeurSt)) + PoolsInt.Set(int32(nn), int(lpi), int(di), int(PoolNeurEd)) + PoolsInt.Set(1, int(lpi), int(di), int(PoolIsLayer)) } if np > 1 { ly.BuildSubPools(ctx) @@ -482,7 +482,7 @@ func (ly *Layer) UnitValue1D(varIndex int, idx, di int) float32 { return GlobalScalars.Value(int(GvSer), int(uint32(di))) case 4: pi := ly.Params.PoolIndex(NeuronIxs.Value(int(ni), int(NrnSubPool))) - return float32(PoolsInt.Value(int(pi), int(PoolGated), int(di))) + return float32(PoolsInt.Value(int(pi), int(di), int(PoolGated))) } } else if NeuronVars(varIndex) >= NeuronVarsN { return NeuronAvgs.Value(int(ni), int(NeuronVars(varIndex)-NeuronVarsN)) @@ -624,9 +624,9 @@ func (ly *Layer) VarRange(varNm string) (min, max float32, err error) { func (ly *Layer) WriteWeightsJSON(w io.Writer, depth int) { li := ly.Index ly.MetaData = make(map[string]string) - ly.MetaData["ActMAvg"] = fmt.Sprintf("%g", LayerStates.Value(int(li), int(LayerActMAvg), int(0))) - ly.MetaData["ActPAvg"] = fmt.Sprintf("%g", LayerStates.Value(int(li), int(LayerActPAvg), int(0))) - ly.MetaData["GiMult"] = fmt.Sprintf("%g", LayerStates.Value(int(li), int(LayerGiMult), int(0))) + ly.MetaData["ActMAvg"] = fmt.Sprintf("%g", LayerStates.Value(int(li), int(0), int(LayerActMAvg))) + ly.MetaData["ActPAvg"] = fmt.Sprintf("%g", LayerStates.Value(int(li), int(0), int(LayerActPAvg))) + ly.MetaData["GiMult"] = fmt.Sprintf("%g", LayerStates.Value(int(li), int(0), int(LayerGiMult))) if ly.Params.IsLearnTrgAvg() { ly.LayerBase.WriteWeightsJSONBase(w, depth, "ActAvg", "TrgAvg") @@ -646,15 +646,15 @@ func (ly *Layer) SetWeights(lw *weights.Layer) error { for di := uint32(0); di < ly.MaxData; di++ { if am, ok := lw.MetaData["ActMAvg"]; ok { pv, _ := strconv.ParseFloat(am, 32) - LayerStates.Set(float32(pv), int(li), int(LayerActMAvg), int(di)) + LayerStates.Set(float32(pv), int(li), int(di), int(LayerActMAvg)) } if ap, ok := lw.MetaData["ActPAvg"]; ok { pv, _ := strconv.ParseFloat(ap, 32) - LayerStates.Set(float32(pv), int(li), int(LayerActPAvg), int(di)) + LayerStates.Set(float32(pv), int(li), int(di), int(LayerActPAvg)) } if gi, ok := lw.MetaData["GiMult"]; ok { pv, _ := strconv.ParseFloat(gi, 32) - LayerStates.Set(float32(pv), int(li), int(LayerGiMult), int(di)) + LayerStates.Set(float32(pv), int(li), int(di), int(LayerGiMult)) } } } diff --git a/axon/layer.goal b/axon/layer.goal index d7059717..d11a4b32 100644 --- a/axon/layer.goal +++ b/axon/layer.goal @@ -97,7 +97,7 @@ func (ly *Layer) Defaults() { //types:add ly.Params.Type = ly.Type ly.Params.Defaults() for di := uint32(0); di < ly.MaxData; di++ { - LayerStates[li, LayerGiMult, di] = 1 + LayerStates[li, di, LayerGiMult] = 1 } ly.Params.Learn.CaLearn.Dt.PDTauForNCycles(int(ctx.ThetaCycles)) ly.Params.Learn.CaSpk.Dt.PDTauForNCycles(int(ctx.ThetaCycles)) @@ -331,8 +331,8 @@ func (ly *Layer) BuildSubPools(ctx *Context) { eoff := int32(ly.Shape.IndexTo1D(py, px, sh[2] - 1, sh[3] - 1) + 1) for di := uint32(0); di < ly.MaxData; di++ { pi := ly.Params.PoolIndex(spi) - PoolsInt[pi, PoolNeurSt, di] = soff - PoolsInt[pi, PoolNeurEd, di] = eoff + PoolsInt[pi, di, PoolNeurSt] = soff + PoolsInt[pi, di, PoolNeurEd] = eoff } for lni := soff; lni < eoff; lni++ { ni := ly.NeurStIndex + uint32(lni) @@ -348,9 +348,9 @@ func (ly *Layer) BuildPools(ctx *Context, nn uint32) error { np := 1 + ly.NumPools() for di := uint32(0); di < ly.MaxData; di++ { lpi := ly.Params.PoolIndex(0) - PoolsInt[lpi, PoolNeurSt, di] = 0 - PoolsInt[lpi, PoolNeurEd, di] = int32(nn) - PoolsInt[lpi, PoolIsLayer, di] = 1 + PoolsInt[lpi, di, PoolNeurSt] = 0 + PoolsInt[lpi, di, PoolNeurEd] = int32(nn) + PoolsInt[lpi, di, PoolIsLayer] = 1 } if np > 1 { ly.BuildSubPools(ctx) @@ -480,7 +480,7 @@ func (ly *Layer) UnitValue1D(varIndex int, idx, di int) float32 { return GlobalScalars[GvSer, uint32(di)] case 4: pi := ly.Params.PoolIndex(NeuronIxs[ni, NrnSubPool]) - return float32(PoolsInt[pi, PoolGated, di]) + return float32(PoolsInt[pi, di, PoolGated]) } } else if NeuronVars(varIndex) >= NeuronVarsN { return NeuronAvgs[ni, NeuronVars(varIndex)-NeuronVarsN] @@ -622,9 +622,9 @@ func (ly *Layer) VarRange(varNm string) (min, max float32, err error) { func (ly *Layer) WriteWeightsJSON(w io.Writer, depth int) { li := ly.Index ly.MetaData = make(map[string]string) - ly.MetaData["ActMAvg"] = fmt.Sprintf("%g", LayerStates[li, LayerActMAvg, 0]) - ly.MetaData["ActPAvg"] = fmt.Sprintf("%g", LayerStates[li, LayerActPAvg, 0]) - ly.MetaData["GiMult"] = fmt.Sprintf("%g", LayerStates[li, LayerGiMult, 0]) + ly.MetaData["ActMAvg"] = fmt.Sprintf("%g", LayerStates[li, 0, LayerActMAvg]) + ly.MetaData["ActPAvg"] = fmt.Sprintf("%g", LayerStates[li, 0, LayerActPAvg]) + ly.MetaData["GiMult"] = fmt.Sprintf("%g", LayerStates[li, 0, LayerGiMult]) if ly.Params.IsLearnTrgAvg() { ly.LayerBase.WriteWeightsJSONBase(w, depth, "ActAvg", "TrgAvg") @@ -644,15 +644,15 @@ func (ly *Layer) SetWeights(lw *weights.Layer) error { for di := uint32(0); di < ly.MaxData; di++ { if am, ok := lw.MetaData["ActMAvg"]; ok { pv, _ := strconv.ParseFloat(am, 32) - LayerStates[li, LayerActMAvg, di] = float32(pv) + LayerStates[li, di, LayerActMAvg] = float32(pv) } if ap, ok := lw.MetaData["ActPAvg"]; ok { pv, _ := strconv.ParseFloat(ap, 32) - LayerStates[li, LayerActPAvg, di] = float32(pv) + LayerStates[li, di, LayerActPAvg] = float32(pv) } if gi, ok := lw.MetaData["GiMult"]; ok { pv, _ := strconv.ParseFloat(gi, 32) - LayerStates[li, LayerGiMult, di] = float32(pv) + LayerStates[li, di, LayerGiMult] = float32(pv) } } } diff --git a/axon/learn-layer.go b/axon/learn-layer.go index 57859aad..5df23833 100644 --- a/axon/learn-layer.go +++ b/axon/learn-layer.go @@ -19,8 +19,8 @@ func (ly *Layer) DTrgSubMean(ctx *Context) { np := ly.NPools for spi := uint32(1); spi < np; spi++ { pi := ly.Params.PoolIndex(spi) // only for idxs - nsi := PoolsInt.Value(int(pi), int(PoolNeurSt), int(0)) - nei := PoolsInt.Value(int(pi), int(PoolNeurEd), int(0)) + nsi := PoolsInt.Value(int(pi), int(0), int(PoolNeurSt)) + nei := PoolsInt.Value(int(pi), int(0), int(PoolNeurEd)) nn := 0 avg := float32(0) for lni := nsi; lni < nei; lni++ { @@ -112,10 +112,10 @@ func (ly *Layer) AdaptInhib(ctx *Context) { return } for di := uint32(0); di < ctx.NData; di++ { - giMult := LayerStates.Value(int(ly.Index), int(LayerGiMult), int(di)) - avg := LayerStates.Value(int(ly.Index), int(LayerActMAvg), int(di)) + giMult := LayerStates.Value(int(ly.Index), int(di), int(LayerGiMult)) + avg := LayerStates.Value(int(ly.Index), int(di), int(LayerActMAvg)) ly.Params.Inhib.ActAvg.Adapt(&giMult, avg) - LayerStates.Set(giMult, int(ly.Index), int(LayerGiMult), int(di)) + LayerStates.Set(giMult, int(ly.Index), int(di), int(LayerGiMult)) } } @@ -129,8 +129,8 @@ func (ly *Layer) AvgDifFromTrgAvg(ctx *Context) { np := ly.NPools for spi := sp; spi < np; spi++ { pi := ly.Params.PoolIndex(spi) - nsi := PoolsInt.Value(int(pi), int(PoolNeurSt), int(0)) - nei := PoolsInt.Value(int(pi), int(PoolNeurEd), int(0)) + nsi := PoolsInt.Value(int(pi), int(0), int(PoolNeurSt)) + nei := PoolsInt.Value(int(pi), int(0), int(PoolNeurEd)) plavg := float32(0) nn := 0 for lni := nsi; lni < nei; lni++ { @@ -162,15 +162,15 @@ func (ly *Layer) AvgDifFromTrgAvg(ctx *Context) { } PoolAvgDifCalc(pi, 0) for di := uint32(1); di < ctx.NData; di++ { // copy to other datas - Pools.Set(Pools.Value(int(pi), int(AvgMaxVarIndex(AMAvgDif, AMCycle, Avg)), int(0)), int(pi), int(AvgMaxVarIndex(AMAvgDif, AMCycle, Avg)), int(di)) - Pools.Set(Pools.Value(int(pi), int(AvgMaxVarIndex(AMAvgDif, AMCycle, Max)), int(0)), int(pi), int(AvgMaxVarIndex(AMAvgDif, AMCycle, Max)), int(di)) + Pools.Set(Pools.Value(int(pi), int(0), int(AvgMaxVarIndex(AMAvgDif, AMCycle, Avg))), int(pi), int(di), int(AvgMaxVarIndex(AMAvgDif, AMCycle, Avg))) + Pools.Set(Pools.Value(int(pi), int(0), int(AvgMaxVarIndex(AMAvgDif, AMCycle, Max))), int(pi), int(di), int(AvgMaxVarIndex(AMAvgDif, AMCycle, Max))) } } if sp == 1 { // update layer pool lpi := ly.Params.PoolIndex(0) PoolAvgDifInit(lpi, 0) - nsi := PoolsInt.Value(int(lpi), int(PoolNeurSt), int(0)) - nei := PoolsInt.Value(int(lpi), int(PoolNeurEd), int(0)) + nsi := PoolsInt.Value(int(lpi), int(0), int(PoolNeurSt)) + nei := PoolsInt.Value(int(lpi), int(0), int(PoolNeurEd)) for lni := nsi; lni < nei; lni++ { ni := ly.NeurStIndex + uint32(lni) if NeuronIsOff(ni) { @@ -181,8 +181,8 @@ func (ly *Layer) AvgDifFromTrgAvg(ctx *Context) { PoolAvgDifCalc(lpi, 0) for di := uint32(1); di < ctx.NData; di++ { // copy to other datas - Pools.Set(Pools.Value(int(lpi), int(AvgMaxVarIndex(AMAvgDif, AMCycle, Avg)), int(0)), int(lpi), int(AvgMaxVarIndex(AMAvgDif, AMCycle, Avg)), int(di)) - Pools.Set(Pools.Value(int(lpi), int(AvgMaxVarIndex(AMAvgDif, AMCycle, Max)), int(0)), int(lpi), int(AvgMaxVarIndex(AMAvgDif, AMCycle, Max)), int(di)) + Pools.Set(Pools.Value(int(lpi), int(0), int(AvgMaxVarIndex(AMAvgDif, AMCycle, Avg))), int(lpi), int(di), int(AvgMaxVarIndex(AMAvgDif, AMCycle, Avg))) + Pools.Set(Pools.Value(int(lpi), int(0), int(AvgMaxVarIndex(AMAvgDif, AMCycle, Max))), int(lpi), int(di), int(AvgMaxVarIndex(AMAvgDif, AMCycle, Max))) } } } diff --git a/axon/learn-layer.goal b/axon/learn-layer.goal index b780b5c0..f64e6a0d 100644 --- a/axon/learn-layer.goal +++ b/axon/learn-layer.goal @@ -17,8 +17,8 @@ func (ly *Layer) DTrgSubMean(ctx *Context) { np := ly.NPools for spi := uint32(1); spi < np; spi++ { pi := ly.Params.PoolIndex(spi) // only for idxs - nsi := PoolsInt[pi, PoolNeurSt, 0] - nei := PoolsInt[pi, PoolNeurEd, 0] + nsi := PoolsInt[pi, 0, PoolNeurSt] + nei := PoolsInt[pi, 0, PoolNeurEd] nn := 0 avg := float32(0) for lni := nsi; lni < nei; lni++ { @@ -110,10 +110,10 @@ func (ly *Layer) AdaptInhib(ctx *Context) { return } for di := uint32(0); di < ctx.NData; di++ { - giMult := LayerStates[ly.Index, LayerGiMult, di] - avg := LayerStates[ly.Index, LayerActMAvg, di] + giMult := LayerStates[ly.Index, di, LayerGiMult] + avg := LayerStates[ly.Index, di, LayerActMAvg] ly.Params.Inhib.ActAvg.Adapt(&giMult, avg) - LayerStates[ly.Index, LayerGiMult, di] = giMult + LayerStates[ly.Index, di, LayerGiMult] = giMult } } @@ -127,8 +127,8 @@ func (ly *Layer) AvgDifFromTrgAvg(ctx *Context) { np := ly.NPools for spi := sp; spi < np; spi++ { pi := ly.Params.PoolIndex(spi) - nsi := PoolsInt[pi, PoolNeurSt, 0] - nei := PoolsInt[pi, PoolNeurEd, 0] + nsi := PoolsInt[pi, 0, PoolNeurSt] + nei := PoolsInt[pi, 0, PoolNeurEd] plavg := float32(0) nn := 0 for lni := nsi; lni < nei; lni++ { @@ -160,15 +160,15 @@ func (ly *Layer) AvgDifFromTrgAvg(ctx *Context) { } PoolAvgDifCalc(pi, 0) for di := uint32(1); di < ctx.NData; di++ { // copy to other datas - Pools[pi, AvgMaxVarIndex(AMAvgDif, AMCycle, Avg), di] = Pools[pi, AvgMaxVarIndex(AMAvgDif, AMCycle, Avg), 0] - Pools[pi, AvgMaxVarIndex(AMAvgDif, AMCycle, Max), di] = Pools[pi, AvgMaxVarIndex(AMAvgDif, AMCycle, Max), 0] + Pools[pi, di, AvgMaxVarIndex(AMAvgDif, AMCycle, Avg)] = Pools[pi, 0, AvgMaxVarIndex(AMAvgDif, AMCycle, Avg)] + Pools[pi, di, AvgMaxVarIndex(AMAvgDif, AMCycle, Max)] = Pools[pi, 0, AvgMaxVarIndex(AMAvgDif, AMCycle, Max)] } } if sp == 1 { // update layer pool lpi := ly.Params.PoolIndex(0) PoolAvgDifInit(lpi, 0) - nsi := PoolsInt[lpi, PoolNeurSt, 0] - nei := PoolsInt[lpi, PoolNeurEd, 0] + nsi := PoolsInt[lpi, 0, PoolNeurSt] + nei := PoolsInt[lpi, 0, PoolNeurEd] for lni := nsi; lni < nei; lni++ { ni := ly.NeurStIndex + uint32(lni) if NeuronIsOff(ni) { @@ -179,8 +179,8 @@ func (ly *Layer) AvgDifFromTrgAvg(ctx *Context) { PoolAvgDifCalc(lpi, 0) for di := uint32(1); di < ctx.NData; di++ { // copy to other datas - Pools[lpi, AvgMaxVarIndex(AMAvgDif, AMCycle, Avg), di] = Pools[lpi, AvgMaxVarIndex(AMAvgDif, AMCycle, Avg), 0] - Pools[lpi, AvgMaxVarIndex(AMAvgDif, AMCycle, Max), di] = Pools[lpi, AvgMaxVarIndex(AMAvgDif, AMCycle, Max), 0] + Pools[lpi, di, AvgMaxVarIndex(AMAvgDif, AMCycle, Avg)] = Pools[lpi, 0, AvgMaxVarIndex(AMAvgDif, AMCycle, Avg)] + Pools[lpi, di, AvgMaxVarIndex(AMAvgDif, AMCycle, Max)] = Pools[lpi, 0, AvgMaxVarIndex(AMAvgDif, AMCycle, Max)] } } } diff --git a/axon/learn-net.go b/axon/learn-net.go index c46ac0a6..995077ec 100644 --- a/axon/learn-net.go +++ b/axon/learn-net.go @@ -147,11 +147,11 @@ func (nt *Network) CollectDWts(dwts *[]float32) bool { } for li, ly := range nt.Layers { nn := ly.NNeurons - (*dwts)[idx+0] = LayerStates.Value(int(li), int(LayerActMAvg), int(0)) - (*dwts)[idx+1] = LayerStates.Value(int(li), int(LayerActPAvg), int(0)) - (*dwts)[idx+2] = LayerStates.Value(int(li), int(LayerAvgMaxGeM), int(0)) - (*dwts)[idx+3] = LayerStates.Value(int(li), int(LayerAvgMaxGiM), int(0)) - (*dwts)[idx+4] = LayerStates.Value(int(li), int(LayerGiMult), int(0)) + (*dwts)[idx+0] = LayerStates.Value(int(li), int(0), int(LayerActMAvg)) + (*dwts)[idx+1] = LayerStates.Value(int(li), int(0), int(LayerActPAvg)) + (*dwts)[idx+2] = LayerStates.Value(int(li), int(0), int(LayerAvgMaxGeM)) + (*dwts)[idx+3] = LayerStates.Value(int(li), int(0), int(LayerAvgMaxGiM)) + (*dwts)[idx+4] = LayerStates.Value(int(li), int(0), int(LayerGiMult)) idx += 5 for lni := uint32(0); lni < nn; lni++ { ni := ly.NeurStIndex + lni @@ -191,11 +191,11 @@ func (nt *Network) SetDWts(dwts []float32, navg int) { davg := 1 / float32(navg) for li, ly := range nt.Layers { nn := ly.NNeurons - LayerStates.Set(davg*dwts[idx+0], int(li), int(LayerActMAvg), int(0)) - LayerStates.Set(davg*dwts[idx+1], int(li), int(LayerActPAvg), int(0)) - LayerStates.Set(davg*dwts[idx+2], int(li), int(LayerAvgMaxGeM), int(0)) - LayerStates.Set(davg*dwts[idx+3], int(li), int(LayerAvgMaxGiM), int(0)) - LayerStates.Set(davg*dwts[idx+4], int(li), int(LayerGiMult), int(0)) + LayerStates.Set(davg*dwts[idx+0], int(li), int(0), int(LayerActMAvg)) + LayerStates.Set(davg*dwts[idx+1], int(li), int(0), int(LayerActPAvg)) + LayerStates.Set(davg*dwts[idx+2], int(li), int(0), int(LayerAvgMaxGeM)) + LayerStates.Set(davg*dwts[idx+3], int(li), int(0), int(LayerAvgMaxGiM)) + LayerStates.Set(davg*dwts[idx+4], int(li), int(0), int(LayerGiMult)) idx += 5 for lni := uint32(0); lni < nn; lni++ { ni := ly.NeurStIndex + lni diff --git a/axon/learn-net.goal b/axon/learn-net.goal index bfd4cd1f..e6c95abf 100644 --- a/axon/learn-net.goal +++ b/axon/learn-net.goal @@ -143,11 +143,11 @@ func (nt *Network) CollectDWts(dwts *[]float32) bool { } for li, ly := range nt.Layers { nn := ly.NNeurons - (*dwts)[idx+0] = LayerStates[li, LayerActMAvg, 0] - (*dwts)[idx+1] = LayerStates[li, LayerActPAvg, 0] - (*dwts)[idx+2] = LayerStates[li, LayerAvgMaxGeM, 0] - (*dwts)[idx+3] = LayerStates[li, LayerAvgMaxGiM, 0] - (*dwts)[idx+4] = LayerStates[li, LayerGiMult, 0] + (*dwts)[idx+0] = LayerStates[li, 0, LayerActMAvg] + (*dwts)[idx+1] = LayerStates[li, 0, LayerActPAvg] + (*dwts)[idx+2] = LayerStates[li, 0, LayerAvgMaxGeM] + (*dwts)[idx+3] = LayerStates[li, 0, LayerAvgMaxGiM] + (*dwts)[idx+4] = LayerStates[li, 0, LayerGiMult] idx += 5 for lni := uint32(0); lni < nn; lni++ { ni := ly.NeurStIndex + lni @@ -187,11 +187,11 @@ func (nt *Network) SetDWts(dwts []float32, navg int) { davg := 1 / float32(navg) for li, ly := range nt.Layers { nn := ly.NNeurons - LayerStates[li, LayerActMAvg, 0] = davg * dwts[idx+0] - LayerStates[li, LayerActPAvg, 0] = davg * dwts[idx+1] - LayerStates[li, LayerAvgMaxGeM, 0] = davg * dwts[idx+2] - LayerStates[li, LayerAvgMaxGiM, 0] = davg * dwts[idx+3] - LayerStates[li, LayerGiMult, 0] = davg * dwts[idx+4] + LayerStates[li, 0, LayerActMAvg] = davg * dwts[idx+0] + LayerStates[li, 0, LayerActPAvg] = davg * dwts[idx+1] + LayerStates[li, 0, LayerAvgMaxGeM] = davg * dwts[idx+2] + LayerStates[li, 0, LayerAvgMaxGiM] = davg * dwts[idx+3] + LayerStates[li, 0, LayerGiMult] = davg * dwts[idx+4] idx += 5 for lni := uint32(0); lni < nn; lni++ { ni := ly.NeurStIndex + lni diff --git a/axon/network.go b/axon/network.go index 57efde0b..8e116867 100644 --- a/axon/network.go +++ b/axon/network.go @@ -739,9 +739,9 @@ func (nt *Network) Build() error { //types:add nix.RubiconNNegUSs = nt.Rubicon.NNegUSs nt.LayParams = make([]LayerParams, nLayers) - sltensor.SetShapeSizes(&nt.LayerStates, nLayers, int(LayerVarsN), maxData) - sltensor.SetShapeSizes(&nt.Pools, totPools, int(PoolVarsN), maxData) - sltensor.SetShapeSizes(&nt.PoolsInt, totPools, int(PoolIntVarsTot), maxData) + sltensor.SetShapeSizes(&nt.LayerStates, nLayers, maxData, int(LayerVarsN)) + sltensor.SetShapeSizes(&nt.Pools, totPools, maxData, int(PoolVarsN)) + sltensor.SetShapeSizes(&nt.PoolsInt, totPools, maxData, int(PoolIntVarsTot)) sltensor.SetShapeSizes(&nt.Neurons, totNeurons, maxData, int(NeuronVarsN)) sltensor.SetShapeSizes(&nt.NeuronAvgs, totNeurons, int(NeuronAvgVarsN)) sltensor.SetShapeSizes(&nt.NeuronIxs, totNeurons, int(NeuronIndexVarsN)) @@ -794,7 +794,7 @@ func (nt *Network) Build() error { //types:add } for pi := 0; pi < np; pi++ { for di := 0; di < maxData; di++ { - nt.PoolsInt.Set(int32(li), int(poolIndex+pi), int(PoolLayerIdx), int(di)) + nt.PoolsInt.Set(int32(li), int(poolIndex+pi), int(di), int(PoolLayerIdx)) } } if ly.Type.IsExt() { @@ -1004,7 +1004,7 @@ func (nt *Network) BuildPathGBuf() { } nix.MaxDelay = maxDel mxlen := maxDel + 1 - sltensor.SetShapeSizes(&nt.PathGBuf, int(nptneur), int(mxlen), int(maxData)) + sltensor.SetShapeSizes(&nt.PathGBuf, int(nptneur), int(maxData), int(mxlen)) sltensor.SetShapeSizes(&nt.PathGSyns, int(nptneur), int(maxData)) npti := uint32(0) diff --git a/axon/network.goal b/axon/network.goal index 2b031899..1b21a802 100644 --- a/axon/network.goal +++ b/axon/network.goal @@ -736,9 +736,9 @@ func (nt *Network) Build() error { //types:add nix.RubiconNNegUSs = nt.Rubicon.NNegUSs nt.LayParams = make([]LayerParams, nLayers) - sltensor.SetShapeSizes(&nt.LayerStates, nLayers, int(LayerVarsN), maxData) - sltensor.SetShapeSizes(&nt.Pools, totPools, int(PoolVarsN), maxData) - sltensor.SetShapeSizes(&nt.PoolsInt, totPools, int(PoolIntVarsTot), maxData) + sltensor.SetShapeSizes(&nt.LayerStates, nLayers, maxData, int(LayerVarsN)) + sltensor.SetShapeSizes(&nt.Pools, totPools, maxData, int(PoolVarsN)) + sltensor.SetShapeSizes(&nt.PoolsInt, totPools, maxData, int(PoolIntVarsTot)) sltensor.SetShapeSizes(&nt.Neurons, totNeurons, maxData, int(NeuronVarsN)) sltensor.SetShapeSizes(&nt.NeuronAvgs, totNeurons, int(NeuronAvgVarsN)) sltensor.SetShapeSizes(&nt.NeuronIxs, totNeurons, int(NeuronIndexVarsN)) @@ -791,7 +791,7 @@ func (nt *Network) Build() error { //types:add } for pi := 0; pi < np; pi++ { for di := 0; di < maxData; di++ { - nt.PoolsInt[poolIndex+pi, PoolLayerIdx, di] = int32(li) + nt.PoolsInt[poolIndex+pi, di, PoolLayerIdx] = int32(li) } } if ly.Type.IsExt() { @@ -1001,7 +1001,7 @@ func (nt *Network) BuildPathGBuf() { } nix.MaxDelay = maxDel mxlen := maxDel + 1 - sltensor.SetShapeSizes(&nt.PathGBuf, int(nptneur), int(mxlen), int(maxData)) + sltensor.SetShapeSizes(&nt.PathGBuf, int(nptneur), int(maxData), int(mxlen)) sltensor.SetShapeSizes(&nt.PathGSyns, int(nptneur), int(maxData)) npti := uint32(0) diff --git a/axon/pcore-layer.go b/axon/pcore-layer.go index 872a0136..0d9a134a 100644 --- a/axon/pcore-layer.go +++ b/axon/pcore-layer.go @@ -106,7 +106,7 @@ func (ly *Layer) MatrixGated(ctx *Context) { opi := oly.Params.PoolIndex(0) // note: NoGo layers don't track gating at the sub-pool level! for di := uint32(0); di < ctx.NData; di++ { - PoolsInt.Set(PoolsInt.Value(int(opi), int(PoolGated), int(di)), int(lpi), int(PoolGated), int(di)) + PoolsInt.Set(PoolsInt.Value(int(opi), int(di), int(PoolGated)), int(lpi), int(di), int(PoolGated)) } return } @@ -158,7 +158,7 @@ func (ly *Layer) MatrixGated(ctx *Context) { if !mtxGated { // nobody did if thal didn't for spi := uint32(0); spi < ly.NPools; spi++ { pi := ly.Params.PoolIndex(spi) - PoolsInt.Set(0, int(pi), int(PoolGated), int(di)) + PoolsInt.Set(0, int(pi), int(di), int(PoolGated)) } } if ctx.PlusPhase.IsTrue() && ly.Params.Matrix.IsVS.IsTrue() { @@ -187,9 +187,9 @@ func (ly *Layer) GatedFromSpkMax(di uint32, thr float32) (bool, int) { if poolIndex < 0 { poolIndex = int(spi) - 1 } - PoolsInt.Set(1, int(pi), int(PoolGated), int(di)) + PoolsInt.Set(1, int(pi), int(di), int(PoolGated)) } else { - PoolsInt.Set(0, int(pi), int(PoolGated), int(di)) + PoolsInt.Set(0, int(pi), int(di), int(PoolGated)) } } } else { @@ -199,9 +199,9 @@ func (ly *Layer) GatedFromSpkMax(di uint32, thr float32) (bool, int) { } } if anyGated { - PoolsInt.Set(1, int(lpi), int(PoolGated), int(di)) + PoolsInt.Set(1, int(lpi), int(di), int(PoolGated)) } else { - PoolsInt.Set(0, int(lpi), int(PoolGated), int(di)) + PoolsInt.Set(0, int(lpi), int(di), int(PoolGated)) } return anyGated, poolIndex } @@ -210,7 +210,7 @@ func (ly *Layer) GatedFromSpkMax(di uint32, thr float32) (bool, int) { // which indicates if any of the layers gated. func (ly *Layer) AnyGated(di uint32) bool { lpi := ly.Params.PoolIndex(0) - return PoolsInt.Value(int(lpi), int(PoolGated), int(di)) > 0 + return PoolsInt.Value(int(lpi), int(di), int(PoolGated)) > 0 } func (ly *Layer) MatrixDefaults() { diff --git a/axon/pcore-layer.goal b/axon/pcore-layer.goal index 57ddd39a..3509ce3d 100644 --- a/axon/pcore-layer.goal +++ b/axon/pcore-layer.goal @@ -104,7 +104,7 @@ func (ly *Layer) MatrixGated(ctx *Context) { opi := oly.Params.PoolIndex(0) // note: NoGo layers don't track gating at the sub-pool level! for di := uint32(0); di < ctx.NData; di++ { - PoolsInt[lpi, PoolGated, di] = PoolsInt[opi, PoolGated, di] + PoolsInt[lpi, di, PoolGated] = PoolsInt[opi, di, PoolGated] } return } @@ -156,7 +156,7 @@ func (ly *Layer) MatrixGated(ctx *Context) { if !mtxGated { // nobody did if thal didn't for spi := uint32(0); spi < ly.NPools; spi++ { pi := ly.Params.PoolIndex(spi) - PoolsInt[pi, PoolGated, di] = 0 + PoolsInt[pi, di, PoolGated] = 0 } } if ctx.PlusPhase.IsTrue() && ly.Params.Matrix.IsVS.IsTrue() { @@ -185,9 +185,9 @@ func (ly *Layer) GatedFromSpkMax(di uint32, thr float32) (bool, int) { if poolIndex < 0 { poolIndex = int(spi) - 1 } - PoolsInt[pi, PoolGated, di] = 1 + PoolsInt[pi, di, PoolGated] = 1 } else { - PoolsInt[pi, PoolGated, di] = 0 + PoolsInt[pi, di, PoolGated] = 0 } } } else { @@ -197,9 +197,9 @@ func (ly *Layer) GatedFromSpkMax(di uint32, thr float32) (bool, int) { } } if anyGated { - PoolsInt[lpi, PoolGated, di] = 1 + PoolsInt[lpi, di, PoolGated] = 1 } else { - PoolsInt[lpi, PoolGated, di] = 0 + PoolsInt[lpi, di, PoolGated] = 0 } return anyGated, poolIndex } @@ -208,7 +208,7 @@ func (ly *Layer) GatedFromSpkMax(di uint32, thr float32) (bool, int) { // which indicates if any of the layers gated. func (ly *Layer) AnyGated(di uint32) bool { lpi := ly.Params.PoolIndex(0) - return PoolsInt[lpi, PoolGated, di] > 0 + return PoolsInt[lpi, di, PoolGated] > 0 } func (ly *Layer) MatrixDefaults() { diff --git a/axon/pool.go b/axon/pool.go index 13f825b2..c8494b18 100644 --- a/axon/pool.go +++ b/axon/pool.go @@ -147,13 +147,13 @@ func AvgMaxIntVarIndex(vr AvgMaxVars, am AvgMax) uint32 { // PoolAvgMax returns an AvgMax value for given variable, phase, // and Avg or Max, for given pool index and data index. func PoolAvgMax(vr AvgMaxVars, phase AvgMaxPhases, am AvgMax, pi, di uint32) float32 { - return Pools.Value(int(pi), int(AvgMaxVarIndex(vr, phase, am)), int(di)) + return Pools.Value(int(pi), int(di), int(AvgMaxVarIndex(vr, phase, am))) } // PoolNNeurons returns the number of neurons in the given pool. // pi = global pool index. func PoolNNeurons(pi uint32) int32 { - return PoolsInt.Value(int(pi), int(PoolNeurEd), int(0)) - PoolsInt.Value(int(pi), int(PoolNeurSt), int(0)) + return PoolsInt.Value(int(pi), int(0), int(PoolNeurEd)) - PoolsInt.Value(int(pi), int(0), int(PoolNeurSt)) } // PoolAvgMaxInit initializes the AvgMax Int accumulators for Cycle vals @@ -161,8 +161,8 @@ func PoolNNeurons(pi uint32) int32 { // pi = global pool index. func PoolAvgMaxInit(pi, di uint32) { for vr := range AMAvgDif { - PoolsInt.Set(0, int(pi), int(AvgMaxIntVarIndex(vr, Avg)), int(di)) - PoolsInt.Set(0, int(pi), int(AvgMaxIntVarIndex(vr, Max)), int(di)) + PoolsInt.Set(0, int(pi), int(di), int(AvgMaxIntVarIndex(vr, Avg))) + PoolsInt.Set(0, int(pi), int(di), int(AvgMaxIntVarIndex(vr, Max))) } } @@ -172,8 +172,8 @@ func PoolAvgMaxZero(pi, di uint32) { PoolAvgMaxInit(pi, di) for vr := range AMAvgDif { for ph := range AvgMaxPhasesN { - Pools.Set(0, int(pi), int(AvgMaxVarIndex(vr, ph, Avg)), int(di)) - Pools.Set(0, int(pi), int(AvgMaxVarIndex(vr, ph, Max)), int(di)) + Pools.Set(0, int(pi), int(di), int(AvgMaxVarIndex(vr, ph, Avg))) + Pools.Set(0, int(pi), int(di), int(AvgMaxVarIndex(vr, ph, Max))) } } } @@ -186,8 +186,8 @@ func PoolAvgMaxUpdateVar(vr AvgMaxVars, pi, di uint32, val float32) { floatToSum := floatToInt / n vis := AvgMaxIntVarIndex(vr, Avg) vim := AvgMaxIntVarIndex(vr, Max) - atomic.AddInt32(PoolsInt.ValuePtr(int(pi), int(vis), int(di)), int32(val*floatToSum)) - atomicx.MaxInt32(PoolsInt.ValuePtr(int(pi), int(vim), int(di)), int32(val*floatToInt)) + atomic.AddInt32(PoolsInt.ValuePtr(int(pi), int(di), int(vis)), int32(val*floatToSum)) + atomicx.MaxInt32(PoolsInt.ValuePtr(int(pi), int(di), int(vim)), int32(val*floatToInt)) } // PoolAvgMaxUpdate updates the AvgMax values based on current neuron values. @@ -205,25 +205,25 @@ func PoolAvgMaxUpdate(pi, di, ni uint32) { func PoolAvgMaxCalcVar(vr AvgMaxVars, pi, di uint32) { floatFromInt := float32(1.0) / float32(uint32(1)<<20) vis := AvgMaxIntVarIndex(vr, Avg) - sum := PoolsInt.Value(int(pi), int(vis), int(di)) + sum := PoolsInt.Value(int(pi), int(di), int(vis)) if sum < 0 { //gosl:end log.Println("PoolAvgMaxCalc overflow in Sum", "pi:", pi, "di:", di, "sum:", sum) //gosl:start sum = int32(uint32(1) << 20) } - Pools.Set(float32(sum)*floatFromInt, int(pi), int(AvgMaxVarIndex(vr, AMCycle, Avg)), int(di)) - PoolsInt.Set(0, int(pi), int(vis), int(di)) + Pools.Set(float32(sum)*floatFromInt, int(pi), int(di), int(AvgMaxVarIndex(vr, AMCycle, Avg))) + PoolsInt.Set(0, int(pi), int(di), int(vis)) vim := AvgMaxIntVarIndex(vr, Max) - mx := PoolsInt.Value(int(pi), int(vim), int(di)) + mx := PoolsInt.Value(int(pi), int(di), int(vim)) if mx < 0 { //gosl:end log.Println("PoolAvgMaxCalc overflow in Max", "pi:", pi, "di:", di, "max:", mx) //gosl:start mx = int32(uint32(1) << 20) } - PoolsInt.Set(0, int(pi), int(vim), int(di)) - Pools.Set(float32(mx)*floatFromInt, int(pi), int(AvgMaxVarIndex(vr, AMCycle, Max)), int(di)) + PoolsInt.Set(0, int(pi), int(di), int(vim)) + Pools.Set(float32(mx)*floatFromInt, int(pi), int(di), int(AvgMaxVarIndex(vr, AMCycle, Max))) } // PoolAvgMaxCalc does Calc on Cycle level, and re-inits @@ -237,8 +237,8 @@ func PoolAvgMaxCalc(pi, di uint32) { // for update start. always left init'd so generally unnecessary. // pi = global pool index. func PoolAvgDifInit(pi, di uint32) { - PoolsInt.Set(0, int(pi), int(AvgMaxIntVarIndex(AMAvgDif, Avg)), int(di)) - PoolsInt.Set(0, int(pi), int(AvgMaxIntVarIndex(AMAvgDif, Max)), int(di)) + PoolsInt.Set(0, int(pi), int(di), int(AvgMaxIntVarIndex(AMAvgDif, Avg))) + PoolsInt.Set(0, int(pi), int(di), int(AvgMaxIntVarIndex(AMAvgDif, Max))) } // PoolAvgDifUpdate updates the AvgMax values for AvgDif Var. @@ -256,39 +256,39 @@ func PoolAvgDifCalc(pi, di uint32) { // and Plus values into Prev. func PoolCycleToMinus(pi, di uint32) { for vr := range AMAvgDif { // don't do AvgDif - Pools.Set(Pools.Value(int(pi), int(AvgMaxVarIndex(vr, AMCycle, Avg)), int(di)), int(pi), int(AvgMaxVarIndex(vr, AMMinus, Avg)), int(di)) - Pools.Set(Pools.Value(int(pi), int(AvgMaxVarIndex(vr, AMCycle, Max)), int(di)), int(pi), int(AvgMaxVarIndex(vr, AMMinus, Max)), int(di)) + Pools.Set(Pools.Value(int(pi), int(di), int(AvgMaxVarIndex(vr, AMCycle, Avg))), int(pi), int(di), int(AvgMaxVarIndex(vr, AMMinus, Avg))) + Pools.Set(Pools.Value(int(pi), int(di), int(AvgMaxVarIndex(vr, AMCycle, Max))), int(pi), int(di), int(AvgMaxVarIndex(vr, AMMinus, Max))) - Pools.Set(Pools.Value(int(pi), int(AvgMaxVarIndex(vr, AMPlus, Avg)), int(di)), int(pi), int(AvgMaxVarIndex(vr, AMPrev, Avg)), int(di)) - Pools.Set(Pools.Value(int(pi), int(AvgMaxVarIndex(vr, AMPlus, Max)), int(di)), int(pi), int(AvgMaxVarIndex(vr, AMPrev, Max)), int(di)) + Pools.Set(Pools.Value(int(pi), int(di), int(AvgMaxVarIndex(vr, AMPlus, Avg))), int(pi), int(di), int(AvgMaxVarIndex(vr, AMPrev, Avg))) + Pools.Set(Pools.Value(int(pi), int(di), int(AvgMaxVarIndex(vr, AMPlus, Max))), int(pi), int(di), int(AvgMaxVarIndex(vr, AMPrev, Max))) } } // PoolCycleToPlus grabs current Cycle values into the Plus phase values. func PoolCycleToPlus(pi, di uint32) { for vr := range AMAvgDif { // don't do AvgDif - Pools.Set(Pools.Value(int(pi), int(AvgMaxVarIndex(vr, AMCycle, Avg)), int(di)), int(pi), int(AvgMaxVarIndex(vr, AMPlus, Avg)), int(di)) - Pools.Set(Pools.Value(int(pi), int(AvgMaxVarIndex(vr, AMCycle, Max)), int(di)), int(pi), int(AvgMaxVarIndex(vr, AMPlus, Max)), int(di)) + Pools.Set(Pools.Value(int(pi), int(di), int(AvgMaxVarIndex(vr, AMCycle, Avg))), int(pi), int(di), int(AvgMaxVarIndex(vr, AMPlus, Avg))) + Pools.Set(Pools.Value(int(pi), int(di), int(AvgMaxVarIndex(vr, AMCycle, Max))), int(pi), int(di), int(AvgMaxVarIndex(vr, AMPlus, Max))) } } // PoolInit is callled during InitActs func PoolInit(pi, di uint32) { PoolInhibInit(pi, di) - PoolsInt.Set(0, int(pi), int(PoolGated), int(di)) + PoolsInt.Set(0, int(pi), int(di), int(PoolGated)) PoolAvgMaxZero(pi, di) } // PoolPoolGi computes the total inhibitory conductance for the pool. func PoolPoolGi(ctx *Context, pi, di uint32) { - if PoolsInt.Value(int(pi), int(PoolIsLayer), int(di)) > 0 { + if PoolsInt.Value(int(pi), int(di), int(PoolIsLayer)) > 0 { return } - li := PoolsInt.Value(int(pi), int(PoolLayerIdx), int(di)) + li := PoolsInt.Value(int(pi), int(di), int(PoolLayerIdx)) PoolAvgMaxCalc(pi, di) PoolInhibIntToRaw(pi, di) ly := GetLayers(uint32(li)) - giMult := LayerStates.Value(int(li), int(LayerGiMult), int(di)) + giMult := LayerStates.Value(int(li), int(di), int(LayerGiMult)) lyIsOn := (ly.Inhib.Layer.On == 1) lpi := ly.PoolIndex(uint32(0)) ly.SubPoolGiFromSpikes(ctx, lpi, pi, di, lyIsOn, giMult) diff --git a/axon/pool.goal b/axon/pool.goal index fca549f8..2d30c5c7 100644 --- a/axon/pool.goal +++ b/axon/pool.goal @@ -145,13 +145,13 @@ func AvgMaxIntVarIndex(vr AvgMaxVars, am AvgMax) uint32 { // PoolAvgMax returns an AvgMax value for given variable, phase, // and Avg or Max, for given pool index and data index. func PoolAvgMax(vr AvgMaxVars, phase AvgMaxPhases, am AvgMax, pi, di uint32) float32 { - return Pools[pi, AvgMaxVarIndex(vr, phase, am), di] + return Pools[pi, di, AvgMaxVarIndex(vr, phase, am)] } // PoolNNeurons returns the number of neurons in the given pool. // pi = global pool index. func PoolNNeurons(pi uint32) int32 { - return PoolsInt[pi, PoolNeurEd, 0] - PoolsInt[pi, PoolNeurSt, 0] + return PoolsInt[pi, 0, PoolNeurEd] - PoolsInt[pi, 0, PoolNeurSt] } // PoolAvgMaxInit initializes the AvgMax Int accumulators for Cycle vals @@ -159,8 +159,8 @@ func PoolNNeurons(pi uint32) int32 { // pi = global pool index. func PoolAvgMaxInit(pi, di uint32) { for vr := range AMAvgDif { - PoolsInt[pi, AvgMaxIntVarIndex(vr, Avg), di] = 0 - PoolsInt[pi, AvgMaxIntVarIndex(vr, Max), di] = 0 + PoolsInt[pi, di, AvgMaxIntVarIndex(vr, Avg)] = 0 + PoolsInt[pi, di, AvgMaxIntVarIndex(vr, Max)] = 0 } } @@ -170,8 +170,8 @@ func PoolAvgMaxZero(pi, di uint32) { PoolAvgMaxInit(pi, di) for vr := range AMAvgDif { for ph := range AvgMaxPhasesN { - Pools[pi, AvgMaxVarIndex(vr, ph, Avg), di] = 0 - Pools[pi, AvgMaxVarIndex(vr, ph, Max), di] = 0 + Pools[pi, di, AvgMaxVarIndex(vr, ph, Avg)] = 0 + Pools[pi, di, AvgMaxVarIndex(vr, ph, Max)] = 0 } } } @@ -184,8 +184,8 @@ func PoolAvgMaxUpdateVar(vr AvgMaxVars, pi, di uint32, val float32) { floatToSum := floatToInt / n vis := AvgMaxIntVarIndex(vr, Avg) vim := AvgMaxIntVarIndex(vr, Max) - atomic.AddInt32(&PoolsInt[pi, vis, di], int32(val * floatToSum)) - atomicx.MaxInt32(&PoolsInt[pi, vim, di], int32(val * floatToInt)) + atomic.AddInt32(&PoolsInt[pi, di, vis], int32(val * floatToSum)) + atomicx.MaxInt32(&PoolsInt[pi, di, vim], int32(val * floatToInt)) } // PoolAvgMaxUpdate updates the AvgMax values based on current neuron values. @@ -203,25 +203,25 @@ func PoolAvgMaxUpdate(pi, di, ni uint32) { func PoolAvgMaxCalcVar(vr AvgMaxVars, pi, di uint32) { floatFromInt := float32(1.0) / float32(uint32(1) << 20) vis := AvgMaxIntVarIndex(vr, Avg) - sum := PoolsInt[pi, vis, di] + sum := PoolsInt[pi, di, vis] if sum < 0 { //gosl:end log.Println("PoolAvgMaxCalc overflow in Sum", "pi:", pi, "di:", di, "sum:", sum) //gosl:start sum = int32(uint32(1) << 20) } - Pools[pi, AvgMaxVarIndex(vr, AMCycle, Avg), di] = float32(sum) * floatFromInt - PoolsInt[pi, vis, di] = 0 + Pools[pi, di, AvgMaxVarIndex(vr, AMCycle, Avg)] = float32(sum) * floatFromInt + PoolsInt[pi, di, vis] = 0 vim := AvgMaxIntVarIndex(vr, Max) - mx := PoolsInt[pi, vim, di] + mx := PoolsInt[pi, di, vim] if mx < 0 { //gosl:end log.Println("PoolAvgMaxCalc overflow in Max", "pi:", pi, "di:", di, "max:", mx) //gosl:start mx = int32(uint32(1) << 20) } - PoolsInt[pi, vim, di] = 0 - Pools[pi, AvgMaxVarIndex(vr, AMCycle, Max), di] = float32(mx) * floatFromInt + PoolsInt[pi, di, vim] = 0 + Pools[pi, di, AvgMaxVarIndex(vr, AMCycle, Max)] = float32(mx) * floatFromInt } // PoolAvgMaxCalc does Calc on Cycle level, and re-inits @@ -235,8 +235,8 @@ func PoolAvgMaxCalc(pi, di uint32) { // for update start. always left init'd so generally unnecessary. // pi = global pool index. func PoolAvgDifInit(pi, di uint32) { - PoolsInt[pi, AvgMaxIntVarIndex(AMAvgDif, Avg), di] = 0 - PoolsInt[pi, AvgMaxIntVarIndex(AMAvgDif, Max), di] = 0 + PoolsInt[pi, di, AvgMaxIntVarIndex(AMAvgDif, Avg)] = 0 + PoolsInt[pi, di, AvgMaxIntVarIndex(AMAvgDif, Max)] = 0 } // PoolAvgDifUpdate updates the AvgMax values for AvgDif Var. @@ -254,39 +254,39 @@ func PoolAvgDifCalc(pi, di uint32) { // and Plus values into Prev. func PoolCycleToMinus(pi, di uint32) { for vr := range AMAvgDif { // don't do AvgDif - Pools[pi, AvgMaxVarIndex(vr, AMMinus, Avg), di] = Pools[pi, AvgMaxVarIndex(vr, AMCycle, Avg), di] - Pools[pi, AvgMaxVarIndex(vr, AMMinus, Max), di] = Pools[pi, AvgMaxVarIndex(vr, AMCycle, Max), di] + Pools[pi, di, AvgMaxVarIndex(vr, AMMinus, Avg)] = Pools[pi, di, AvgMaxVarIndex(vr, AMCycle, Avg)] + Pools[pi, di, AvgMaxVarIndex(vr, AMMinus, Max)] = Pools[pi, di, AvgMaxVarIndex(vr, AMCycle, Max)] - Pools[pi, AvgMaxVarIndex(vr, AMPrev, Avg), di] = Pools[pi, AvgMaxVarIndex(vr, AMPlus, Avg), di] - Pools[pi, AvgMaxVarIndex(vr, AMPrev, Max), di] = Pools[pi, AvgMaxVarIndex(vr, AMPlus, Max), di] + Pools[pi, di, AvgMaxVarIndex(vr, AMPrev, Avg)] = Pools[pi, di, AvgMaxVarIndex(vr, AMPlus, Avg)] + Pools[pi, di, AvgMaxVarIndex(vr, AMPrev, Max)] = Pools[pi, di, AvgMaxVarIndex(vr, AMPlus, Max)] } } // PoolCycleToPlus grabs current Cycle values into the Plus phase values. func PoolCycleToPlus(pi, di uint32) { for vr := range AMAvgDif { // don't do AvgDif - Pools[pi, AvgMaxVarIndex(vr, AMPlus, Avg), di] = Pools[pi, AvgMaxVarIndex(vr, AMCycle, Avg), di] - Pools[pi, AvgMaxVarIndex(vr, AMPlus, Max), di] = Pools[pi, AvgMaxVarIndex(vr, AMCycle, Max), di] + Pools[pi, di, AvgMaxVarIndex(vr, AMPlus, Avg)] = Pools[pi, di, AvgMaxVarIndex(vr, AMCycle, Avg)] + Pools[pi, di, AvgMaxVarIndex(vr, AMPlus, Max)] = Pools[pi, di, AvgMaxVarIndex(vr, AMCycle, Max)] } } // PoolInit is callled during InitActs func PoolInit(pi, di uint32) { PoolInhibInit(pi, di) - PoolsInt[pi, PoolGated, di] = 0 + PoolsInt[pi, di, PoolGated] = 0 PoolAvgMaxZero(pi, di) } // PoolPoolGi computes the total inhibitory conductance for the pool. func PoolPoolGi(ctx *Context, pi, di uint32) { - if PoolsInt[pi, PoolIsLayer, di] > 0 { + if PoolsInt[pi, di, PoolIsLayer] > 0 { return } - li := PoolsInt[pi, PoolLayerIdx, di] + li := PoolsInt[pi, di, PoolLayerIdx] PoolAvgMaxCalc(pi, di) PoolInhibIntToRaw(pi, di) ly := GetLayers(uint32(li)) - giMult := LayerStates[li, LayerGiMult, di] + giMult := LayerStates[li, di, LayerGiMult] lyIsOn := (ly.Inhib.Layer.On == 1) lpi := ly.PoolIndex(uint32(0)) ly.SubPoolGiFromSpikes(ctx, lpi, pi, di, lyIsOn, giMult) diff --git a/axon/shaders/BetweenGi.wgsl b/axon/shaders/BetweenGi.wgsl index 79630236..5503d29d 100644 --- a/axon/shaders/BetweenGi.wgsl +++ b/axon/shaders/BetweenGi.wgsl @@ -83,12 +83,12 @@ fn IndexI323D(s0: i32, s1: i32, s2: i32, i0: u32, i1: u32, i2: u32) -> u32 { ///////////// import: "act-layer.go" fn LayerParams_BetweenGi(ly: ptr, ctx: ptr, di: u32) { var lpi = LayerParams_PoolIndex(ly, u32(u32(0))); - var maxGi = Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(lpi),u32(TotalGi),u32(di))]; + var maxGi = Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(lpi),u32(di),u32(TotalGi))]; maxGi = LayerParams_BetweenLayerGiMax(ly, di, maxGi, (*ly).LayInhib.Index1); maxGi = LayerParams_BetweenLayerGiMax(ly, di, maxGi, (*ly).LayInhib.Index2); maxGi = LayerParams_BetweenLayerGiMax(ly, di, maxGi, (*ly).LayInhib.Index3); maxGi = LayerParams_BetweenLayerGiMax(ly, di, maxGi, (*ly).LayInhib.Index4); - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(lpi),u32(TotalGi),u32(di))] = maxGi; // our inhib is max of us and everyone in the layer pool + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(lpi),u32(di),u32(TotalGi))] = maxGi; // our inhib is max of us and everyone in the layer pool } fn LayerParams_BetweenLayerGiMax(ly: ptr, di: u32, maxGi: f32, layIndex: i32) -> f32 { if (layIndex < 0) { @@ -96,7 +96,7 @@ fn LayerParams_BetweenLayerGiMax(ly: ptr, di: u32, maxGi: } var oly = Layers[u32(layIndex)]; var opi = LayerParams_PoolIndex(&oly, u32(u32(0))); - var ogi = Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(opi),u32(TotalGi),u32(di))]; + var ogi = Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(opi),u32(di),u32(TotalGi))]; if (ogi > maxGi) { return ogi; }return maxGi; diff --git a/axon/shaders/CycleNeuron.wgsl b/axon/shaders/CycleNeuron.wgsl index 589fa180..9a82a578 100644 --- a/axon/shaders/CycleNeuron.wgsl +++ b/axon/shaders/CycleNeuron.wgsl @@ -128,7 +128,7 @@ fn LayerParams_SpecialPreGs(ly: ptr, ctx: ptr 0; @@ -331,9 +331,9 @@ fn LayerParams_GFromRawSyn(ly: ptr, ctx: ptr, ctx: ptr, pi: u32,ni: u32,di: u32) { - var giMult = LayerStates[IndexF323D(LayerStates[0], LayerStates[1], LayerStates[2], u32((*ly).Index),u32(LayerGiMult),u32(di))]; - var gi = giMult*Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(TotalGi),u32(di))] + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GiSyn))] + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GiNoise))] + NeuroModParams_GiFromACh(&(*ly).Learn.NeuroMod, GlobalScalars[IndexF322D(GlobalScalars[0], GlobalScalars[1], u32(GvACh),u32(di))]); - var ssgi = Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(SSGi),u32(di))]; + var giMult = LayerStates[IndexF323D(LayerStates[0], LayerStates[1], LayerStates[2], u32((*ly).Index),u32(di),u32(LayerGiMult))]; + var gi = giMult*Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(TotalGi))] + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GiSyn))] + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GiNoise))] + NeuroModParams_GiFromACh(&(*ly).Learn.NeuroMod, GlobalScalars[IndexF322D(GlobalScalars[0], GlobalScalars[1], u32(GvACh),u32(di))]); + var ssgi = Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(SSGi))]; Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Gi))] = gi; Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(SSGiDend))] = 0.0; if ((*ctx).PlusPhase == 1 && (*ly).Type == PulvinarLayer) { @@ -2063,11 +2063,11 @@ fn AvgMaxVarIndex(vr: AvgMaxVars, phase: AvgMaxPhases, am: AvgMax) -> u32 { return u32(poolFloatAvgMaxStart) + u32(vr)*u32(AvgMaxN)*u32(AvgMaxPhasesN) + u32(phase)*u32(AvgMaxN) + u32(am); } fn PoolAvgMax(vr: AvgMaxVars, phase: AvgMaxPhases, am: AvgMax, pi: u32,di: u32) -> f32 { - return Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(AvgMaxVarIndex(vr, phase, am)),u32(di))]; + return Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(AvgMaxVarIndex(vr, phase, am)))]; } fn PoolNNeurons(pi: u32) -> i32 { - return PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(PoolNeurEd),u32(0))] - PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[ - 2], u32(pi),u32(PoolNeurSt),u32(0))]; + return PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(0),u32(PoolNeurEd))] - PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[ + 2], u32(pi),u32(0),u32(PoolNeurSt))]; } ///////////// import: "rand.go" diff --git a/axon/shaders/CyclePost.wgsl b/axon/shaders/CyclePost.wgsl index f8f52a0b..075504d3 100644 --- a/axon/shaders/CyclePost.wgsl +++ b/axon/shaders/CyclePost.wgsl @@ -123,8 +123,8 @@ fn LayerParams_CyclePost(ly: ptr, ctx: ptr, ctx: ptr, lpi: u32,di: u32) { var casp = PoolAvgMax(AMCaSpkP, AMCycle, Max, lpi, di); if ((*ctx).Cycle >= (*ly).Acts.Dt.MaxCycStart && casp > 0.5) { // todo: param - if (LayerStates[IndexF323D(LayerStates[0], LayerStates[1], LayerStates[2], u32((*ly).Index),u32(LayerRT),u32(di))] <= 0) { - LayerStates[IndexF323D(LayerStates[0], LayerStates[1], LayerStates[2], u32((*ly).Index),u32(LayerRT),u32(di))] = f32((*ctx).Cycle); + if (LayerStates[IndexF323D(LayerStates[0], LayerStates[1], LayerStates[2], u32((*ly).Index),u32(di),u32(LayerRT))] <= 0) { + LayerStates[IndexF323D(LayerStates[0], LayerStates[1], LayerStates[2], u32((*ly).Index),u32(di),u32(LayerRT))] = f32((*ctx).Cycle); } } } @@ -147,7 +147,7 @@ fn LayerParams_CyclePostLDTLayer(ly: ptr, ctx: ptr, ctx: ptr, di: u32) { var pli = u32((*ly).RWDa.RWPredLayIndex); - var pred = LayerStates[IndexF323D(LayerStates[0], LayerStates[1], LayerStates[2], u32(pli),u32(LayerRewPredPos),u32(di))] - LayerStates[IndexF323D(LayerStates[0], LayerStates[1], LayerStates[2], u32(pli),u32(LayerRewPredNeg),u32(di))]; + var pred = LayerStates[IndexF323D(LayerStates[0], LayerStates[1], LayerStates[2], u32(pli),u32(di),u32(LayerRewPredPos))] - LayerStates[IndexF323D(LayerStates[0], LayerStates[1], LayerStates[2], u32(pli),u32(di),u32(LayerRewPredNeg))]; GlobalScalars[IndexF322D(GlobalScalars[0], GlobalScalars[ // record 1], u32(GvRewPred),u32(di))] = pred; var da = f32(0); @@ -161,7 +161,7 @@ fn LayerParams_CyclePostTDPredLayer(ly: ptr, ctx: ptr, ctx: ptr, di: u32) { @@ -172,19 +172,19 @@ fn LayerParams_CyclePostTDIntegLayer(ly: ptr, ctx: ptr, ctx: ptr, di: u32) { var ili = u32((*ly).TDDa.TDIntegLayIndex); - var da = LayerStates[IndexF323D(LayerStates[0], LayerStates[1], LayerStates[2], u32(ili),u32(LayerRewPredPos),u32(di))] - LayerStates[IndexF323D(LayerStates[0], LayerStates[1], LayerStates[2], u32(ili),u32(LayerRewPredNeg),u32(di))]; + var da = LayerStates[IndexF323D(LayerStates[0], LayerStates[1], LayerStates[2], u32(ili),u32(di),u32(LayerRewPredPos))] - LayerStates[IndexF323D(LayerStates[0], LayerStates[1], LayerStates[2], u32(ili),u32(di),u32(LayerRewPredNeg))]; if ((*ctx).PlusPhase == 0) { da = f32(0); } @@ -1263,7 +1263,7 @@ fn AvgMaxVarIndex(vr: AvgMaxVars, phase: AvgMaxPhases, am: AvgMax) -> u32 { return u32(poolFloatAvgMaxStart) + u32(vr)*u32(AvgMaxN)*u32(AvgMaxPhasesN) + u32(phase)*u32(AvgMaxN) + u32(am); } fn PoolAvgMax(vr: AvgMaxVars, phase: AvgMaxPhases, am: AvgMax, pi: u32,di: u32) -> f32 { - return Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(AvgMaxVarIndex(vr, phase, am)),u32(di))]; + return Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(AvgMaxVarIndex(vr, phase, am)))]; } ///////////// import: "rand.go" diff --git a/axon/shaders/GatherSpikes.wgsl b/axon/shaders/GatherSpikes.wgsl index 3bd183a4..bf0a0741 100644 --- a/axon/shaders/GatherSpikes.wgsl +++ b/axon/shaders/GatherSpikes.wgsl @@ -108,7 +108,7 @@ fn LayerParams_GiFromSpikes(ly: ptr, ctx: ptr, ctx: ptr, ly: ptr, ni: u32,di: u32,lni: u32) { var deli = SynComParams_ReadOff(&(*pt).Com, (*ctx).CyclesTotal); var npti = (*pt).Indexes.NPathNeurSt + lni; - var gRaw = SynComParams_FloatFromGBuf(&(*pt).Com, PathGBuf[IndexI323D(PathGBuf[0], PathGBuf[1], PathGBuf[2], u32(npti),u32(deli),u32(di))]); - PathGBuf[IndexI323D(PathGBuf[0], PathGBuf[1], PathGBuf[2], u32(npti),u32(deli),u32(di))] = 0; + var gRaw = SynComParams_FloatFromGBuf(&(*pt).Com, PathGBuf[IndexI323D(PathGBuf[0], PathGBuf[1], PathGBuf[2], u32(npti),u32(di),u32(deli))]); + PathGBuf[IndexI323D(PathGBuf[0], PathGBuf[1], PathGBuf[2], u32(npti),u32(di),u32(deli))] = 0; var gsyn = PathGSyns[IndexF322D(PathGSyns[0], PathGSyns[1], u32(npti),u32(di))]; PathParams_GatherSpikesGSyn(pt, ctx, ly, ni, di, gRaw, &gsyn); PathGSyns[IndexF322D(PathGSyns[0], PathGSyns[ @@ -675,9 +675,9 @@ struct InhibParams { fn PoolInhibRawIncrInt(pi: u32,di: u32, spike: f32,geRaw: f32,geExt: f32) { var floatToInt = f32(u32(1) << 24); var fnn = f32(PoolNNeurons(pi)); - atomicAdd(&PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(FBsRawInt),u32(di))], i32(spike)); - atomicAdd(&PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(FFsRawInt),u32(di))], i32((geRaw/fnn)*floatToInt)); - atomicAdd(&PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(GeExtRawInt),u32(di))], i32((geExt/fnn)*floatToInt)); + atomicAdd(&PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(di),u32(FBsRawInt))], i32(spike)); + atomicAdd(&PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(di),u32(FFsRawInt))], i32((geRaw/fnn)*floatToInt)); + atomicAdd(&PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(di),u32(GeExtRawInt))], i32((geExt/fnn)*floatToInt)); } ///////////// import: "kinase-params.go" @@ -1230,16 +1230,16 @@ const PoolVarsN = poolFloatAvgMaxStart + InhibVars(i32(AvgMaxVarsN)*i32(AvgMaxN const PoolIntVarsTot = PoolIntAvgMaxStart + PoolIntVars(i32(AvgMaxVarsN)*i32(AvgMaxN)); const avgMaxToNeuron = array(CaSpkP, CaSpkD, SpkMax, Act, GeInt, GiInt); fn AvgMaxIntVarIndex(vr: AvgMaxVars, am: AvgMax) -> u32 { return u32(PoolIntAvgMaxStart) + u32(vr)*u32(AvgMaxN) + u32(am); } -fn PoolNNeurons(pi: u32) -> i32 { return PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(PoolNeurEd),u32(0))] - PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[ -2], u32(pi),u32(PoolNeurSt),u32(0))]; } +fn PoolNNeurons(pi: u32) -> i32 { return PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(0),u32(PoolNeurEd))] - PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[ +2], u32(pi),u32(0),u32(PoolNeurSt))]; } fn PoolAvgMaxUpdateVar(vr: AvgMaxVars, pi: u32,di: u32, val: f32) { var n = f32(PoolNNeurons(pi)); var floatToInt = f32(u32(1) << 20); var floatToSum = floatToInt / n; var vis = AvgMaxIntVarIndex(vr, Avg); var vim = AvgMaxIntVarIndex(vr, Max); - atomicAdd(&PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(vis),u32(di))], i32(val*floatToSum)); - atomicMax(&PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(vim),u32(di))], i32(val*floatToInt)); + atomicAdd(&PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(di),u32(vis))], i32(val*floatToSum)); + atomicMax(&PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(di),u32(vim))], i32(val*floatToInt)); } fn PoolAvgMaxUpdate(pi: u32,di: u32,ni: u32) { PoolAvgMaxUpdateVar(AMCaSpkP, pi, di, abs(Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(avgMaxToNeuron[AMCaSpkP]))])); diff --git a/axon/shaders/LayerGi.wgsl b/axon/shaders/LayerGi.wgsl index 9568a3d3..37e5d3be 100644 --- a/axon/shaders/LayerGi.wgsl +++ b/axon/shaders/LayerGi.wgsl @@ -90,7 +90,7 @@ fn LayerParams_LayerGi(ly: ptr, ctx: ptr fn LayerParams_LayPoolGiFromSpikes(ly: ptr, ctx: ptr, lpi: u32,di: u32) { PoolInhibSpikesFromRaw(lpi, di); PoolInhib(&(*ly).Inhib.Layer, lpi, di, LayerStates[IndexF323D(LayerStates[0], LayerStates[1], LayerStates[ - 2], u32((*ly).Index),u32(LayerGiMult),u32(di))]); + 2], u32((*ly).Index),u32(di),u32(LayerGiMult))]); } ///////////// import: "act-net.go" @@ -609,68 +609,68 @@ fn PoolInhib(fb: ptr, pi: u32,di: u32, gimult: f32) { if ((*fb).On == 0) { PoolInhibZero(pi, di);return; } - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FFAvg),u32(di))] += (*fb).FFAvgDt * (Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FFs),u32(di))] - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FFAvg),u32(di))]); - var fsi = Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FSi),u32(di))]; - fsi = GiParams_FSiFromFFs(fb, fsi, Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FFs),u32(di))], Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FBs),u32(di))]); - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FSi),u32(di))] = fsi; - var clamped = PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(Clamped),u32(di))] > 0; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FSGi),u32(di))] = (*fb).Gi * GiParams_FS(fb, fsi, Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(GeExts),u32(di))], clamped); - var ssf = Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(SSf),u32(di))]; - var ssi = Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(SSi),u32(di))]; - GiParams_SSFromFBs(fb, &ssf, &ssi, Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FBs),u32(di))]); - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(SSGi),u32(di))] = (*fb).Gi * (*fb).SS * ssi; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(SSf),u32(di))] = ssf; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(SSi),u32(di))] = ssi; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(TotalGi),u32(di))] = PoolInhibGiFromFSSS(pi, di) + (*fb).FFPrv*Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FFAvgPrv),u32(di))]; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FFAvg))] += (*fb).FFAvgDt * (Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FFs))] - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FFAvg))]); + var fsi = Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FSi))]; + fsi = GiParams_FSiFromFFs(fb, fsi, Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FFs))], Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FBs))]); + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FSi))] = fsi; + var clamped = PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(di),u32(Clamped))] > 0; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FSGi))] = (*fb).Gi * GiParams_FS(fb, fsi, Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(GeExts))], clamped); + var ssf = Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(SSf))]; + var ssi = Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(SSi))]; + GiParams_SSFromFBs(fb, &ssf, &ssi, Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FBs))]); + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(SSGi))] = (*fb).Gi * (*fb).SS * ssi; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(SSf))] = ssf; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(SSi))] = ssi; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(TotalGi))] = PoolInhibGiFromFSSS(pi, di) + (*fb).FFPrv*Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FFAvgPrv))]; PoolInhibSaveOrig(pi, di); } fn PoolInhibInitRaw(pi: u32,di: u32) { - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FFsRaw),u32(di))] = 0.0; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FBsRaw),u32(di))] = 0.0; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(GeExtRaw),u32(di))] = 0.0; - PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(FFsRawInt),u32(di))] = 0; - PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(FBsRawInt),u32(di))] = 0; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FFsRaw))] = 0.0; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FBsRaw))] = 0.0; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(GeExtRaw))] = 0.0; + PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(di),u32(FFsRawInt))] = 0; + PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(di),u32(FBsRawInt))] = 0; PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], - u32(pi),u32(GeExtRawInt),u32(di))] = 0; + u32(pi),u32(di),u32(GeExtRawInt))] = 0; } fn PoolInhibZero(pi: u32,di: u32) { - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FFs),u32(di))] = 0.0; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FBs),u32(di))] = 0.0; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(GeExts),u32(di))] = 0.0; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FSi),u32(di))] = 0.0; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(SSi),u32(di))] = 0.0; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(SSf),u32(di))] = 0.0; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FSGi),u32(di))] = 0.0; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(SSGi),u32(di))] = 0.0; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(TotalGi),u32(di))] = 0.0; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FFAvg),u32(di))] = 0.0; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FFAvgPrv),u32(di))] = 0.0; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(GiOrig),u32(di))] = 0.0; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(LayGi),u32(di))] = 0.0; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FFs))] = 0.0; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FBs))] = 0.0; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(GeExts))] = 0.0; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FSi))] = 0.0; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(SSi))] = 0.0; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(SSf))] = 0.0; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FSGi))] = 0.0; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(SSGi))] = 0.0; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(TotalGi))] = 0.0; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FFAvg))] = 0.0; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FFAvgPrv))] = 0.0; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(GiOrig))] = 0.0; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(LayGi))] = 0.0; PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[ - 2], u32(pi),u32(Clamped),u32(di))] = 0; + 2], u32(pi),u32(di),u32(Clamped))] = 0; } fn PoolInhibSpikesFromRaw(pi: u32,di: u32) { var fnn = f32(PoolNNeurons(pi)); - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FBs),u32(di))] = Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FBsRaw),u32(di))] / fnn; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FFs),u32(di))] = Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FFsRaw),u32(di))]; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(GeExts),u32(di))] = Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(GeExtRaw),u32(di))]; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FBs))] = Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FBsRaw))] / fnn; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FFs))] = Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FFsRaw))]; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(GeExts))] = Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(GeExtRaw))]; PoolInhibInitRaw(pi, di); } fn PoolInhibSaveOrig(pi: u32,di: u32) { - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(GiOrig),u32(di))] = Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(TotalGi),u32(di))]; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(GiOrig))] = Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(TotalGi))]; } fn PoolInhibGiFromFSSS(pi: u32,di: u32) -> f32 { - return Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FSGi),u32(di))] + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(SSGi),u32(di))]; + return Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FSGi))] + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(SSGi))]; } fn PoolInhibIntToRaw(pi: u32,di: u32) { var floatFromInt = 1.0 / f32(u32(1)<<24); - var fbs = PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(FBsRawInt),u32(di))]; - var ffs = PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(FFsRawInt),u32(di))]; - var geExt = PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(GeExtRawInt),u32(di))]; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FBsRaw),u32(di))] = f32(fbs); - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FFsRaw),u32(di))] = f32(ffs) * floatFromInt; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(GeExtRaw),u32(di))] = f32(geExt) * floatFromInt; + var fbs = PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(di),u32(FBsRawInt))]; + var ffs = PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(di),u32(FFsRawInt))]; + var geExt = PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(di),u32(GeExtRawInt))]; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FBsRaw))] = f32(fbs); + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FFsRaw))] = f32(ffs) * floatFromInt; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(GeExtRaw))] = f32(geExt) * floatFromInt; } ///////////// import: "kinase-params.go" @@ -1229,25 +1229,25 @@ fn AvgMaxIntVarIndex(vr: AvgMaxVars, am: AvgMax) -> u32 { return u32(PoolIntAvgMaxStart) + u32(vr)*u32(AvgMaxN) + u32(am); } fn PoolNNeurons(pi: u32) -> i32 { - return PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(PoolNeurEd),u32(0))] - PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[ - 2], u32(pi),u32(PoolNeurSt),u32(0))]; + return PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(0),u32(PoolNeurEd))] - PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[ + 2], u32(pi),u32(0),u32(PoolNeurSt))]; } fn PoolAvgMaxCalcVar(vr: AvgMaxVars, pi: u32,di: u32) { var floatFromInt = f32(1.0) / f32(u32(1)<<20); var vis = AvgMaxIntVarIndex(vr, Avg); - var sum = PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(vis),u32(di))]; + var sum = PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(di),u32(vis))]; if (sum < 0) { sum = i32(u32(1) << 20); } - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(AvgMaxVarIndex(vr, AMCycle, Avg)),u32(di))] = f32(sum) * floatFromInt; - PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(vis),u32(di))] = 0; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(AvgMaxVarIndex(vr, AMCycle, Avg)))] = f32(sum) * floatFromInt; + PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(di),u32(vis))] = 0; var vim = AvgMaxIntVarIndex(vr, Max); - var mx = PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(vim),u32(di))]; + var mx = PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(di),u32(vim))]; if (mx < 0) { mx = i32(u32(1) << 20); } - PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(vim),u32(di))] = 0; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(AvgMaxVarIndex(vr, AMCycle, Max)),u32(di))] = f32(mx) * floatFromInt; + PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(di),u32(vim))] = 0; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(AvgMaxVarIndex(vr, AMCycle, Max)))] = f32(mx) * floatFromInt; } fn PoolAvgMaxCalc(pi: u32,di: u32) { for (var vr=0; vr u32 { fn LayerParams_MinusPhasePool(ly: ptr, ctx: ptr, pi: u32,di: u32) { PoolCycleToMinus(pi, di); if ((*ly).Acts.Clamp.Add == 0 && (*ly).Acts.Clamp.IsTarget == 1) { - PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(Clamped),u32(di))] = 1; + PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(di),u32(Clamped))] = 1; } - if (PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(PoolIsLayer),u32(di))] == 0) { + if (PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(di),u32(PoolIsLayer))] == 0) { return; } var geIntMinusMax = f32(0); @@ -100,12 +100,12 @@ fn LayerParams_MinusPhasePool(ly: ptr, ctx: ptr, ctx: ptr, di: u32, geIntMinusMax: f32,giIntMinusMax: f32) { - var gem = LayerStates[IndexF323D(LayerStates[0], LayerStates[1], LayerStates[2], u32((*ly).Index),u32(LayerAvgMaxGeM),u32(di))]; - var gim = LayerStates[IndexF323D(LayerStates[0], LayerStates[1], LayerStates[2], u32((*ly).Index),u32(LayerAvgMaxGiM),u32(di))]; + var gem = LayerStates[IndexF323D(LayerStates[0], LayerStates[1], LayerStates[2], u32((*ly).Index),u32(di),u32(LayerAvgMaxGeM))]; + var gim = LayerStates[IndexF323D(LayerStates[0], LayerStates[1], LayerStates[2], u32((*ly).Index),u32(di),u32(LayerAvgMaxGiM))]; gem += (*ly).Acts.Dt.LongAvgDt * (geIntMinusMax - gem); gim += (*ly).Acts.Dt.LongAvgDt * (giIntMinusMax - gim); - LayerStates[IndexF323D(LayerStates[0], LayerStates[1], LayerStates[2], u32((*ly).Index),u32(LayerAvgMaxGeM),u32(di))] = gem; - LayerStates[IndexF323D(LayerStates[0], LayerStates[1], LayerStates[2], u32((*ly).Index),u32(LayerAvgMaxGiM),u32(di))] = gim; + LayerStates[IndexF323D(LayerStates[0], LayerStates[1], LayerStates[2], u32((*ly).Index),u32(di),u32(LayerAvgMaxGeM))] = gem; + LayerStates[IndexF323D(LayerStates[0], LayerStates[1], LayerStates[2], u32((*ly).Index),u32(di),u32(LayerAvgMaxGiM))] = gim; } ///////////// import: "act-net.go" @@ -113,7 +113,7 @@ fn MinusPhasePool(i: u32) { //gosl:kernel var ctx = Ctx[0]; var di = Context_DataIndex(&ctx, i); var pi = Context_ItemIndex(&ctx, i); - var li = PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(PoolLayerIdx),u32(di))]; + var li = PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(di),u32(PoolLayerIdx))]; var layers=Layers[li]; LayerParams_MinusPhasePool(&layers, &ctx, pi, di); Ctx[0] = ctx; } @@ -1157,14 +1157,14 @@ fn AvgMaxVarIndex(vr: AvgMaxVars, phase: AvgMaxPhases, am: AvgMax) -> u32 { return u32(poolFloatAvgMaxStart) + u32(vr)*u32(AvgMaxN)*u32(AvgMaxPhasesN) + u32(phase)*u32(AvgMaxN) + u32(am); } fn PoolAvgMax(vr: AvgMaxVars, phase: AvgMaxPhases, am: AvgMax, pi: u32,di: u32) -> f32 { - return Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(AvgMaxVarIndex(vr, phase, am)),u32(di))]; + return Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(AvgMaxVarIndex(vr, phase, am)))]; } fn PoolCycleToMinus(pi: u32,di: u32) { for (var vr=0; vr, ctx: ptr, ctx: ptr, ctx: ptr, di: u32, actMinusAvg: f32,actPlusAvg: f32) { - var mavg = LayerStates[IndexF323D(LayerStates[0], LayerStates[1], LayerStates[2], u32((*ly).Index),u32(LayerActMAvg),u32(di))]; - var pavg = LayerStates[IndexF323D(LayerStates[0], LayerStates[1], LayerStates[2], u32((*ly).Index),u32(LayerActPAvg),u32(di))]; + var mavg = LayerStates[IndexF323D(LayerStates[0], LayerStates[1], LayerStates[2], u32((*ly).Index),u32(di),u32(LayerActMAvg))]; + var pavg = LayerStates[IndexF323D(LayerStates[0], LayerStates[1], LayerStates[2], u32((*ly).Index),u32(di),u32(LayerActPAvg))]; ActAvgParams_AvgFromAct(&(*ly).Inhib.ActAvg, &mavg, actMinusAvg, (*ly).Acts.Dt.LongAvgDt); ActAvgParams_AvgFromAct(&(*ly).Inhib.ActAvg, &pavg, actPlusAvg, (*ly).Acts.Dt.LongAvgDt); - LayerStates[IndexF323D(LayerStates[0], LayerStates[1], LayerStates[2], u32((*ly).Index),u32(LayerActMAvg),u32(di))] = mavg; - LayerStates[IndexF323D(LayerStates[0], LayerStates[1], LayerStates[2], u32((*ly).Index),u32(LayerActPAvg),u32(di))] = pavg; + LayerStates[IndexF323D(LayerStates[0], LayerStates[1], LayerStates[2], u32((*ly).Index),u32(di),u32(LayerActMAvg))] = mavg; + LayerStates[IndexF323D(LayerStates[0], LayerStates[1], LayerStates[2], u32((*ly).Index),u32(di),u32(LayerActPAvg))] = pavg; } fn LayerParams_NewStatePool(ly: ptr, ctx: ptr, pi: u32,di: u32) { - PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(Clamped),u32(di))] = 0; + PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(di),u32(Clamped))] = 0; if ((*ly).Acts.Clamp.Add == 0 && (*ly).Acts.Clamp.IsInput == 1) { - PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(Clamped),u32(di))] = 1; + PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(di),u32(Clamped))] = 1; } PoolInhibDecay(pi, di, (*ly).Acts.Decay.Act); PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], - u32(pi),u32(PoolGated),u32(di))] = 0; + u32(pi),u32(di),u32(PoolGated))] = 0; } ///////////// import: "act-net.go" @@ -641,17 +641,17 @@ struct InhibParams { Pool: GiParams, } fn PoolInhibDecay(pi: u32,di: u32, decay: f32) { - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FFAvgPrv),u32(di))] = Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FFAvg),u32(di))]; // capture prior to decay - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FFs),u32(di))] -= decay * Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FFs),u32(di))]; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FBs),u32(di))] -= decay * Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FBs),u32(di))]; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(GeExts),u32(di))] -= decay * Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(GeExts),u32(di))]; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FSi),u32(di))] -= decay * Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FSi),u32(di))]; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(SSi),u32(di))] -= decay * Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(SSi),u32(di))]; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(SSf),u32(di))] -= decay * Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(SSf),u32(di))]; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FSGi),u32(di))] -= decay * Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FSGi),u32(di))]; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(SSGi),u32(di))] -= decay * Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(SSGi),u32(di))]; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(TotalGi),u32(di))] -= decay * Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(TotalGi),u32(di))]; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FFAvg),u32(di))] -= decay * Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FFAvg),u32(di))]; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FFAvgPrv))] = Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FFAvg))]; // capture prior to decay + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FFs))] -= decay * Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FFs))]; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FBs))] -= decay * Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FBs))]; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(GeExts))] -= decay * Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(GeExts))]; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FSi))] -= decay * Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FSi))]; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(SSi))] -= decay * Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(SSi))]; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(SSf))] -= decay * Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(SSf))]; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FSGi))] -= decay * Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FSGi))]; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(SSGi))] -= decay * Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(SSGi))]; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(TotalGi))] -= decay * Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(TotalGi))]; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FFAvg))] -= decay * Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FFAvg))]; } ///////////// import: "kinase-params.go" @@ -1207,7 +1207,7 @@ fn AvgMaxVarIndex(vr: AvgMaxVars, phase: AvgMaxPhases, am: AvgMax) -> u32 { return u32(poolFloatAvgMaxStart) + u32(vr)*u32(AvgMaxN)*u32(AvgMaxPhasesN) + u32(phase)*u32(AvgMaxN) + u32(am); } fn PoolAvgMax(vr: AvgMaxVars, phase: AvgMaxPhases, am: AvgMax, pi: u32,di: u32) -> f32 { - return Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(AvgMaxVarIndex(vr, phase, am)),u32(di))]; + return Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(AvgMaxVarIndex(vr, phase, am)))]; } ///////////// import: "rand.go" diff --git a/axon/shaders/PlusPhaseNeuron.wgsl b/axon/shaders/PlusPhaseNeuron.wgsl index 4ea575e4..633158de 100644 --- a/axon/shaders/PlusPhaseNeuron.wgsl +++ b/axon/shaders/PlusPhaseNeuron.wgsl @@ -97,7 +97,7 @@ fn LayerParams_PlusPhaseNeuron(ly: ptr, ctx: ptr u32 { return u32(poolFloatAvgMaxStart) + u32(vr)*u32(AvgMaxN)*u32(AvgMaxPhasesN) + u32(phase)*u32(AvgMaxN) + u32(am); } fn PoolAvgMax(vr: AvgMaxVars, phase: AvgMaxPhases, am: AvgMax, pi: u32,di: u32) -> f32 { - return Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(AvgMaxVarIndex(vr, phase, am)),u32(di))]; + return Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(AvgMaxVarIndex(vr, phase, am)))]; } ///////////// import: "rand.go" diff --git a/axon/shaders/PlusPhasePool.wgsl b/axon/shaders/PlusPhasePool.wgsl index 04a13d45..a6ca6c62 100644 --- a/axon/shaders/PlusPhasePool.wgsl +++ b/axon/shaders/PlusPhasePool.wgsl @@ -90,7 +90,7 @@ fn PlusPhasePool(i: u32) { //gosl:kernel var ctx = Ctx[0]; var di = Context_DataIndex(&ctx, i); var pi = Context_ItemIndex(&ctx, i); - var li = PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(PoolLayerIdx),u32(di))]; + var li = PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(di),u32(PoolLayerIdx))]; var layers=Layers[li]; LayerParams_PlusPhasePool(&layers, &ctx, pi, di); Ctx[0] = ctx; } @@ -1135,8 +1135,8 @@ fn AvgMaxVarIndex(vr: AvgMaxVars, phase: AvgMaxPhases, am: AvgMax) -> u32 { } fn PoolCycleToPlus(pi: u32,di: u32) { for (var vr=0; vr, ctx: ptr, pi: u32,di: u32, gimult: f32) { if ((*fb).On == 0) { PoolInhibZero(pi, di);return; } - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FFAvg),u32(di))] += (*fb).FFAvgDt * (Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FFs),u32(di))] - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FFAvg),u32(di))]); - var fsi = Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FSi),u32(di))]; - fsi = GiParams_FSiFromFFs(fb, fsi, Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FFs),u32(di))], Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FBs),u32(di))]); - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FSi),u32(di))] = fsi; - var clamped = PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(Clamped),u32(di))] > 0; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FSGi),u32(di))] = (*fb).Gi * GiParams_FS(fb, fsi, Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(GeExts),u32(di))], clamped); - var ssf = Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(SSf),u32(di))]; - var ssi = Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(SSi),u32(di))]; - GiParams_SSFromFBs(fb, &ssf, &ssi, Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FBs),u32(di))]); - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(SSGi),u32(di))] = (*fb).Gi * (*fb).SS * ssi; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(SSf),u32(di))] = ssf; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(SSi),u32(di))] = ssi; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(TotalGi),u32(di))] = PoolInhibGiFromFSSS(pi, di) + (*fb).FFPrv*Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FFAvgPrv),u32(di))]; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FFAvg))] += (*fb).FFAvgDt * (Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FFs))] - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FFAvg))]); + var fsi = Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FSi))]; + fsi = GiParams_FSiFromFFs(fb, fsi, Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FFs))], Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FBs))]); + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FSi))] = fsi; + var clamped = PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(di),u32(Clamped))] > 0; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FSGi))] = (*fb).Gi * GiParams_FS(fb, fsi, Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(GeExts))], clamped); + var ssf = Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(SSf))]; + var ssi = Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(SSi))]; + GiParams_SSFromFBs(fb, &ssf, &ssi, Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FBs))]); + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(SSGi))] = (*fb).Gi * (*fb).SS * ssi; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(SSf))] = ssf; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(SSi))] = ssi; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(TotalGi))] = PoolInhibGiFromFSSS(pi, di) + (*fb).FFPrv*Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FFAvgPrv))]; PoolInhibSaveOrig(pi, di); } fn PoolInhibInitRaw(pi: u32,di: u32) { - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FFsRaw),u32(di))] = 0.0; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FBsRaw),u32(di))] = 0.0; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(GeExtRaw),u32(di))] = 0.0; - PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(FFsRawInt),u32(di))] = 0; - PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(FBsRawInt),u32(di))] = 0; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FFsRaw))] = 0.0; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FBsRaw))] = 0.0; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(GeExtRaw))] = 0.0; + PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(di),u32(FFsRawInt))] = 0; + PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(di),u32(FBsRawInt))] = 0; PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], - u32(pi),u32(GeExtRawInt),u32(di))] = 0; + u32(pi),u32(di),u32(GeExtRawInt))] = 0; } fn PoolInhibZero(pi: u32,di: u32) { - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FFs),u32(di))] = 0.0; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FBs),u32(di))] = 0.0; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(GeExts),u32(di))] = 0.0; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FSi),u32(di))] = 0.0; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(SSi),u32(di))] = 0.0; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(SSf),u32(di))] = 0.0; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FSGi),u32(di))] = 0.0; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(SSGi),u32(di))] = 0.0; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(TotalGi),u32(di))] = 0.0; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FFAvg),u32(di))] = 0.0; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FFAvgPrv),u32(di))] = 0.0; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(GiOrig),u32(di))] = 0.0; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(LayGi),u32(di))] = 0.0; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FFs))] = 0.0; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FBs))] = 0.0; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(GeExts))] = 0.0; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FSi))] = 0.0; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(SSi))] = 0.0; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(SSf))] = 0.0; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FSGi))] = 0.0; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(SSGi))] = 0.0; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(TotalGi))] = 0.0; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FFAvg))] = 0.0; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FFAvgPrv))] = 0.0; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(GiOrig))] = 0.0; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(LayGi))] = 0.0; PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[ - 2], u32(pi),u32(Clamped),u32(di))] = 0; + 2], u32(pi),u32(di),u32(Clamped))] = 0; } fn PoolInhibSpikesFromRaw(pi: u32,di: u32) { var fnn = f32(PoolNNeurons(pi)); - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FBs),u32(di))] = Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FBsRaw),u32(di))] / fnn; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FFs),u32(di))] = Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FFsRaw),u32(di))]; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(GeExts),u32(di))] = Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(GeExtRaw),u32(di))]; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FBs))] = Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FBsRaw))] / fnn; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FFs))] = Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FFsRaw))]; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(GeExts))] = Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(GeExtRaw))]; PoolInhibInitRaw(pi, di); } fn PoolInhibSaveOrig(pi: u32,di: u32) { - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(GiOrig),u32(di))] = Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(TotalGi),u32(di))]; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(GiOrig))] = Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(TotalGi))]; } fn PoolInhibGiFromFSSS(pi: u32,di: u32) -> f32 { - return Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FSGi),u32(di))] + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(SSGi),u32(di))]; + return Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FSGi))] + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(SSGi))]; } fn PoolInhibLayerMax(pi: u32,di: u32, liGi: f32) { - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(LayGi),u32(di))] = liGi; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(TotalGi),u32(di))] = max(Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(TotalGi),u32(di))], liGi); + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(LayGi))] = liGi; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(TotalGi))] = max(Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(TotalGi))], liGi); } fn PoolInhibPoolMax(pi: u32,di: u32, piGi: f32) { - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(TotalGi),u32(di))] = max(Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(TotalGi),u32(di))], piGi); + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(TotalGi))] = max(Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(TotalGi))], piGi); } fn PoolInhibIntToRaw(pi: u32,di: u32) { var floatFromInt = 1.0 / f32(u32(1)<<24); - var fbs = PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(FBsRawInt),u32(di))]; - var ffs = PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(FFsRawInt),u32(di))]; - var geExt = PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(GeExtRawInt),u32(di))]; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FBsRaw),u32(di))] = f32(fbs); - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(FFsRaw),u32(di))] = f32(ffs) * floatFromInt; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(GeExtRaw),u32(di))] = f32(geExt) * floatFromInt; + var fbs = PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(di),u32(FBsRawInt))]; + var ffs = PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(di),u32(FFsRawInt))]; + var geExt = PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(di),u32(GeExtRawInt))]; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FBsRaw))] = f32(fbs); + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(FFsRaw))] = f32(ffs) * floatFromInt; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(GeExtRaw))] = f32(geExt) * floatFromInt; } ///////////// import: "kinase-params.go" @@ -1235,25 +1235,25 @@ fn AvgMaxIntVarIndex(vr: AvgMaxVars, am: AvgMax) -> u32 { return u32(PoolIntAvgMaxStart) + u32(vr)*u32(AvgMaxN) + u32(am); } fn PoolNNeurons(pi: u32) -> i32 { - return PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(PoolNeurEd),u32(0))] - PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[ - 2], u32(pi),u32(PoolNeurSt),u32(0))]; + return PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(0),u32(PoolNeurEd))] - PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[ + 2], u32(pi),u32(0),u32(PoolNeurSt))]; } fn PoolAvgMaxCalcVar(vr: AvgMaxVars, pi: u32,di: u32) { var floatFromInt = f32(1.0) / f32(u32(1)<<20); var vis = AvgMaxIntVarIndex(vr, Avg); - var sum = PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(vis),u32(di))]; + var sum = PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(di),u32(vis))]; if (sum < 0) { sum = i32(u32(1) << 20); } - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(AvgMaxVarIndex(vr, AMCycle, Avg)),u32(di))] = f32(sum) * floatFromInt; - PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(vis),u32(di))] = 0; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(AvgMaxVarIndex(vr, AMCycle, Avg)))] = f32(sum) * floatFromInt; + PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(di),u32(vis))] = 0; var vim = AvgMaxIntVarIndex(vr, Max); - var mx = PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(vim),u32(di))]; + var mx = PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(di),u32(vim))]; if (mx < 0) { mx = i32(u32(1) << 20); } - PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(vim),u32(di))] = 0; - Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(AvgMaxVarIndex(vr, AMCycle, Max)),u32(di))] = f32(mx) * floatFromInt; + PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(di),u32(vim))] = 0; + Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(AvgMaxVarIndex(vr, AMCycle, Max)))] = f32(mx) * floatFromInt; } fn PoolAvgMaxCalc(pi: u32,di: u32) { for (var vr=0; vr, pi: u32,di: u32) { - if (PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(PoolIsLayer),u32(di))] > 0) { + if (PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(di),u32(PoolIsLayer))] > 0) { return; } - var li = PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(PoolLayerIdx),u32(di))]; + var li = PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(di),u32(PoolLayerIdx))]; PoolAvgMaxCalc(pi, di); PoolInhibIntToRaw(pi, di); var ly = Layers[u32(li)]; - var giMult = LayerStates[IndexF323D(LayerStates[0], LayerStates[1], LayerStates[2], u32(li),u32(LayerGiMult),u32(di))]; + var giMult = LayerStates[IndexF323D(LayerStates[0], LayerStates[1], LayerStates[2], u32(li),u32(di),u32(LayerGiMult))]; var lyIsOn = (ly.Inhib.Layer.On == 1); var lpi = LayerParams_PoolIndex(&ly, u32(0)); LayerParams_SubPoolGiFromSpikes(&ly, ctx, lpi, pi, di, lyIsOn, giMult); diff --git a/axon/shaders/SendSpike.wgsl b/axon/shaders/SendSpike.wgsl index 34fb66af..cd0cb3de 100644 --- a/axon/shaders/SendSpike.wgsl +++ b/axon/shaders/SendSpike.wgsl @@ -96,7 +96,7 @@ fn LayerParams_PostSpikeSpecial(ly: ptr, ctx: ptr 0; switch ((*ly).Type) { case SuperLayer: { @@ -197,9 +197,9 @@ fn LayerParams_PostSpikeSpecial(ly: ptr, ctx: ptr, ctx: ptr, ctx: ptr var npti = npst + (ri - recvNeurSt); var deli = SynComParams_WriteOff(&(*pt).Com, (*ctx).CyclesTotal); var sv = i32(sendVal * Synapses[IndexF322D(Synapses[0], Synapses[1], u32(syni),u32(Wt))]); - atomicAdd(&PathGBuf[IndexI323D(PathGBuf[0], PathGBuf[1], PathGBuf[2], u32(npti),u32(deli),u32(di))], sv); + atomicAdd(&PathGBuf[IndexI323D(PathGBuf[0], PathGBuf[1], PathGBuf[2], u32(npti),u32(di),u32(deli))], sv); } } @@ -1380,11 +1380,11 @@ fn AvgMaxVarIndex(vr: AvgMaxVars, phase: AvgMaxPhases, am: AvgMax) -> u32 { return u32(poolFloatAvgMaxStart) + u32(vr)*u32(AvgMaxN)*u32(AvgMaxPhasesN) + u32(phase)*u32(AvgMaxN) + u32(am); } fn PoolAvgMax(vr: AvgMaxVars, phase: AvgMaxPhases, am: AvgMax, pi: u32,di: u32) -> f32 { - return Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(AvgMaxVarIndex(vr, phase, am)),u32(di))]; + return Pools[IndexF323D(Pools[0], Pools[1], Pools[2], u32(pi),u32(di),u32(AvgMaxVarIndex(vr, phase, am)))]; } fn PoolNNeurons(pi: u32) -> i32 { - return PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(PoolNeurEd),u32(0))] - PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[ - 2], u32(pi),u32(PoolNeurSt),u32(0))]; + return PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(0),u32(PoolNeurEd))] - PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[ + 2], u32(pi),u32(0),u32(PoolNeurSt))]; } ///////////// import: "rand.go" diff --git a/axon/stats.go b/axon/stats.go index 17e3e565..cd250a4c 100644 --- a/axon/stats.go +++ b/axon/stats.go @@ -147,8 +147,8 @@ func (ly *Layer) AvgMaxVarByPool(ctx *Context, varNm string, poolIndex, di int) return am } pi := ly.Params.PoolIndex(uint32(poolIndex)) - nsi := PoolsInt.Value(int(pi), int(PoolNeurSt), int(di)) - nei := PoolsInt.Value(int(pi), int(PoolNeurEd), int(di)) + nsi := PoolsInt.Value(int(pi), int(di), int(PoolNeurSt)) + nei := PoolsInt.Value(int(pi), int(di), int(PoolNeurEd)) am.Init() for lni := nsi; lni < nei; lni++ { ni := ly.NeurStIndex + uint32(lni) @@ -191,11 +191,11 @@ func (ly *Layer) PhaseDiffFromActs(ctx *Context) { if dist != 0 { cosv /= dist } - LayerStates.Set(1-cosv, int(li), int(LayerPhaseDiff), int(di)) - avg := LayerStates.Value(int(li), int(LayerPhaseDiffAvg), int(di)) - vr := LayerStates.Value(int(li), int(LayerPhaseDiffVar), int(di)) + LayerStates.Set(1-cosv, int(li), int(di), int(LayerPhaseDiff)) + avg := LayerStates.Value(int(li), int(di), int(LayerPhaseDiffAvg)) + vr := LayerStates.Value(int(li), int(di), int(LayerPhaseDiffVar)) ly.Params.Acts.Dt.AvgVarUpdate(&avg, &vr, 1-cosv) - LayerStates.Set(avg, int(li), int(LayerPhaseDiffAvg), int(di)) - LayerStates.Set(vr, int(li), int(LayerPhaseDiffVar), int(di)) + LayerStates.Set(avg, int(li), int(di), int(LayerPhaseDiffAvg)) + LayerStates.Set(vr, int(li), int(di), int(LayerPhaseDiffVar)) } } diff --git a/axon/stats.goal b/axon/stats.goal index a767a8e9..d55c8154 100644 --- a/axon/stats.goal +++ b/axon/stats.goal @@ -145,8 +145,8 @@ func (ly *Layer) AvgMaxVarByPool(ctx *Context, varNm string, poolIndex, di int) return am } pi := ly.Params.PoolIndex(uint32(poolIndex)) - nsi := PoolsInt[pi, PoolNeurSt, di] - nei := PoolsInt[pi, PoolNeurEd, di] + nsi := PoolsInt[pi, di, PoolNeurSt] + nei := PoolsInt[pi, di, PoolNeurEd] am.Init() for lni := nsi; lni < nei; lni++ { ni := ly.NeurStIndex + uint32(lni) @@ -189,11 +189,11 @@ func (ly *Layer) PhaseDiffFromActs(ctx *Context) { if dist != 0 { cosv /= dist } - LayerStates[li, LayerPhaseDiff, di] = 1 - cosv - avg := LayerStates[li, LayerPhaseDiffAvg, di] - vr := LayerStates[li, LayerPhaseDiffVar, di] + LayerStates[li, di, LayerPhaseDiff] = 1 - cosv + avg := LayerStates[li, di, LayerPhaseDiffAvg] + vr := LayerStates[li, di, LayerPhaseDiffVar] ly.Params.Acts.Dt.AvgVarUpdate(&avg, &vr, 1-cosv) - LayerStates[li, LayerPhaseDiffAvg, di] = avg - LayerStates[li, LayerPhaseDiffVar, di] = vr + LayerStates[li, di, LayerPhaseDiffAvg] = avg + LayerStates[li, di, LayerPhaseDiffVar] = vr } } diff --git a/examples/bench_lvis/bench_lvis.go b/examples/bench_lvis/bench_lvis.go index fa0ac6be..c1cba910 100644 --- a/examples/bench_lvis/bench_lvis.go +++ b/examples/bench_lvis/bench_lvis.go @@ -231,7 +231,7 @@ func TrainNet(ctx *axon.Context, net *axon.Network, pats, epcLog *table.Table, p } net.PlusPhase() net.DWtToWt() - phasedif := axon.LayerStates.Value(int(outLay.Index), int(axon.LayerPhaseDiff), int(0)) + phasedif := axon.LayerStates.Value(int(outLay.Index), int(0), int(axon.LayerPhaseDiff)) outPhaseDiff += 1.0 - phasedif pSSE := outLay.PctUnitErr(ctx)[0] sse += pSSE diff --git a/examples/bench_lvis/bench_results.md b/examples/bench_lvis/bench_results.md index 2a388159..2e3db7c4 100644 --- a/examples/bench_lvis/bench_results.md +++ b/examples/bench_lvis/bench_results.md @@ -22,7 +22,9 @@ Currently, can only handle -hiddenNeurs=4 due to memory limits! wgpu issues need go test -gpu -hiddenNeurs=4 -verbose=false -ndata=1 -bench=. -run not ``` -* 2.7 with ndata = 1 on GPU, with ndata=1 di still inner-most. +* Indexing: Neurons[ni, di, var] is just slightly faster than Neurons[ni, var, di]: 2.69-70 vs. 2.71-2. And cycPerStep = 50 vs. 10 is about .1 faster. + +* 2.71 with ndata = 1 on GPU, with ndata=1 di still inner-most. * 9.7 on CPU = 3.6x speedup for GPU; CPU is sig slower due to atomic sendspikes. diff --git a/examples/ra25/ra25.go b/examples/ra25/ra25.go index 56e2be77..fcd378af 100644 --- a/examples/ra25/ra25.go +++ b/examples/ra25/ra25.go @@ -707,7 +707,7 @@ func (ss *Sim) ConfigStats() { var stat float64 switch name { case "CorSim": - stat = 1.0 - float64(axon.LayerStates.Value(int(out.Index), int(axon.LayerPhaseDiff), int(di))) + stat = 1.0 - float64(axon.LayerStates.Value(int(out.Index), int(di), int(axon.LayerPhaseDiff))) case "UnitErr": stat = out.PctUnitErr(ss.Net.Context())[di] case "Err":