From f059cb05d81b8314b4649ce9f6681344a70bc9e2 Mon Sep 17 00:00:00 2001 From: "Randall C. O'Reilly" Date: Fri, 22 Nov 2024 23:40:13 -0800 Subject: [PATCH] Neurons ni, di, var indexing --- axon/act-layer.go | 312 ++++++++--------- axon/act-layer.goal | 312 ++++++++--------- axon/act-net.go | 2 +- axon/act-net.goal | 2 +- axon/act-path.go | 20 +- axon/act-path.goal | 20 +- axon/act.go | 458 ++++++++++++------------- axon/act.goal | 458 ++++++++++++------------- axon/act_test.go | 18 +- axon/act_test.goal | 18 +- axon/basic_test.go | 18 +- axon/basic_test.goal | 16 +- axon/init-layer.go | 6 +- axon/init-layer.goal | 6 +- axon/layer.go | 6 +- axon/layer.goal | 6 +- axon/learn-path.go | 98 +++--- axon/learn-path.goal | 98 +++--- axon/learn.go | 62 ++-- axon/learn.goal | 62 ++-- axon/network.go | 6 +- axon/network.goal | 6 +- axon/pool.go | 12 +- axon/pool.goal | 12 +- axon/shaders/ApplyExtsNeuron.wgsl | 12 +- axon/shaders/CycleNeuron.wgsl | 346 +++++++++---------- axon/shaders/DWtSyn.wgsl | 98 +++--- axon/shaders/GatherSpikes.wgsl | 50 +-- axon/shaders/MinusPhaseNeuron.wgsl | 4 +- axon/shaders/NewStateNeuron.wgsl | 136 ++++---- axon/shaders/PlusPhaseNeuron.wgsl | 22 +- axon/shaders/PlusPhaseStartNeuron.wgsl | 12 +- axon/shaders/SendSpike.wgsl | 70 ++-- axon/stats.go | 18 +- axon/stats.goal | 18 +- examples/deep_fsa/deep_fsa.go | 2 +- examples/neuron/neuron.go | 12 +- 37 files changed, 1417 insertions(+), 1417 deletions(-) diff --git a/axon/act-layer.go b/axon/act-layer.go index 7589aef5..1864d8a4 100644 --- a/axon/act-layer.go +++ b/axon/act-layer.go @@ -36,8 +36,8 @@ func (ly *LayerParams) ApplyExtFlags(clearMask, setMask *NeuronFlags, toTarg *bo // InitExt initializes external input state for given neuron func (ly *LayerParams) InitExt(ni, di uint32) { - Neurons.Set(0.0, int(ni), int(Ext), int(di)) - Neurons.Set(0.0, int(ni), int(Target), int(di)) + Neurons.Set(0.0, int(ni), int(di), int(Ext)) + Neurons.Set(0.0, int(ni), int(di), int(Target)) NeuronClearFlag(NeuronHasExt|NeuronHasTarg|NeuronHasCmpr, ni, di) } @@ -53,9 +53,9 @@ func (ly *LayerParams) ApplyExtValue(ni, di uint32, val float32) { var toTarg bool ly.ApplyExtFlags(&clearMask, &setMask, &toTarg) if toTarg { - Neurons.Set(val, int(ni), int(Target), int(di)) + Neurons.Set(val, int(ni), int(di), int(Target)) } else { - Neurons.Set(val, int(ni), int(Ext), int(di)) + Neurons.Set(val, int(ni), int(di), int(Ext)) } NeuronClearFlag(clearMask, ni, di) NeuronSetFlag(setMask, ni, di) @@ -76,15 +76,15 @@ func (ly *LayerParams) ApplyExtsNeuron(ni, di uint32) { func SetNeuronExtPosNeg(ctx *Context, ni, di uint32, val float32) { if ni == 0 { if val >= 0 { - Neurons.Set(val, int(ni), int(Ext), int(di)) + Neurons.Set(val, int(ni), int(di), int(Ext)) } else { - Neurons.Set(float32(0), int(ni), int(Ext), int(di)) + Neurons.Set(float32(0), int(ni), int(di), int(Ext)) } } else { if val >= 0 { - Neurons.Set(float32(0), int(ni), int(Ext), int(di)) + Neurons.Set(float32(0), int(ni), int(di), int(Ext)) } else { - Neurons.Set(-val, int(ni), int(Ext), int(di)) + Neurons.Set(-val, int(ni), int(di), int(Ext)) } } } @@ -161,14 +161,14 @@ func (ly *LayerParams) GatherSpikes(ctx *Context, ni, di uint32) { // GatherSpikesInit initializes G*Raw and G*Syn values for given neuron // prior to integration. func (ly *LayerParams) GatherSpikesInit(ctx *Context, ni, di uint32) { - Neurons.Set(0.0, int(ni), int(GeRaw), int(di)) - Neurons.Set(0.0, int(ni), int(GiRaw), int(di)) - Neurons.Set(0.0, int(ni), int(GModRaw), int(di)) - Neurons.Set(0.0, int(ni), int(GModSyn), int(di)) - Neurons.Set(0.0, int(ni), int(GMaintRaw), int(di)) - Neurons.Set(0.0, int(ni), int(CtxtGeRaw), int(di)) - Neurons.Set(NeuronAvgs.Value(int(ni), int(GeBase)), int(ni), int(GeSyn), int(di)) - Neurons.Set(NeuronAvgs.Value(int(ni), int(GiBase)), int(ni), int(GiSyn), int(di)) + Neurons.Set(0.0, int(ni), int(di), int(GeRaw)) + Neurons.Set(0.0, int(ni), int(di), int(GiRaw)) + Neurons.Set(0.0, int(ni), int(di), int(GModRaw)) + Neurons.Set(0.0, int(ni), int(di), int(GModSyn)) + Neurons.Set(0.0, int(ni), int(di), int(GMaintRaw)) + Neurons.Set(0.0, int(ni), int(di), int(CtxtGeRaw)) + Neurons.Set(NeuronAvgs.Value(int(ni), int(GeBase)), int(ni), int(di), int(GeSyn)) + Neurons.Set(NeuronAvgs.Value(int(ni), int(GiBase)), int(ni), int(di), int(GiSyn)) } // GiFromSpikes gets the Spike, GeRaw and GeExt from neurons in the pools @@ -181,9 +181,9 @@ func (ly *LayerParams) GatherSpikesInit(ctx *Context, ni, di uint32) { // Also updates all AvgMax values at the Cycle level. func (ly *LayerParams) GiFromSpikes(ctx *Context, ni, di uint32) { pi := ly.PoolIndex(NeuronIxs.Value(int(ni), int(NrnSubPool))) - spk := Neurons.Value(int(ni), int(Spike), int(di)) - geRaw := Neurons.Value(int(ni), int(GeRaw), int(di)) - geExt := Neurons.Value(int(ni), int(GeExt), int(di)) + spk := Neurons.Value(int(ni), int(di), int(Spike)) + geRaw := Neurons.Value(int(ni), int(di), int(GeRaw)) + 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 @@ -263,7 +263,7 @@ func (ly *LayerParams) PulvinarDriver(ctx *Context, lni, di uint32, drvGe, nonDr dpi := dly.PoolIndex(0) drvMax := PoolAvgMax(AMCaSpkP, AMCycle, Max, dpi, di) *nonDrivePct = ly.Pulv.NonDrivePct(drvMax) // how much non-driver to keep - burst := Neurons.Value(int(dly.Indexes.NeurSt+lni), int(Burst), int(di)) + burst := Neurons.Value(int(dly.Indexes.NeurSt+lni), int(di), int(Burst)) *drvGe = ly.Pulv.DriveGe(burst) } @@ -274,7 +274,7 @@ func (ly *LayerParams) GInteg(ctx *Context, pi, ni, di uint32) { nonDrivePct := float32(0) if ly.Type == PulvinarLayer { ly.PulvinarDriver(ctx, ni-ly.Indexes.NeurSt, di, &drvGe, &nonDrivePct) - Neurons.Set(nonDrivePct, int(ni), int(Ext), int(di)) // use for regulating inhibition + Neurons.Set(nonDrivePct, int(ni), int(di), int(Ext)) // use for regulating inhibition } saveVal := ly.SpecialPreGs(ctx, pi, ni, di, drvGe, nonDrivePct) @@ -295,31 +295,31 @@ func (ly *LayerParams) SpecialPreGs(ctx *Context, pi, ni, di uint32, drvGe float pil := pi - ly.PoolSt pnn := uint32(PoolNNeurons(pi)) pni := NeuronIxs.Value(int(ni), int(NrnNeurIndex)) - uint32(PoolsInt.Value(int(pi), int(PoolNeurSt), int(di))) - nrnCtxtGe := Neurons.Value(int(ni), int(CtxtGe), int(di)) - nrnGeRaw := Neurons.Value(int(ni), int(GeRaw), int(di)) + 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 switch ly.Type { case PTPredLayer, CTLayer: geCtxt := ly.CT.GeGain * nrnCtxtGe - Neurons.SetAdd(geCtxt, int(ni), int(GeRaw), int(di)) + Neurons.SetAdd(geCtxt, int(ni), int(di), int(GeRaw)) if ly.CT.DecayDt > 0 { - Neurons.SetSub(ly.CT.DecayDt*nrnCtxtGe, int(ni), int(CtxtGe), int(di)) + Neurons.SetSub(ly.CT.DecayDt*nrnCtxtGe, int(ni), int(di), int(CtxtGe)) } ctxExt := ly.Acts.Dt.GeSynFromRawSteady(geCtxt) - Neurons.SetAdd(ctxExt, int(ni), int(GeSyn), int(di)) + Neurons.SetAdd(ctxExt, int(ni), int(di), int(GeSyn)) saveVal = ctxExt // used In PostGs to set nrn.GeExt case PTMaintLayer: if ly.Acts.SMaint.On.IsTrue() { - saveVal = ly.Acts.SMaint.Inhib * Neurons.Value(int(ni), int(GMaintRaw), int(di)) // used In PostGs to set nrn.GeExt + saveVal = ly.Acts.SMaint.Inhib * Neurons.Value(int(ni), int(di), int(GMaintRaw)) // used In PostGs to set nrn.GeExt } case PulvinarLayer: if ctx.PlusPhase.IsFalse() { break } // geSyn, goes into nrn.GeExt in PostGs, so inhibition gets it - saveVal = nonDrivePct*Neurons.Value(int(ni), int(GeSyn), int(di)) + ly.Acts.Dt.GeSynFromRawSteady(drvGe) - Neurons.Set(nonDrivePct*nrnGeRaw+drvGe, int(ni), int(GeRaw), int(di)) - Neurons.Set(saveVal, int(ni), int(GeSyn), int(di)) + saveVal = nonDrivePct*Neurons.Value(int(ni), int(di), int(GeSyn)) + ly.Acts.Dt.GeSynFromRawSteady(drvGe) + Neurons.Set(nonDrivePct*nrnGeRaw+drvGe, int(ni), int(di), int(GeRaw)) + Neurons.Set(saveVal, int(ni), int(di), int(GeSyn)) case VSGatedLayer: dr := float32(0) if pil == 0 { @@ -328,16 +328,16 @@ func (ly *LayerParams) SpecialPreGs(ctx *Context, pi, ni, di uint32, drvGe float dr = GlobalScalars.Value(int(GvVSMatrixHasGated), int(di)) } dr = math32.Abs(dr) - Neurons.Set(dr, int(ni), int(GeRaw), int(di)) - Neurons.Set(ly.Acts.Dt.GeSynFromRawSteady(dr), int(ni), int(GeSyn), int(di)) + Neurons.Set(dr, int(ni), int(di), int(GeRaw)) + Neurons.Set(ly.Acts.Dt.GeSynFromRawSteady(dr), int(ni), int(di), int(GeSyn)) case BLALayer: if ly.Learn.NeuroMod.IsBLAExt() { md := max(-GlobalScalars.Value(int(GvDA), int(di)), float32(0)) // ext is modulated by negative da - geCtxt := md * ly.CT.GeGain * Neurons.Value(int(ni), int(CtxtGeOrig), int(di)) - Neurons.SetAdd(geCtxt, int(ni), int(GeRaw), int(di)) + geCtxt := md * ly.CT.GeGain * Neurons.Value(int(ni), int(di), int(CtxtGeOrig)) + Neurons.SetAdd(geCtxt, int(ni), int(di), int(GeRaw)) ctxExt := ly.Acts.Dt.GeSynFromRawSteady(geCtxt) - Neurons.SetAdd(ctxExt, int(ni), int(GeSyn), int(di)) + Neurons.SetAdd(ctxExt, int(ni), int(di), int(GeSyn)) saveVal = ctxExt // used In PostGs to set nrn.GeExt } case LHbLayer: @@ -347,24 +347,24 @@ func (ly *LayerParams) SpecialPreGs(ctx *Context, pi, ni, di uint32, drvGe float } else { geRaw = 0.2 * math32.Abs(GlobalScalars.Value(int(GvLHbBurst), int(di))) } - Neurons.Set(geRaw, int(ni), int(GeRaw), int(di)) - Neurons.Set(ly.Acts.Dt.GeSynFromRawSteady(geRaw), int(ni), int(GeSyn), int(di)) + Neurons.Set(geRaw, int(ni), int(di), int(GeRaw)) + Neurons.Set(ly.Acts.Dt.GeSynFromRawSteady(geRaw), int(ni), int(di), int(GeSyn)) case DrivesLayer: dr := GlobalVectors.Value(int(GvDrives), int(pil-1), int(di)) geRaw := dr if dr > 0 { geRaw = ly.Acts.PopCode.EncodeGe(pni, pnn, dr) } - Neurons.Set(geRaw, int(ni), int(GeRaw), int(di)) - Neurons.Set(ly.Acts.Dt.GeSynFromRawSteady(geRaw), int(ni), int(GeSyn), int(di)) + Neurons.Set(geRaw, int(ni), int(di), int(GeRaw)) + Neurons.Set(ly.Acts.Dt.GeSynFromRawSteady(geRaw), int(ni), int(di), int(GeSyn)) case UrgencyLayer: ur := GlobalScalars.Value(int(GvUrgency), int(di)) geRaw := ur if ur > 0 { geRaw = ly.Acts.PopCode.EncodeGe(pni, pnn, ur) } - Neurons.Set(geRaw, int(ni), int(GeRaw), int(di)) - Neurons.Set(ly.Acts.Dt.GeSynFromRawSteady(geRaw), int(ni), int(GeSyn), int(di)) + Neurons.Set(geRaw, int(ni), int(di), int(GeRaw)) + Neurons.Set(ly.Acts.Dt.GeSynFromRawSteady(geRaw), int(ni), int(di), int(GeSyn)) case USLayer: us := RubiconUSStimValue(di, pil-1, ly.Learn.NeuroMod.Valence) geRaw := us @@ -373,8 +373,8 @@ func (ly *LayerParams) SpecialPreGs(ctx *Context, pi, ni, di uint32, drvGe float } // D2Mod = final if ly.Learn.NeuroMod.DAMod == D1Mod || (ly.Learn.NeuroMod.DAMod == D2Mod && hasRew && ctx.PlusPhase.IsTrue()) { - Neurons.Set(geRaw, int(ni), int(GeRaw), int(di)) - Neurons.Set(ly.Acts.Dt.GeSynFromRawSteady(geRaw), int(ni), int(GeSyn), int(di)) + Neurons.Set(geRaw, int(ni), int(di), int(GeRaw)) + Neurons.Set(ly.Acts.Dt.GeSynFromRawSteady(geRaw), int(ni), int(di), int(GeSyn)) } case PVLayer: if hasRew && ctx.PlusPhase.IsTrue() { @@ -385,29 +385,29 @@ func (ly *LayerParams) SpecialPreGs(ctx *Context, pi, ni, di uint32, drvGe float pv = GlobalScalars.Value(int(GvPVneg), int(di)) } pc := ly.Acts.PopCode.EncodeGe(pni, ly.Indexes.NNeurons, pv) - Neurons.Set(pc, int(ni), int(GeRaw), int(di)) - Neurons.Set(ly.Acts.Dt.GeSynFromRawSteady(pc), int(ni), int(GeSyn), int(di)) + Neurons.Set(pc, int(ni), int(di), int(GeRaw)) + Neurons.Set(ly.Acts.Dt.GeSynFromRawSteady(pc), int(ni), int(di), int(GeSyn)) } case LDTLayer: geRaw := 0.4 * GlobalScalars.Value(int(GvACh), int(di)) - Neurons.Set(geRaw, int(ni), int(GeRaw), int(di)) - Neurons.Set(ly.Acts.Dt.GeSynFromRawSteady(geRaw), int(ni), int(GeSyn), int(di)) + Neurons.Set(geRaw, int(ni), int(di), int(GeRaw)) + Neurons.Set(ly.Acts.Dt.GeSynFromRawSteady(geRaw), int(ni), int(di), int(GeSyn)) case VTALayer: geRaw := ly.RWDa.GeFromDA(GlobalScalars.Value(int(GvVtaDA), int(di))) - Neurons.Set(geRaw, int(ni), int(GeRaw), int(di)) - Neurons.Set(ly.Acts.Dt.GeSynFromRawSteady(geRaw), int(ni), int(GeSyn), int(di)) + Neurons.Set(geRaw, int(ni), int(di), int(GeRaw)) + Neurons.Set(ly.Acts.Dt.GeSynFromRawSteady(geRaw), int(ni), int(di), int(GeSyn)) case RewLayer: NeuronSetFlag(NeuronHasExt, ni, di) SetNeuronExtPosNeg(ctx, ni, di, GlobalScalars.Value(int(GvRew), int(di))) // Rew must be set in Context! case RWDaLayer: geRaw := ly.RWDa.GeFromDA(GlobalScalars.Value(int(GvDA), int(di))) - Neurons.Set(geRaw, int(ni), int(GeRaw), int(di)) - Neurons.Set(ly.Acts.Dt.GeSynFromRawSteady(geRaw), int(ni), int(GeSyn), int(di)) + Neurons.Set(geRaw, int(ni), int(di), int(GeRaw)) + Neurons.Set(ly.Acts.Dt.GeSynFromRawSteady(geRaw), int(ni), int(di), int(GeSyn)) case TDDaLayer: geRaw := ly.TDDa.GeFromDA(GlobalScalars.Value(int(GvDA), int(di))) - Neurons.Set(geRaw, int(ni), int(GeRaw), int(di)) - Neurons.Set(ly.Acts.Dt.GeSynFromRawSteady(geRaw), int(ni), int(GeSyn), int(di)) + Neurons.Set(geRaw, int(ni), int(di), int(GeRaw)) + Neurons.Set(ly.Acts.Dt.GeSynFromRawSteady(geRaw), int(ni), int(di), int(GeSyn)) case TDIntegLayer: NeuronSetFlag(NeuronHasExt, ni, di) SetNeuronExtPosNeg(ctx, ni, di, GlobalScalars.Value(int(GvRewPred), int(di))) @@ -422,12 +422,12 @@ func (ly *LayerParams) SpecialPreGs(ctx *Context, pi, ni, di uint32, drvGe float func (ly *LayerParams) SpecialPostGs(ctx *Context, ni, di uint32, saveVal float32) { switch ly.Type { case PulvinarLayer, PTMaintLayer, CTLayer, BLALayer: - Neurons.Set(saveVal, int(ni), int(GeExt), int(di)) + Neurons.Set(saveVal, int(ni), int(di), int(GeExt)) case PTPredLayer: - Neurons.Set(saveVal, int(ni), int(GeExt), int(di)) - orig := Neurons.Value(int(ni), int(CtxtGeOrig), int(di)) + Neurons.Set(saveVal, int(ni), int(di), int(GeExt)) + orig := Neurons.Value(int(ni), int(di), int(CtxtGeOrig)) if orig < 0.05 { - Neurons.Set(0.0, int(ni), int(Ge), int(di)) + Neurons.Set(0.0, int(ni), int(di), int(Ge)) } default: } @@ -439,8 +439,8 @@ func (ly *LayerParams) SpecialPostGs(ctx *Context, ni, di uint32, saveVal float3 func (ly *LayerParams) GFromRawSyn(ctx *Context, ni, di uint32) { extraRaw := float32(0) extraSyn := float32(0) - nrnGModRaw := Neurons.Value(int(ni), int(GModRaw), int(di)) - nrnGModSyn := Neurons.Value(int(ni), int(GModSyn), int(di)) + nrnGModRaw := Neurons.Value(int(ni), int(di), int(GModRaw)) + nrnGModSyn := Neurons.Value(int(ni), int(di), int(GModSyn)) ach := GlobalScalars.Value(int(GvACh), int(di)) switch ly.Type { case PTMaintLayer: @@ -450,8 +450,8 @@ func (ly *LayerParams) GFromRawSyn(ctx *Context, ni, di uint32) { } md += ly.Acts.Dend.ModBase // key: excluding GModMaint here, so active maintenance can persist - Neurons.SetMul(md, int(ni), int(GeRaw), int(di)) - Neurons.SetMul(md, int(ni), int(GeSyn), int(di)) + Neurons.SetMul(md, int(ni), int(di), int(GeRaw)) + Neurons.SetMul(md, int(ni), int(di), int(GeSyn)) extraRaw = ly.Acts.Dend.ModGain * nrnGModRaw if ly.Acts.Dend.ModACh.IsTrue() { extraRaw *= ach @@ -468,56 +468,56 @@ func (ly *LayerParams) GFromRawSyn(ctx *Context, ni, di uint32) { if md > 1 { md = 1 } - Neurons.SetMul(md, int(ni), int(GeRaw), int(di)) - Neurons.SetMul(md, int(ni), int(GeSyn), int(di)) + Neurons.SetMul(md, int(ni), int(di), int(GeRaw)) + Neurons.SetMul(md, int(ni), int(di), int(GeSyn)) } } - geRaw := Neurons.Value(int(ni), int(GeRaw), int(di)) - geSyn := Neurons.Value(int(ni), int(GeSyn), int(di)) + geRaw := Neurons.Value(int(ni), int(di), int(GeRaw)) + geSyn := Neurons.Value(int(ni), int(di), int(GeSyn)) ly.Acts.NMDAFromRaw(ctx, ni, di, geRaw+extraRaw) ly.Acts.MaintNMDAFromRaw(ctx, ni, di) // uses GMaintRaw directly ly.Learn.LrnNMDAFromRaw(ctx, ni, di, geRaw) ly.Acts.GvgccFromVm(ctx, ni, di) - ege := Neurons.Value(int(ni), int(Gnmda), int(di)) + Neurons.Value(int(ni), int(GnmdaMaint), int(di)) + Neurons.Value(int(ni), int(Gvgcc), int(di)) + extraSyn + ege := Neurons.Value(int(ni), int(di), int(Gnmda)) + Neurons.Value(int(ni), int(di), int(GnmdaMaint)) + Neurons.Value(int(ni), int(di), int(Gvgcc)) + extraSyn ly.Acts.GeFromSyn(ctx, ni, di, geSyn, ege) // sets nrn.GeExt too ly.Acts.GkFromVm(ctx, ni, di) ly.Acts.GSkCaFromCa(ctx, ni, di) - Neurons.Set(ly.Acts.GiFromSyn(ctx, ni, di, Neurons.Value(int(ni), int(GiSyn), int(di))), int(ni), int(GiSyn), int(di)) + Neurons.Set(ly.Acts.GiFromSyn(ctx, ni, di, Neurons.Value(int(ni), int(di), int(GiSyn))), int(ni), int(di), int(GiSyn)) } // 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(GiSyn), int(di)) + Neurons.Value(int(ni), int(GiNoise), int(di)) + ly.Learn.NeuroMod.GiFromACh(GlobalScalars.Value(int(GvACh), 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)) - Neurons.Set(gi, int(ni), int(Gi), int(di)) - Neurons.Set(0.0, int(ni), int(SSGiDend), int(di)) + 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 { - ext := Neurons.Value(int(ni), int(Ext), int(di)) // nonDrivePct - Neurons.Set(ext*ly.Acts.Dend.SSGi*ssgi, int(ni), int(SSGiDend), int(di)) + ext := Neurons.Value(int(ni), int(di), int(Ext)) // nonDrivePct + Neurons.Set(ext*ly.Acts.Dend.SSGi*ssgi, int(ni), int(di), int(SSGiDend)) } else { if !(ly.Acts.Clamp.IsInput.IsTrue() || ly.Acts.Clamp.IsTarget.IsTrue()) { - Neurons.Set(ly.Acts.Dend.SSGi*ssgi, int(ni), int(SSGiDend), int(di)) + Neurons.Set(ly.Acts.Dend.SSGi*ssgi, int(ni), int(di), int(SSGiDend)) } } - vm := Neurons.Value(int(ni), int(VmDend), int(di)) - nrnGABAB := Neurons.Value(int(ni), int(GABAB), int(di)) - nrnGABABx := Neurons.Value(int(ni), int(GABABx), int(di)) + vm := Neurons.Value(int(ni), int(di), int(VmDend)) + nrnGABAB := Neurons.Value(int(ni), int(di), int(GABAB)) + nrnGABABx := Neurons.Value(int(ni), int(di), int(GABABx)) ly.Acts.GabaB.GABAB(gi, &nrnGABAB, &nrnGABABx) - Neurons.Set(nrnGABAB, int(ni), int(GABAB), int(di)) - Neurons.Set(nrnGABABx, int(ni), int(GABABx), int(di)) + Neurons.Set(nrnGABAB, int(ni), int(di), int(GABAB)) + Neurons.Set(nrnGABABx, int(ni), int(di), int(GABABx)) nrnGgabaB := ly.Acts.GabaB.GgabaB(nrnGABAB, vm) - Neurons.Set(nrnGgabaB, int(ni), int(GgabaB), int(di)) + Neurons.Set(nrnGgabaB, int(ni), int(di), int(GgabaB)) // Gk was already init - Neurons.SetAdd(nrnGgabaB, int(ni), int(Gk), int(di)) + Neurons.SetAdd(nrnGgabaB, int(ni), int(di), int(Gk)) } // GNeuroMod does neuromodulation of conductances func (ly *LayerParams) GNeuroMod(ctx *Context, ni, di uint32) { ggain := ly.Learn.NeuroMod.GGain(GlobalScalars.Value(int(GvDA), int(di)) + GlobalScalars.Value(int(GvDAtonic), int(di))) - Neurons.SetMul(ggain, int(ni), int(Ge), int(di)) - Neurons.SetMul(ggain, int(ni), int(Gi), int(di)) + Neurons.SetMul(ggain, int(ni), int(di), int(Ge)) + Neurons.SetMul(ggain, int(ni), int(di), int(Gi)) } //////// SendSpike @@ -529,22 +529,22 @@ func (ly *LayerParams) SpikeFromG(ctx *Context, lpi, ni, di uint32) { ly.Learn.CaFromSpike(ctx, ni, di) lmax := PoolAvgMax(AMGeInt, AMCycle, Max, lpi, di) if lmax > 0 { - Neurons.Set(Neurons.Value(int(ni), int(GeInt), int(di))/lmax, int(ni), int(GeIntNorm), int(di)) + Neurons.Set(Neurons.Value(int(ni), int(di), int(GeInt))/lmax, int(ni), int(di), int(GeIntNorm)) } else { - Neurons.Set(Neurons.Value(int(ni), int(GeInt), int(di)), int(ni), int(GeIntNorm), int(di)) + Neurons.Set(Neurons.Value(int(ni), int(di), int(GeInt)), int(ni), int(di), int(GeIntNorm)) } if ctx.Cycle >= ly.Acts.Dt.MaxCycStart { - Neurons.SetAdd(ly.Learn.CaSpk.Dt.PDt*(Neurons.Value(int(ni), int(CaSpkM), int(di))-Neurons.Value(int(ni), int(SpkMaxCa), int(di))), int(ni), int(SpkMaxCa), int(di)) - spkmax := Neurons.Value(int(ni), int(SpkMaxCa), int(di)) - if spkmax > Neurons.Value(int(ni), int(SpkMax), int(di)) { - Neurons.Set(spkmax, int(ni), int(SpkMax), int(di)) + Neurons.SetAdd(ly.Learn.CaSpk.Dt.PDt*(Neurons.Value(int(ni), int(di), int(CaSpkM))-Neurons.Value(int(ni), int(di), int(SpkMaxCa))), int(ni), int(di), int(SpkMaxCa)) + spkmax := Neurons.Value(int(ni), int(di), int(SpkMaxCa)) + if spkmax > Neurons.Value(int(ni), int(di), int(SpkMax)) { + Neurons.Set(spkmax, int(ni), int(di), int(SpkMax)) } } - spk := Neurons.Value(int(ni), int(Spike), int(di)) + spk := Neurons.Value(int(ni), int(di), int(Spike)) if spk > 0 { spksper := ctx.ThetaCycles / 8 bin := min(ctx.Cycle/spksper, 7) - Neurons.SetAdd(spk, int(ni), int(SpkBin0+NeuronVars(bin)), int(di)) + Neurons.SetAdd(spk, int(ni), int(di), int(SpkBin0+NeuronVars(bin))) } } @@ -566,7 +566,7 @@ func (ly *LayerParams) SendSpike(ctx *Context, ni, di uint32) { // PostSpikeSpecial does updates at neuron level after spiking has been computed. // This is where special layer types add extra code. func (ly *LayerParams) PostSpikeSpecial(ctx *Context, lpi, pi, ni, di uint32) { - Neurons.Set(Neurons.Value(int(ni), int(CaSpkP), int(di)), int(ni), int(Burst), int(di)) + Neurons.Set(Neurons.Value(int(ni), int(di), int(CaSpkP)), int(ni), int(di), int(Burst)) li := ly.Index pil := pi - ly.PoolSt // 0-n pool index pnn := uint32(PoolNNeurons(pi)) @@ -578,18 +578,18 @@ func (ly *LayerParams) PostSpikeSpecial(ctx *Context, lpi, pi, ni, di uint32) { actMax := PoolAvgMax(AMCaSpkP, AMCycle, Max, lpi, di) actAvg := PoolAvgMax(AMCaSpkP, AMCycle, Avg, lpi, di) thr := ly.Bursts.ThrFromAvgMax(actAvg, actMax) - if Neurons.Value(int(ni), int(CaSpkP), int(di)) < thr { - Neurons.Set(0.0, int(ni), int(Burst), int(di)) + if Neurons.Value(int(ni), int(di), int(CaSpkP)) < thr { + Neurons.Set(0.0, int(ni), int(di), int(Burst)) } } case PTPredLayer, CTLayer: if ctx.Cycle == ctx.ThetaCycles-1 { if ly.CT.DecayTau == 0 { - Neurons.Set(Neurons.Value(int(ni), int(CtxtGeRaw), int(di)), int(ni), int(CtxtGe), int(di)) + Neurons.Set(Neurons.Value(int(ni), int(di), int(CtxtGeRaw)), int(ni), int(di), int(CtxtGe)) } else { - Neurons.SetAdd(Neurons.Value(int(ni), int(CtxtGeRaw), int(di)), int(ni), int(CtxtGe), int(di)) + Neurons.SetAdd(Neurons.Value(int(ni), int(di), int(CtxtGeRaw)), int(ni), int(di), int(CtxtGe)) } - Neurons.Set(Neurons.Value(int(ni), int(CtxtGe), int(di)), int(ni), int(CtxtGeOrig), int(di)) + Neurons.Set(Neurons.Value(int(ni), int(di), int(CtxtGe)), int(ni), int(di), int(CtxtGeOrig)) } case VSGatedLayer: dr := float32(0) @@ -598,39 +598,39 @@ func (ly *LayerParams) PostSpikeSpecial(ctx *Context, lpi, pi, ni, di uint32) { } else { dr = GlobalScalars.Value(int(GvVSMatrixHasGated), int(di)) } - Neurons.Set(dr, int(ni), int(Act), int(di)) + Neurons.Set(dr, int(ni), int(di), int(Act)) case BLALayer: if ctx.Cycle == ctx.ThetaCycles-1 { if hasRew { - Neurons.Set(0.0, int(ni), int(CtxtGe), int(di)) - Neurons.Set(0.0, int(ni), int(CtxtGeOrig), int(di)) + Neurons.Set(0.0, int(ni), int(di), int(CtxtGe)) + Neurons.Set(0.0, int(ni), int(di), int(CtxtGeOrig)) } else if GlobalScalars.Value(int(GvACh), int(di)) > 0.1 { - Neurons.Set(Neurons.Value(int(ni), int(CtxtGeRaw), int(di)), int(ni), int(CtxtGe), int(di)) - Neurons.Set(Neurons.Value(int(ni), int(CtxtGe), int(di)), int(ni), int(CtxtGeOrig), int(di)) + Neurons.Set(Neurons.Value(int(ni), int(di), int(CtxtGeRaw)), int(ni), int(di), int(CtxtGe)) + Neurons.Set(Neurons.Value(int(ni), int(di), int(CtxtGe)), int(ni), int(di), int(CtxtGeOrig)) } } case LHbLayer: if pni == 0 { - Neurons.Set(GlobalScalars.Value(int(GvLHbDip), int(di)), int(ni), int(Act), int(di)) + Neurons.Set(GlobalScalars.Value(int(GvLHbDip), int(di)), int(ni), int(di), int(Act)) } else { - Neurons.Set(GlobalScalars.Value(int(GvLHbBurst), int(di)), int(ni), int(Act), int(di)) + Neurons.Set(GlobalScalars.Value(int(GvLHbBurst), int(di)), int(ni), int(di), int(Act)) } - Neurons.Set(ly.Acts.Dt.GeSynFromRawSteady(Neurons.Value(int(ni), int(GeRaw), int(di))), int(ni), int(GeSyn), int(di)) + Neurons.Set(ly.Acts.Dt.GeSynFromRawSteady(Neurons.Value(int(ni), int(di), int(GeRaw))), int(ni), int(di), int(GeSyn)) case DrivesLayer: dr := GlobalVectors.Value(int(GvDrives), int(pil-1), int(di)) act := dr if dr > 0 { act = ly.Acts.PopCode.EncodeValue(pni, pnn, dr) } - Neurons.Set(act, int(ni), int(Act), int(di)) + Neurons.Set(act, int(ni), int(di), int(Act)) case UrgencyLayer: ur := GlobalScalars.Value(int(GvUrgency), int(di)) act := ur if ur > 0 { act = ly.Acts.PopCode.EncodeValue(pni, pnn, ur) } - Neurons.Set(act, int(ni), int(Act), int(di)) + Neurons.Set(act, int(ni), int(di), int(Act)) case USLayer: us := RubiconUSStimValue(di, pil-1, ly.Learn.NeuroMod.Valence) act := us @@ -639,7 +639,7 @@ func (ly *LayerParams) PostSpikeSpecial(ctx *Context, lpi, pi, ni, di uint32) { } // D2Mod = final if ly.Learn.NeuroMod.DAMod == D1Mod || (ly.Learn.NeuroMod.DAMod == D2Mod && hasRew && ctx.PlusPhase.IsTrue()) { - Neurons.Set(act, int(ni), int(Act), int(di)) + Neurons.Set(act, int(ni), int(di), int(Act)) } case PVLayer: if hasRew { @@ -650,41 +650,41 @@ func (ly *LayerParams) PostSpikeSpecial(ctx *Context, lpi, pi, ni, di uint32) { pv = GlobalScalars.Value(int(GvPVneg), int(di)) } act := ly.Acts.PopCode.EncodeValue(pni, ly.Indexes.NNeurons, pv) - Neurons.Set(act, int(ni), int(Act), int(di)) + Neurons.Set(act, int(ni), int(di), int(Act)) } case LDTLayer: // I set this in CyclePost - Neurons.Set(GlobalScalars.Value(int(GvAChRaw), int(di)), int(ni), int(Act), int(di)) + Neurons.Set(GlobalScalars.Value(int(GvAChRaw), int(di)), int(ni), int(di), int(Act)) case VTALayer: // I set this in CyclePost - Neurons.Set(GlobalScalars.Value(int(GvVtaDA), int(di)), int(ni), int(Act), int(di)) + Neurons.Set(GlobalScalars.Value(int(GvVtaDA), int(di)), int(ni), int(di), int(Act)) case RewLayer: - Neurons.Set(GlobalScalars.Value(int(GvRew), int(di)), int(ni), int(Act), int(di)) + Neurons.Set(GlobalScalars.Value(int(GvRew), int(di)), int(ni), int(di), int(Act)) case RWPredLayer: // clipped linear - Neurons.Set(ly.RWPred.PredRange.ClipValue(Neurons.Value(int(ni), int(Ge), int(di))), int(ni), int(Act), int(di)) + 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(ActInt), int(di)), int(li), int(LayerRewPredPos), int(di)) + LayerStates.Set(Neurons.Value(int(ni), int(di), int(ActInt)), int(li), int(LayerRewPredPos), int(di)) } else { - LayerStates.Set(Neurons.Value(int(ni), int(ActInt), int(di)), int(li), int(LayerRewPredNeg), int(di)) + LayerStates.Set(Neurons.Value(int(ni), int(di), int(ActInt)), int(li), int(LayerRewPredNeg), int(di)) } case RWDaLayer: // I set this in CyclePost - Neurons.Set(GlobalScalars.Value(int(GvDA), int(di)), int(ni), int(Act), int(di)) + Neurons.Set(GlobalScalars.Value(int(GvDA), int(di)), int(ni), int(di), int(Act)) case TDPredLayer: // linear - Neurons.Set(Neurons.Value(int(ni), int(Ge), int(di)), int(ni), int(Act), int(di)) + 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(ActInt), int(di)), int(li), int(LayerRewPredPos), int(di)) + LayerStates.Set(Neurons.Value(int(ni), int(di), int(ActInt)), int(li), int(LayerRewPredPos), int(di)) } else { - LayerStates.Set(Neurons.Value(int(ni), int(ActInt), int(di)), int(li), int(LayerRewPredNeg), int(di)) + LayerStates.Set(Neurons.Value(int(ni), int(di), int(ActInt)), int(li), int(LayerRewPredNeg), int(di)) } case TDIntegLayer: - Neurons.Set(GlobalScalars.Value(int(GvRewPred), int(di)), int(ni), int(Act), int(di)) + Neurons.Set(GlobalScalars.Value(int(GvRewPred), int(di)), int(ni), int(di), int(Act)) case TDDaLayer: // I set this in CyclePost - Neurons.Set(GlobalScalars.Value(int(GvDA), int(di)), int(ni), int(Act), int(di)) + Neurons.Set(GlobalScalars.Value(int(GvDA), int(di)), int(ni), int(di), int(Act)) default: } } @@ -694,14 +694,14 @@ func (ly *LayerParams) PostSpikeSpecial(ctx *Context, lpi, pi, ni, di uint32) { func (ly *LayerParams) PostSpike(ctx *Context, lpi, pi, ni, di uint32) { ly.PostSpikeSpecial(ctx, lpi, pi, ni, di) intdt := ly.Acts.Dt.IntDt - Neurons.SetAdd(intdt*(Neurons.Value(int(ni), int(Ge), int(di))-Neurons.Value(int(ni), int(GeInt), int(di))), int(ni), int(GeInt), int(di)) - Neurons.SetAdd(intdt*(Neurons.Value(int(ni), int(GiSyn), int(di))-Neurons.Value(int(ni), int(GiInt), int(di))), int(ni), int(GiInt), int(di)) + Neurons.SetAdd(intdt*(Neurons.Value(int(ni), int(di), int(Ge))-Neurons.Value(int(ni), int(di), int(GeInt))), int(ni), int(di), int(GeInt)) + Neurons.SetAdd(intdt*(Neurons.Value(int(ni), int(di), int(GiSyn))-Neurons.Value(int(ni), int(di), int(GiInt))), int(ni), int(di), int(GiInt)) // act int is reset at start of the plus phase -- needs faster integration: if ctx.PlusPhase.IsTrue() { intdt *= 3.0 } // using reg act here now - Neurons.SetAdd(intdt*(Neurons.Value(int(ni), int(Act), int(di))-Neurons.Value(int(ni), int(ActInt), int(di))), int(ni), int(ActInt), int(di)) + Neurons.SetAdd(intdt*(Neurons.Value(int(ni), int(di), int(Act))-Neurons.Value(int(ni), int(di), int(ActInt))), int(ni), int(di), int(ActInt)) } // CyclePost is called after the standard Cycle update, as a separate @@ -905,10 +905,10 @@ func (ly *LayerParams) NewStatePool(ctx *Context, pi, di uint32) { // NewStateNeuron handles all initialization at start of new input pattern. // Should already have presented the external input to the network at this point. func (ly *LayerParams) NewStateNeuron(ctx *Context, ni, di uint32) { - Neurons.Set(Neurons.Value(int(ni), int(Burst), int(di)), int(ni), int(BurstPrv), int(di)) - Neurons.Set(Neurons.Value(int(ni), int(CaSpkD), int(di)), int(ni), int(SpkPrv), int(di)) - Neurons.Set(0.0, int(ni), int(SpkMax), int(di)) - Neurons.Set(0.0, int(ni), int(SpkMaxCa), int(di)) + Neurons.Set(Neurons.Value(int(ni), int(di), int(Burst)), int(ni), int(di), int(BurstPrv)) + Neurons.Set(Neurons.Value(int(ni), int(di), int(CaSpkD)), int(ni), int(di), int(SpkPrv)) + Neurons.Set(0.0, int(ni), int(di), int(SpkMax)) + Neurons.Set(0.0, int(ni), int(di), int(SpkMaxCa)) ly.Acts.DecayState(ctx, ni, di, ly.Acts.Decay.Act, ly.Acts.Decay.Glong, ly.Acts.Decay.AHP) // Note: synapse-level Ca decay happens in DWt ly.Acts.KNaNewState(ctx, ni, di) @@ -947,21 +947,21 @@ func (ly *LayerParams) AvgGeM(ctx *Context, di uint32, geIntMinusMax, giIntMinus // MinusPhaseNeuron does neuron level minus-phase updating func (ly *LayerParams) MinusPhaseNeuron(ctx *Context, ni, di uint32) { - Neurons.Set(Neurons.Value(int(ni), int(ActInt), int(di)), int(ni), int(ActM), int(di)) - Neurons.Set(Neurons.Value(int(ni), int(CaSpkP), int(di)), int(ni), int(CaSpkPM), int(di)) + Neurons.Set(Neurons.Value(int(ni), int(di), int(ActInt)), int(ni), int(di), int(ActM)) + Neurons.Set(Neurons.Value(int(ni), int(di), int(CaSpkP)), int(ni), int(di), int(CaSpkPM)) } // PlusPhaseStartNeuron does neuron level plus-phase start: // applies Target inputs as External inputs. func (ly *LayerParams) PlusPhaseStartNeuron(ctx *Context, ni, di uint32) { if NeuronHasFlag(NeuronHasTarg, ni, di) { // will be clamped in plus phase - Neurons.Set(Neurons.Value(int(ni), int(Target), int(di)), int(ni), int(Ext), int(di)) + Neurons.Set(Neurons.Value(int(ni), int(di), int(Target)), int(ni), int(di), int(Ext)) NeuronSetFlag(NeuronHasExt, ni, di) // get fresh update on plus phase output acts - Neurons.Set(-1.0, int(ni), int(ISI), int(di)) - Neurons.Set(-1.0, int(ni), int(ISIAvg), int(di)) + Neurons.Set(-1.0, int(ni), int(di), int(ISI)) + Neurons.Set(-1.0, int(ni), int(di), int(ISIAvg)) // reset for plus phase - Neurons.Set(ly.Acts.Init.Act, int(ni), int(ActInt), int(di)) + Neurons.Set(ly.Acts.Init.Act, int(ni), int(di), int(ActInt)) } } @@ -973,9 +973,9 @@ func (ly *LayerParams) PlusPhasePool(ctx *Context, pi, di uint32) { func (ly *LayerParams) PlusPhaseNeuron(ctx *Context, ni, di uint32) { pi := ly.PoolIndex(NeuronIxs.Value(int(ni), int(NrnSubPool))) lpi := ly.PoolIndex(0) - Neurons.Set(Neurons.Value(int(ni), int(ActInt), int(di)), int(ni), int(ActP), int(di)) - nrnCaSpkP := Neurons.Value(int(ni), int(CaSpkP), int(di)) - nrnCaSpkD := Neurons.Value(int(ni), int(CaSpkD), int(di)) + Neurons.Set(Neurons.Value(int(ni), int(di), int(ActInt)), int(ni), int(di), int(ActP)) + nrnCaSpkP := Neurons.Value(int(ni), int(di), int(CaSpkP)) + nrnCaSpkD := Neurons.Value(int(ni), int(di), int(CaSpkD)) da := GlobalScalars.Value(int(GvDA), int(di)) ach := GlobalScalars.Value(int(GvACh), int(di)) mlr := ly.Learn.RLRate.RLRateSigDeriv(nrnCaSpkD, PoolAvgMax(AMCaSpkD, AMCycle, Max, lpi, di)) @@ -985,14 +985,14 @@ 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(SpkPrv), int(di))) // delta on previous trial + 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 dlr = 0 // first pool is novelty / curiosity -- no learn } case VSPatchLayer: da = GlobalScalars.Value(int(GvVSPatchPosRPE), int(di)) // our own personal modlr = ly.Learn.NeuroMod.LRMod(da, ach) - mlr = ly.Learn.RLRate.RLRateSigDeriv(Neurons.Value(int(ni), int(SpkPrv), int(di)), 1) // note: don't have proper max here + mlr = ly.Learn.RLRate.RLRateSigDeriv(Neurons.Value(int(ni), int(di), int(SpkPrv)), 1) // note: don't have proper max here case MatrixLayer: if hasRew { // reward time mlr = 1 // don't use dig deriv @@ -1002,15 +1002,15 @@ func (ly *LayerParams) PlusPhaseNeuron(ctx *Context, ni, di uint32) { default: dlr = ly.Learn.RLRate.RLRateDiff(nrnCaSpkP, nrnCaSpkD) } - Neurons.Set(mlr*dlr*modlr, int(ni), int(RLRate), int(di)) + Neurons.Set(mlr*dlr*modlr, int(ni), int(di), int(RLRate)) var tau float32 - sahpN := Neurons.Value(int(ni), int(SahpN), int(di)) - nrnSaphCa := Neurons.Value(int(ni), int(SahpCa), int(di)) + sahpN := Neurons.Value(int(ni), int(di), int(SahpN)) + nrnSaphCa := Neurons.Value(int(ni), int(di), int(SahpCa)) ly.Acts.Sahp.NinfTauFromCa(nrnSaphCa, &sahpN, &tau) nrnSaphCa = ly.Acts.Sahp.CaInt(nrnSaphCa, nrnCaSpkD) - Neurons.Set(sahpN, int(ni), int(SahpN), int(di)) - Neurons.Set(nrnSaphCa, int(ni), int(SahpCa), int(di)) - Neurons.Set(ly.Acts.Sahp.GsAHP(sahpN), int(ni), int(Gsahp), int(di)) + Neurons.Set(sahpN, int(ni), int(di), int(SahpN)) + Neurons.Set(nrnSaphCa, int(ni), int(di), int(SahpCa)) + Neurons.Set(ly.Acts.Sahp.GsAHP(sahpN), int(ni), int(di), int(Gsahp)) } //gosl:end @@ -1074,9 +1074,9 @@ func (ly *Layer) ApplyExtValue(lni, di uint32, val float32, clearMask, setMask N return } if toTarg { - Neurons.Set(val, int(ni), int(Target), int(di)) + Neurons.Set(val, int(ni), int(di), int(Target)) } else { - Neurons.Set(val, int(ni), int(Ext), int(di)) + Neurons.Set(val, int(ni), int(di), int(Ext)) } NeuronClearFlag(clearMask, ni, di) NeuronSetFlag(setMask, ni, di) @@ -1252,8 +1252,8 @@ func (ly *Layer) PlusPhaseActAvg(ctx *Context) { dTrgSum := float32(0) avgSum := float32(0) for di := uint32(0); di < ctx.NData; di++ { - dTrgSum += ly.Params.LearnTrgAvgErrLRate() * (Neurons.Value(int(ni), int(CaSpkP), int(di)) - Neurons.Value(int(ni), int(CaSpkD), int(di))) - avgSum += ly.Params.Acts.Dt.LongAvgDt * (Neurons.Value(int(ni), int(ActM), int(di)) - NeuronAvgs.Value(int(ni), int(ActAvg))) + dTrgSum += ly.Params.LearnTrgAvgErrLRate() * (Neurons.Value(int(ni), int(di), int(CaSpkP)) - Neurons.Value(int(ni), int(di), int(CaSpkD))) + avgSum += ly.Params.Acts.Dt.LongAvgDt * (Neurons.Value(int(ni), int(di), int(ActM)) - NeuronAvgs.Value(int(ni), int(ActAvg))) } NeuronAvgs.SetAdd(dTrgSum, int(ni), int(DTrgAvg)) NeuronAvgs.SetAdd(avgSum, int(ni), int(ActAvg)) @@ -1274,10 +1274,10 @@ func (ly *Layer) TargToExt(ctx *Context) { if !NeuronHasFlag(NeuronHasTarg, ni, di) { // will be clamped in plus phase continue } - Neurons.Set(Neurons.Value(int(ni), int(Target), int(di)), int(ni), int(Ext), int(di)) + Neurons.Set(Neurons.Value(int(ni), int(di), int(Target)), int(ni), int(di), int(Ext)) NeuronSetFlag(NeuronHasExt, ni, di) - Neurons.Set(-1, int(ni), int(ISI), int(di)) // get fresh update on plus phase output acts - Neurons.Set(-1, int(ni), int(ISIAvg), int(di)) + Neurons.Set(-1, int(ni), int(di), int(ISI)) // get fresh update on plus phase output acts + Neurons.Set(-1, int(ni), int(di), int(ISIAvg)) } } } @@ -1295,10 +1295,10 @@ func (ly *Layer) ClearTargExt(ctx *Context) { if !NeuronHasFlag(NeuronHasTarg, ni, di) { // will be clamped in plus phase continue } - Neurons.Set(0, int(ni), int(Ext), int(di)) + Neurons.Set(0, int(ni), int(di), int(Ext)) NeuronClearFlag(NeuronHasExt, ni, di) - Neurons.Set(-1, int(ni), int(ISI), int(di)) // get fresh update on plus phase output acts - Neurons.Set(-1, int(ni), int(ISIAvg), int(di)) + Neurons.Set(-1, int(ni), int(di), int(ISI)) // get fresh update on plus phase output acts + Neurons.Set(-1, int(ni), int(di), int(ISIAvg)) } } } @@ -1312,7 +1312,7 @@ func (ly *Layer) SpkSt1(ctx *Context) { continue } for di := uint32(0); di < ctx.NData; di++ { - Neurons.Set(Neurons.Value(int(ni), int(CaSpkP), int(di)), int(SpkSt1), int(ni), int(di)) + Neurons.Set(Neurons.Value(int(ni), int(di), int(CaSpkP)), int(SpkSt1), int(di), int(ni)) } } } @@ -1326,7 +1326,7 @@ func (ly *Layer) SpkSt2(ctx *Context) { continue } for di := uint32(0); di < ctx.NData; di++ { - Neurons.Set(Neurons.Value(int(ni), int(CaSpkP), int(di)), int(SpkSt2), int(ni), int(di)) + Neurons.Set(Neurons.Value(int(ni), int(di), int(CaSpkP)), int(SpkSt2), int(di), int(ni)) } } } diff --git a/axon/act-layer.goal b/axon/act-layer.goal index 68c08590..9e329ff9 100644 --- a/axon/act-layer.goal +++ b/axon/act-layer.goal @@ -34,8 +34,8 @@ func (ly *LayerParams) ApplyExtFlags(clearMask, setMask *NeuronFlags, toTarg *bo // InitExt initializes external input state for given neuron func (ly *LayerParams) InitExt(ni, di uint32) { - Neurons[ni, Ext, di] = 0.0 - Neurons[ni, Target, di] = 0.0 + Neurons[ni, di, Ext] = 0.0 + Neurons[ni, di, Target] = 0.0 NeuronClearFlag(NeuronHasExt|NeuronHasTarg|NeuronHasCmpr, ni, di) } @@ -51,9 +51,9 @@ func (ly *LayerParams) ApplyExtValue(ni, di uint32, val float32) { var toTarg bool ly.ApplyExtFlags(&clearMask, &setMask, &toTarg) if toTarg { - Neurons[ni, Target, di] = val + Neurons[ni, di, Target] = val } else { - Neurons[ni, Ext, di] = val + Neurons[ni, di, Ext] = val } NeuronClearFlag(clearMask, ni, di) NeuronSetFlag(setMask, ni, di) @@ -74,15 +74,15 @@ func (ly *LayerParams) ApplyExtsNeuron(ni, di uint32) { func SetNeuronExtPosNeg(ctx *Context, ni, di uint32, val float32) { if ni == 0 { if val >= 0 { - Neurons[ni, Ext, di] = val + Neurons[ni, di, Ext] = val } else { - Neurons[ni, Ext, di] = float32(0) + Neurons[ni, di, Ext] = float32(0) } } else { if val >= 0 { - Neurons[ni, Ext, di] = float32(0) + Neurons[ni, di, Ext] = float32(0) } else { - Neurons[ni, Ext, di] = -val + Neurons[ni, di, Ext] = -val } } } @@ -159,14 +159,14 @@ func (ly *LayerParams) GatherSpikes(ctx *Context, ni, di uint32) { // GatherSpikesInit initializes G*Raw and G*Syn values for given neuron // prior to integration. func (ly *LayerParams) GatherSpikesInit(ctx *Context, ni, di uint32) { - Neurons[ni, GeRaw, di] = 0.0 - Neurons[ni, GiRaw, di] = 0.0 - Neurons[ni, GModRaw, di] = 0.0 - Neurons[ni, GModSyn, di] = 0.0 - Neurons[ni, GMaintRaw, di] = 0.0 - Neurons[ni, CtxtGeRaw, di] = 0.0 - Neurons[ni, GeSyn, di] = NeuronAvgs[ni, GeBase] - Neurons[ni, GiSyn, di] = NeuronAvgs[ni, GiBase] + Neurons[ni, di, GeRaw] = 0.0 + Neurons[ni, di, GiRaw] = 0.0 + Neurons[ni, di, GModRaw] = 0.0 + Neurons[ni, di, GModSyn] = 0.0 + Neurons[ni, di, GMaintRaw] = 0.0 + Neurons[ni, di, CtxtGeRaw] = 0.0 + Neurons[ni, di, GeSyn] = NeuronAvgs[ni, GeBase] + Neurons[ni, di, GiSyn] = NeuronAvgs[ni, GiBase] } // GiFromSpikes gets the Spike, GeRaw and GeExt from neurons in the pools @@ -179,9 +179,9 @@ func (ly *LayerParams) GatherSpikesInit(ctx *Context, ni, di uint32) { // Also updates all AvgMax values at the Cycle level. func (ly *LayerParams) GiFromSpikes(ctx *Context, ni, di uint32) { pi := ly.PoolIndex(NeuronIxs[ni, NrnSubPool]) - spk := Neurons[ni, Spike, di] - geRaw := Neurons[ni, GeRaw, di] - geExt := Neurons[ni, GeExt, di] + spk := Neurons[ni, di, Spike] + geRaw := Neurons[ni, di, GeRaw] + 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 @@ -261,7 +261,7 @@ func (ly *LayerParams) PulvinarDriver(ctx *Context, lni, di uint32, drvGe, nonDr dpi := dly.PoolIndex(0) drvMax := PoolAvgMax(AMCaSpkP, AMCycle, Max, dpi, di) *nonDrivePct = ly.Pulv.NonDrivePct(drvMax) // how much non-driver to keep - burst := Neurons[dly.Indexes.NeurSt+lni, Burst, di] + burst := Neurons[dly.Indexes.NeurSt+lni, di, Burst] *drvGe = ly.Pulv.DriveGe(burst) } @@ -272,7 +272,7 @@ func (ly *LayerParams) GInteg(ctx *Context, pi, ni, di uint32) { nonDrivePct := float32(0) if ly.Type == PulvinarLayer { ly.PulvinarDriver(ctx, ni-ly.Indexes.NeurSt, di, &drvGe, &nonDrivePct) - Neurons[ni, Ext, di] = nonDrivePct // use for regulating inhibition + Neurons[ni, di, Ext] = nonDrivePct // use for regulating inhibition } saveVal := ly.SpecialPreGs(ctx, pi, ni, di, drvGe, nonDrivePct) @@ -293,31 +293,31 @@ func (ly *LayerParams) SpecialPreGs(ctx *Context, pi, ni, di uint32, drvGe float pil := pi - ly.PoolSt pnn := uint32(PoolNNeurons(pi)) pni := NeuronIxs[ni, NrnNeurIndex] - uint32(PoolsInt[pi, PoolNeurSt, di]) - nrnCtxtGe := Neurons[ni, CtxtGe, di] - nrnGeRaw := Neurons[ni, GeRaw, di] + nrnCtxtGe := Neurons[ni, di, CtxtGe] + nrnGeRaw := Neurons[ni, di, GeRaw] hasRew := GlobalScalars[GvHasRew, di] > 0 switch ly.Type { case PTPredLayer, CTLayer: geCtxt := ly.CT.GeGain * nrnCtxtGe - Neurons[ni, GeRaw, di] += geCtxt + Neurons[ni, di, GeRaw] += geCtxt if ly.CT.DecayDt > 0 { - Neurons[ni, CtxtGe, di] -= ly.CT.DecayDt * nrnCtxtGe + Neurons[ni, di, CtxtGe] -= ly.CT.DecayDt * nrnCtxtGe } ctxExt := ly.Acts.Dt.GeSynFromRawSteady(geCtxt) - Neurons[ni, GeSyn, di] += ctxExt + Neurons[ni, di, GeSyn] += ctxExt saveVal = ctxExt // used In PostGs to set nrn.GeExt case PTMaintLayer: if ly.Acts.SMaint.On.IsTrue() { - saveVal = ly.Acts.SMaint.Inhib * Neurons[ni, GMaintRaw, di] // used In PostGs to set nrn.GeExt + saveVal = ly.Acts.SMaint.Inhib * Neurons[ni, di, GMaintRaw] // used In PostGs to set nrn.GeExt } case PulvinarLayer: if ctx.PlusPhase.IsFalse() { break } // geSyn, goes into nrn.GeExt in PostGs, so inhibition gets it - saveVal = nonDrivePct*Neurons[ni, GeSyn, di] + ly.Acts.Dt.GeSynFromRawSteady(drvGe) - Neurons[ni, GeRaw, di] = nonDrivePct*nrnGeRaw + drvGe - Neurons[ni, GeSyn, di] = saveVal + saveVal = nonDrivePct*Neurons[ni, di, GeSyn] + ly.Acts.Dt.GeSynFromRawSteady(drvGe) + Neurons[ni, di, GeRaw] = nonDrivePct*nrnGeRaw + drvGe + Neurons[ni, di, GeSyn] = saveVal case VSGatedLayer: dr := float32(0) if pil == 0 { @@ -326,16 +326,16 @@ func (ly *LayerParams) SpecialPreGs(ctx *Context, pi, ni, di uint32, drvGe float dr = GlobalScalars[GvVSMatrixHasGated, di] } dr = math32.Abs(dr) - Neurons[ni, GeRaw, di] = dr - Neurons[ni, GeSyn, di] = ly.Acts.Dt.GeSynFromRawSteady(dr) + Neurons[ni, di, GeRaw] = dr + Neurons[ni, di, GeSyn] = ly.Acts.Dt.GeSynFromRawSteady(dr) case BLALayer: if ly.Learn.NeuroMod.IsBLAExt() { md := max(-GlobalScalars[GvDA, di], float32(0)) // ext is modulated by negative da - geCtxt := md * ly.CT.GeGain * Neurons[ni, CtxtGeOrig, di] - Neurons[ni, GeRaw, di] += geCtxt + geCtxt := md * ly.CT.GeGain * Neurons[ni, di, CtxtGeOrig] + Neurons[ni, di, GeRaw] += geCtxt ctxExt := ly.Acts.Dt.GeSynFromRawSteady(geCtxt) - Neurons[ni, GeSyn, di] += ctxExt + Neurons[ni, di, GeSyn] += ctxExt saveVal = ctxExt // used In PostGs to set nrn.GeExt } case LHbLayer: @@ -345,24 +345,24 @@ func (ly *LayerParams) SpecialPreGs(ctx *Context, pi, ni, di uint32, drvGe float } else { geRaw = 0.2 * math32.Abs(GlobalScalars[GvLHbBurst, di]) } - Neurons[ni, GeRaw, di] = geRaw - Neurons[ni, GeSyn, di] = ly.Acts.Dt.GeSynFromRawSteady(geRaw) + Neurons[ni, di, GeRaw] = geRaw + Neurons[ni, di, GeSyn] = ly.Acts.Dt.GeSynFromRawSteady(geRaw) case DrivesLayer: dr := GlobalVectors[GvDrives, pil-1, di] geRaw := dr if dr > 0 { geRaw = ly.Acts.PopCode.EncodeGe(pni, pnn, dr) } - Neurons[ni, GeRaw, di] = geRaw - Neurons[ni, GeSyn, di] = ly.Acts.Dt.GeSynFromRawSteady(geRaw) + Neurons[ni, di, GeRaw] = geRaw + Neurons[ni, di, GeSyn] = ly.Acts.Dt.GeSynFromRawSteady(geRaw) case UrgencyLayer: ur := GlobalScalars[GvUrgency, di] geRaw := ur if ur > 0 { geRaw = ly.Acts.PopCode.EncodeGe(pni, pnn, ur) } - Neurons[ni, GeRaw, di] = geRaw - Neurons[ni, GeSyn, di] = ly.Acts.Dt.GeSynFromRawSteady(geRaw) + Neurons[ni, di, GeRaw] = geRaw + Neurons[ni, di, GeSyn] = ly.Acts.Dt.GeSynFromRawSteady(geRaw) case USLayer: us := RubiconUSStimValue(di, pil-1, ly.Learn.NeuroMod.Valence) geRaw := us @@ -371,8 +371,8 @@ func (ly *LayerParams) SpecialPreGs(ctx *Context, pi, ni, di uint32, drvGe float } // D2Mod = final if ly.Learn.NeuroMod.DAMod == D1Mod || (ly.Learn.NeuroMod.DAMod == D2Mod && hasRew && ctx.PlusPhase.IsTrue()) { - Neurons[ni, GeRaw, di] = geRaw - Neurons[ni, GeSyn, di] = ly.Acts.Dt.GeSynFromRawSteady(geRaw) + Neurons[ni, di, GeRaw] = geRaw + Neurons[ni, di, GeSyn] = ly.Acts.Dt.GeSynFromRawSteady(geRaw) } case PVLayer: if hasRew && ctx.PlusPhase.IsTrue() { @@ -383,29 +383,29 @@ func (ly *LayerParams) SpecialPreGs(ctx *Context, pi, ni, di uint32, drvGe float pv = GlobalScalars[GvPVneg, di] } pc := ly.Acts.PopCode.EncodeGe(pni, ly.Indexes.NNeurons, pv) - Neurons[ni, GeRaw, di] = pc - Neurons[ni, GeSyn, di] = ly.Acts.Dt.GeSynFromRawSteady(pc) + Neurons[ni, di, GeRaw] = pc + Neurons[ni, di, GeSyn] = ly.Acts.Dt.GeSynFromRawSteady(pc) } case LDTLayer: geRaw := 0.4 * GlobalScalars[GvACh, di] - Neurons[ni, GeRaw, di] = geRaw - Neurons[ni, GeSyn, di] = ly.Acts.Dt.GeSynFromRawSteady(geRaw) + Neurons[ni, di, GeRaw] = geRaw + Neurons[ni, di, GeSyn] = ly.Acts.Dt.GeSynFromRawSteady(geRaw) case VTALayer: geRaw := ly.RWDa.GeFromDA(GlobalScalars[GvVtaDA, di]) - Neurons[ni, GeRaw, di] = geRaw - Neurons[ni, GeSyn, di] = ly.Acts.Dt.GeSynFromRawSteady(geRaw) + Neurons[ni, di, GeRaw] = geRaw + Neurons[ni, di, GeSyn] = ly.Acts.Dt.GeSynFromRawSteady(geRaw) case RewLayer: NeuronSetFlag(NeuronHasExt, ni, di) SetNeuronExtPosNeg(ctx, ni, di, GlobalScalars[GvRew, di]) // Rew must be set in Context! case RWDaLayer: geRaw := ly.RWDa.GeFromDA(GlobalScalars[GvDA, di]) - Neurons[ni, GeRaw, di] = geRaw - Neurons[ni, GeSyn, di] = ly.Acts.Dt.GeSynFromRawSteady(geRaw) + Neurons[ni, di, GeRaw] = geRaw + Neurons[ni, di, GeSyn] = ly.Acts.Dt.GeSynFromRawSteady(geRaw) case TDDaLayer: geRaw := ly.TDDa.GeFromDA(GlobalScalars[GvDA, di]) - Neurons[ni, GeRaw, di] = geRaw - Neurons[ni, GeSyn, di] = ly.Acts.Dt.GeSynFromRawSteady(geRaw) + Neurons[ni, di, GeRaw] = geRaw + Neurons[ni, di, GeSyn] = ly.Acts.Dt.GeSynFromRawSteady(geRaw) case TDIntegLayer: NeuronSetFlag(NeuronHasExt, ni, di) SetNeuronExtPosNeg(ctx, ni, di, GlobalScalars[GvRewPred, di]) @@ -420,12 +420,12 @@ func (ly *LayerParams) SpecialPreGs(ctx *Context, pi, ni, di uint32, drvGe float func (ly *LayerParams) SpecialPostGs(ctx *Context, ni, di uint32, saveVal float32) { switch ly.Type { case PulvinarLayer, PTMaintLayer, CTLayer, BLALayer: - Neurons[ni, GeExt, di] = saveVal + Neurons[ni, di, GeExt] = saveVal case PTPredLayer: - Neurons[ni, GeExt, di] = saveVal - orig := Neurons[ni, CtxtGeOrig, di] + Neurons[ni, di, GeExt] = saveVal + orig := Neurons[ni, di, CtxtGeOrig] if orig < 0.05 { - Neurons[ni, Ge, di] = 0.0 + Neurons[ni, di, Ge] = 0.0 } default: } @@ -437,8 +437,8 @@ func (ly *LayerParams) SpecialPostGs(ctx *Context, ni, di uint32, saveVal float3 func (ly *LayerParams) GFromRawSyn(ctx *Context, ni, di uint32) { extraRaw := float32(0) extraSyn := float32(0) - nrnGModRaw := Neurons[ni, GModRaw, di] - nrnGModSyn := Neurons[ni, GModSyn, di] + nrnGModRaw := Neurons[ni, di, GModRaw] + nrnGModSyn := Neurons[ni, di, GModSyn] ach := GlobalScalars[GvACh, di] switch ly.Type { case PTMaintLayer: @@ -448,8 +448,8 @@ func (ly *LayerParams) GFromRawSyn(ctx *Context, ni, di uint32) { } md += ly.Acts.Dend.ModBase // key: excluding GModMaint here, so active maintenance can persist - Neurons[ni, GeRaw, di] *= md - Neurons[ni, GeSyn, di] *= md + Neurons[ni, di, GeRaw] *= md + Neurons[ni, di, GeSyn] *= md extraRaw = ly.Acts.Dend.ModGain * nrnGModRaw if ly.Acts.Dend.ModACh.IsTrue() { extraRaw *= ach @@ -466,56 +466,56 @@ func (ly *LayerParams) GFromRawSyn(ctx *Context, ni, di uint32) { if md > 1 { md = 1 } - Neurons[ni, GeRaw, di] *= md - Neurons[ni, GeSyn, di] *= md + Neurons[ni, di, GeRaw] *= md + Neurons[ni, di, GeSyn] *= md } } - geRaw := Neurons[ni, GeRaw, di] - geSyn := Neurons[ni, GeSyn, di] + geRaw := Neurons[ni, di, GeRaw] + geSyn := Neurons[ni, di, GeSyn] ly.Acts.NMDAFromRaw(ctx, ni, di, geRaw+extraRaw) ly.Acts.MaintNMDAFromRaw(ctx, ni, di) // uses GMaintRaw directly ly.Learn.LrnNMDAFromRaw(ctx, ni, di, geRaw) ly.Acts.GvgccFromVm(ctx, ni, di) - ege := Neurons[ni, Gnmda, di] + Neurons[ni, GnmdaMaint, di] + Neurons[ni, Gvgcc, di] + extraSyn + ege := Neurons[ni, di, Gnmda] + Neurons[ni, di, GnmdaMaint] + Neurons[ni, di, Gvgcc] + extraSyn ly.Acts.GeFromSyn(ctx, ni, di, geSyn, ege) // sets nrn.GeExt too ly.Acts.GkFromVm(ctx, ni, di) ly.Acts.GSkCaFromCa(ctx, ni, di) - Neurons[ni, GiSyn, di] = ly.Acts.GiFromSyn(ctx, ni, di, Neurons[ni, GiSyn, di]) + Neurons[ni, di, GiSyn] = ly.Acts.GiFromSyn(ctx, ni, di, Neurons[ni, di, GiSyn]) } // 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, GiSyn, di] + Neurons[ni, GiNoise, di] + ly.Learn.NeuroMod.GiFromACh(GlobalScalars[GvACh, 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] - Neurons[ni, Gi, di] = gi - Neurons[ni, SSGiDend, di] = 0.0 + Neurons[ni, di, Gi] = gi + Neurons[ni, di, SSGiDend] = 0.0 if ctx.PlusPhase.IsTrue() && ly.Type == PulvinarLayer { - ext := Neurons[ni, Ext, di] // nonDrivePct - Neurons[ni, SSGiDend, di] = ext * ly.Acts.Dend.SSGi * ssgi + ext := Neurons[ni, di, Ext] // nonDrivePct + Neurons[ni, di, SSGiDend] = ext * ly.Acts.Dend.SSGi * ssgi } else { if !(ly.Acts.Clamp.IsInput.IsTrue() || ly.Acts.Clamp.IsTarget.IsTrue()) { - Neurons[ni, SSGiDend, di] = ly.Acts.Dend.SSGi * ssgi + Neurons[ni, di, SSGiDend] = ly.Acts.Dend.SSGi * ssgi } } - vm := Neurons[ni, VmDend, di] - nrnGABAB := Neurons[ni, GABAB, di] - nrnGABABx := Neurons[ni, GABABx, di] + vm := Neurons[ni, di, VmDend] + nrnGABAB := Neurons[ni, di, GABAB] + nrnGABABx := Neurons[ni, di, GABABx] ly.Acts.GabaB.GABAB(gi, &nrnGABAB, &nrnGABABx) - Neurons[ni, GABAB, di] = nrnGABAB - Neurons[ni, GABABx, di] = nrnGABABx + Neurons[ni, di, GABAB] = nrnGABAB + Neurons[ni, di, GABABx] = nrnGABABx nrnGgabaB := ly.Acts.GabaB.GgabaB(nrnGABAB, vm) - Neurons[ni, GgabaB, di] = nrnGgabaB + Neurons[ni, di, GgabaB] = nrnGgabaB // Gk was already init - Neurons[ni, Gk, di] += nrnGgabaB + Neurons[ni, di, Gk] += nrnGgabaB } // GNeuroMod does neuromodulation of conductances func (ly *LayerParams) GNeuroMod(ctx *Context, ni, di uint32) { ggain := ly.Learn.NeuroMod.GGain(GlobalScalars[GvDA, di] + GlobalScalars[GvDAtonic, di]) - Neurons[ni, Ge, di] *= ggain - Neurons[ni, Gi, di] *= ggain + Neurons[ni, di, Ge] *= ggain + Neurons[ni, di, Gi] *= ggain } //////// SendSpike @@ -527,22 +527,22 @@ func (ly *LayerParams) SpikeFromG(ctx *Context, lpi, ni, di uint32) { ly.Learn.CaFromSpike(ctx, ni, di) lmax := PoolAvgMax(AMGeInt, AMCycle, Max, lpi, di) if lmax > 0 { - Neurons[ni, GeIntNorm, di] = Neurons[ni, GeInt, di] / lmax + Neurons[ni, di, GeIntNorm] = Neurons[ni, di, GeInt] / lmax } else { - Neurons[ni, GeIntNorm, di] = Neurons[ni, GeInt, di] + Neurons[ni, di, GeIntNorm] = Neurons[ni, di, GeInt] } if ctx.Cycle >= ly.Acts.Dt.MaxCycStart { - Neurons[ni, SpkMaxCa, di] += ly.Learn.CaSpk.Dt.PDt * (Neurons[ni, CaSpkM, di] - Neurons[ni, SpkMaxCa, di]) - spkmax := Neurons[ni, SpkMaxCa, di] - if spkmax > Neurons[ni, SpkMax, di] { - Neurons[ni, SpkMax, di] = spkmax + Neurons[ni, di, SpkMaxCa] += ly.Learn.CaSpk.Dt.PDt * (Neurons[ni, di, CaSpkM] - Neurons[ni, di, SpkMaxCa]) + spkmax := Neurons[ni, di, SpkMaxCa] + if spkmax > Neurons[ni, di, SpkMax] { + Neurons[ni, di, SpkMax] = spkmax } } - spk := Neurons[ni, Spike, di] + spk := Neurons[ni, di, Spike] if spk > 0 { spksper := ctx.ThetaCycles / 8 bin := min(ctx.Cycle / spksper, 7) - Neurons[ni, SpkBin0 + NeuronVars(bin), di] += spk + Neurons[ni, di, SpkBin0 + NeuronVars(bin)] += spk } } @@ -564,7 +564,7 @@ func (ly *LayerParams) SendSpike(ctx *Context, ni, di uint32) { // PostSpikeSpecial does updates at neuron level after spiking has been computed. // This is where special layer types add extra code. func (ly *LayerParams) PostSpikeSpecial(ctx *Context, lpi, pi, ni, di uint32) { - Neurons[ni, Burst, di] = Neurons[ni, CaSpkP, di] + Neurons[ni, di, Burst] = Neurons[ni, di, CaSpkP] li := ly.Index pil := pi - ly.PoolSt // 0-n pool index pnn := uint32(PoolNNeurons(pi)) @@ -576,18 +576,18 @@ func (ly *LayerParams) PostSpikeSpecial(ctx *Context, lpi, pi, ni, di uint32) { actMax := PoolAvgMax(AMCaSpkP, AMCycle, Max, lpi, di) actAvg := PoolAvgMax(AMCaSpkP, AMCycle, Avg, lpi, di) thr := ly.Bursts.ThrFromAvgMax(actAvg, actMax) - if Neurons[ni, CaSpkP, di] < thr { - Neurons[ni, Burst, di] = 0.0 + if Neurons[ni, di, CaSpkP] < thr { + Neurons[ni, di, Burst] = 0.0 } } case PTPredLayer, CTLayer: if ctx.Cycle == ctx.ThetaCycles-1 { if ly.CT.DecayTau == 0 { - Neurons[ni, CtxtGe, di] = Neurons[ni, CtxtGeRaw, di] + Neurons[ni, di, CtxtGe] = Neurons[ni, di, CtxtGeRaw] } else { - Neurons[ni, CtxtGe, di] += Neurons[ni, CtxtGeRaw, di] + Neurons[ni, di, CtxtGe] += Neurons[ni, di, CtxtGeRaw] } - Neurons[ni, CtxtGeOrig, di] = Neurons[ni, CtxtGe, di] + Neurons[ni, di, CtxtGeOrig] = Neurons[ni, di, CtxtGe] } case VSGatedLayer: dr := float32(0) @@ -596,39 +596,39 @@ func (ly *LayerParams) PostSpikeSpecial(ctx *Context, lpi, pi, ni, di uint32) { } else { dr = GlobalScalars[GvVSMatrixHasGated, di] } - Neurons[ni, Act, di] = dr + Neurons[ni, di, Act] = dr case BLALayer: if ctx.Cycle == ctx.ThetaCycles-1 { if hasRew { - Neurons[ni, CtxtGe, di] = 0.0 - Neurons[ni, CtxtGeOrig, di] = 0.0 + Neurons[ni, di, CtxtGe] = 0.0 + Neurons[ni, di, CtxtGeOrig] = 0.0 } else if GlobalScalars[GvACh, di] > 0.1 { - Neurons[ni, CtxtGe, di] = Neurons[ni, CtxtGeRaw, di] - Neurons[ni, CtxtGeOrig, di] = Neurons[ni, CtxtGe, di] + Neurons[ni, di, CtxtGe] = Neurons[ni, di, CtxtGeRaw] + Neurons[ni, di, CtxtGeOrig] = Neurons[ni, di, CtxtGe] } } case LHbLayer: if pni == 0 { - Neurons[ni, Act, di] = GlobalScalars[GvLHbDip, di] + Neurons[ni, di, Act] = GlobalScalars[GvLHbDip, di] } else { - Neurons[ni, Act, di] = GlobalScalars[GvLHbBurst, di] + Neurons[ni, di, Act] = GlobalScalars[GvLHbBurst, di] } - Neurons[ni, GeSyn, di] = ly.Acts.Dt.GeSynFromRawSteady(Neurons[ni, GeRaw, di]) + Neurons[ni, di, GeSyn] = ly.Acts.Dt.GeSynFromRawSteady(Neurons[ni, di, GeRaw]) case DrivesLayer: dr := GlobalVectors[GvDrives, pil-1, di] act := dr if dr > 0 { act = ly.Acts.PopCode.EncodeValue(pni, pnn, dr) } - Neurons[ni, Act, di] = act + Neurons[ni, di, Act] = act case UrgencyLayer: ur := GlobalScalars[GvUrgency, di] act := ur if ur > 0 { act = ly.Acts.PopCode.EncodeValue(pni, pnn, ur) } - Neurons[ni, Act, di] = act + Neurons[ni, di, Act] = act case USLayer: us := RubiconUSStimValue(di, pil-1, ly.Learn.NeuroMod.Valence) act := us @@ -637,7 +637,7 @@ func (ly *LayerParams) PostSpikeSpecial(ctx *Context, lpi, pi, ni, di uint32) { } // D2Mod = final if ly.Learn.NeuroMod.DAMod == D1Mod || (ly.Learn.NeuroMod.DAMod == D2Mod && hasRew && ctx.PlusPhase.IsTrue()) { - Neurons[ni, Act, di] = act + Neurons[ni, di, Act] = act } case PVLayer: if hasRew { @@ -648,41 +648,41 @@ func (ly *LayerParams) PostSpikeSpecial(ctx *Context, lpi, pi, ni, di uint32) { pv = GlobalScalars[GvPVneg, di] } act := ly.Acts.PopCode.EncodeValue(pni, ly.Indexes.NNeurons, pv) - Neurons[ni, Act, di] = act + Neurons[ni, di, Act] = act } case LDTLayer: // I set this in CyclePost - Neurons[ni, Act, di] = GlobalScalars[GvAChRaw, di] + Neurons[ni, di, Act] = GlobalScalars[GvAChRaw, di] case VTALayer: // I set this in CyclePost - Neurons[ni, Act, di] = GlobalScalars[GvVtaDA, di] + Neurons[ni, di, Act] = GlobalScalars[GvVtaDA, di] case RewLayer: - Neurons[ni, Act, di] = GlobalScalars[GvRew, di] + Neurons[ni, di, Act] = GlobalScalars[GvRew, di] case RWPredLayer: // clipped linear - Neurons[ni, Act, di] = ly.RWPred.PredRange.ClipValue(Neurons[ni, Ge, di]) + Neurons[ni, di, Act] = ly.RWPred.PredRange.ClipValue(Neurons[ni, di, Ge]) if pni == 0 { - LayerStates[li, LayerRewPredPos, di] = Neurons[ni, ActInt, di] + LayerStates[li, LayerRewPredPos, di] = Neurons[ni, di, ActInt] } else { - LayerStates[li, LayerRewPredNeg, di] = Neurons[ni, ActInt, di] + LayerStates[li, LayerRewPredNeg, di] = Neurons[ni, di, ActInt] } case RWDaLayer: // I set this in CyclePost - Neurons[ni, Act, di] = GlobalScalars[GvDA, di] + Neurons[ni, di, Act] = GlobalScalars[GvDA, di] case TDPredLayer: // linear - Neurons[ni, Act, di] = Neurons[ni, Ge, di] + Neurons[ni, di, Act] = Neurons[ni, di, Ge] if pni == 0 { - LayerStates[li, LayerRewPredPos, di] = Neurons[ni, ActInt, di] + LayerStates[li, LayerRewPredPos, di] = Neurons[ni, di, ActInt] } else { - LayerStates[li, LayerRewPredNeg, di] = Neurons[ni, ActInt, di] + LayerStates[li, LayerRewPredNeg, di] = Neurons[ni, di, ActInt] } case TDIntegLayer: - Neurons[ni, Act, di] = GlobalScalars[GvRewPred, di] + Neurons[ni, di, Act] = GlobalScalars[GvRewPred, di] case TDDaLayer: // I set this in CyclePost - Neurons[ni, Act, di] = GlobalScalars[GvDA, di] + Neurons[ni, di, Act] = GlobalScalars[GvDA, di] default: } } @@ -692,14 +692,14 @@ func (ly *LayerParams) PostSpikeSpecial(ctx *Context, lpi, pi, ni, di uint32) { func (ly *LayerParams) PostSpike(ctx *Context, lpi, pi, ni, di uint32) { ly.PostSpikeSpecial(ctx, lpi, pi, ni, di) intdt := ly.Acts.Dt.IntDt - Neurons[ni, GeInt, di] += intdt * (Neurons[ni, Ge, di] - Neurons[ni, GeInt, di]) - Neurons[ni, GiInt, di] += intdt * (Neurons[ni, GiSyn, di] - Neurons[ni, GiInt, di]) + Neurons[ni, di, GeInt] += intdt * (Neurons[ni, di, Ge] - Neurons[ni, di, GeInt]) + Neurons[ni, di, GiInt] += intdt * (Neurons[ni, di, GiSyn] - Neurons[ni, di, GiInt]) // act int is reset at start of the plus phase -- needs faster integration: if ctx.PlusPhase.IsTrue() { intdt *= 3.0 } // using reg act here now - Neurons[ni, ActInt, di] += intdt * (Neurons[ni, Act, di] - Neurons[ni, ActInt, di]) + Neurons[ni, di, ActInt] += intdt * (Neurons[ni, di, Act] - Neurons[ni, di, ActInt]) } // CyclePost is called after the standard Cycle update, as a separate @@ -904,10 +904,10 @@ func (ly *LayerParams) NewStatePool(ctx *Context, pi, di uint32) { // NewStateNeuron handles all initialization at start of new input pattern. // Should already have presented the external input to the network at this point. func (ly *LayerParams) NewStateNeuron(ctx *Context, ni, di uint32) { - Neurons[ni, BurstPrv, di] = Neurons[ni, Burst, di] - Neurons[ni, SpkPrv, di] = Neurons[ni, CaSpkD, di] - Neurons[ni, SpkMax, di] = 0.0 - Neurons[ni, SpkMaxCa, di] = 0.0 + Neurons[ni, di, BurstPrv] = Neurons[ni, di, Burst] + Neurons[ni, di, SpkPrv] = Neurons[ni, di, CaSpkD] + Neurons[ni, di, SpkMax] = 0.0 + Neurons[ni, di, SpkMaxCa] = 0.0 ly.Acts.DecayState(ctx, ni, di, ly.Acts.Decay.Act, ly.Acts.Decay.Glong, ly.Acts.Decay.AHP) // Note: synapse-level Ca decay happens in DWt ly.Acts.KNaNewState(ctx, ni, di) @@ -946,21 +946,21 @@ func (ly *LayerParams) AvgGeM(ctx *Context, di uint32, geIntMinusMax, giIntMinus // MinusPhaseNeuron does neuron level minus-phase updating func (ly *LayerParams) MinusPhaseNeuron(ctx *Context, ni, di uint32) { - Neurons[ni, ActM, di] = Neurons[ni, ActInt, di] - Neurons[ni, CaSpkPM, di] = Neurons[ni, CaSpkP, di] + Neurons[ni, di, ActM] = Neurons[ni, di, ActInt] + Neurons[ni, di, CaSpkPM] = Neurons[ni, di, CaSpkP] } // PlusPhaseStartNeuron does neuron level plus-phase start: // applies Target inputs as External inputs. func (ly *LayerParams) PlusPhaseStartNeuron(ctx *Context, ni, di uint32) { if NeuronHasFlag(NeuronHasTarg, ni, di) { // will be clamped in plus phase - Neurons[ni, Ext, di] = Neurons[ni, Target, di] + Neurons[ni, di, Ext] = Neurons[ni, di, Target] NeuronSetFlag(NeuronHasExt, ni, di) // get fresh update on plus phase output acts - Neurons[ni, ISI, di] = -1.0 - Neurons[ni, ISIAvg, di] = -1.0 + Neurons[ni, di, ISI] = -1.0 + Neurons[ni, di, ISIAvg] = -1.0 // reset for plus phase - Neurons[ni, ActInt, di] = ly.Acts.Init.Act + Neurons[ni, di, ActInt] = ly.Acts.Init.Act } } @@ -972,9 +972,9 @@ func (ly *LayerParams) PlusPhasePool(ctx *Context, pi, di uint32) { func (ly *LayerParams) PlusPhaseNeuron(ctx *Context, ni, di uint32) { pi := ly.PoolIndex(NeuronIxs[ni, NrnSubPool]) lpi := ly.PoolIndex(0) - Neurons[ni, ActP, di] = Neurons[ni, ActInt, di] - nrnCaSpkP := Neurons[ni, CaSpkP, di] - nrnCaSpkD := Neurons[ni, CaSpkD, di] + Neurons[ni, di, ActP] = Neurons[ni, di, ActInt] + nrnCaSpkP := Neurons[ni, di, CaSpkP] + nrnCaSpkD := Neurons[ni, di, CaSpkD] da := GlobalScalars[GvDA, di] ach := GlobalScalars[GvACh, di] mlr := ly.Learn.RLRate.RLRateSigDeriv(nrnCaSpkD, PoolAvgMax(AMCaSpkD, AMCycle, Max, lpi, di)) @@ -984,14 +984,14 @@ func (ly *LayerParams) PlusPhaseNeuron(ctx *Context, ni, di uint32) { switch ly.Type { case BLALayer: - dlr = ly.Learn.RLRate.RLRateDiff(nrnCaSpkP, Neurons[ni, SpkPrv, di]) // delta on previous trial + 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 dlr = 0 // first pool is novelty / curiosity -- no learn } case VSPatchLayer: da = GlobalScalars[GvVSPatchPosRPE, di] // our own personal modlr = ly.Learn.NeuroMod.LRMod(da, ach) - mlr = ly.Learn.RLRate.RLRateSigDeriv(Neurons[ni, SpkPrv, di], 1) // note: don't have proper max here + mlr = ly.Learn.RLRate.RLRateSigDeriv(Neurons[ni, di, SpkPrv], 1) // note: don't have proper max here case MatrixLayer: if hasRew { // reward time mlr = 1 // don't use dig deriv @@ -1001,15 +1001,15 @@ func (ly *LayerParams) PlusPhaseNeuron(ctx *Context, ni, di uint32) { default: dlr = ly.Learn.RLRate.RLRateDiff(nrnCaSpkP, nrnCaSpkD) } - Neurons[ni, RLRate, di] = mlr * dlr * modlr + Neurons[ni, di, RLRate] = mlr * dlr * modlr var tau float32 - sahpN := Neurons[ni, SahpN, di] - nrnSaphCa := Neurons[ni, SahpCa, di] + sahpN := Neurons[ni, di, SahpN] + nrnSaphCa := Neurons[ni, di, SahpCa] ly.Acts.Sahp.NinfTauFromCa(nrnSaphCa, &sahpN, &tau) nrnSaphCa = ly.Acts.Sahp.CaInt(nrnSaphCa, nrnCaSpkD) - Neurons[ni, SahpN, di] = sahpN - Neurons[ni, SahpCa, di] = nrnSaphCa - Neurons[ni, Gsahp, di] = ly.Acts.Sahp.GsAHP(sahpN) + Neurons[ni, di, SahpN] = sahpN + Neurons[ni, di, SahpCa] = nrnSaphCa + Neurons[ni, di, Gsahp] = ly.Acts.Sahp.GsAHP(sahpN) } //gosl:end @@ -1073,9 +1073,9 @@ func (ly *Layer) ApplyExtValue(lni, di uint32, val float32, clearMask, setMask N return } if toTarg { - Neurons[ni, Target, di] = val + Neurons[ni, di, Target] = val } else { - Neurons[ni, Ext, di] = val + Neurons[ni, di, Ext] = val } NeuronClearFlag(clearMask, ni, di) NeuronSetFlag(setMask, ni, di) @@ -1251,8 +1251,8 @@ func (ly *Layer) PlusPhaseActAvg(ctx *Context) { dTrgSum := float32(0) avgSum := float32(0) for di := uint32(0); di < ctx.NData; di++ { - dTrgSum += ly.Params.LearnTrgAvgErrLRate() * (Neurons[ni, CaSpkP, di] - Neurons[ni, CaSpkD, di]) - avgSum += ly.Params.Acts.Dt.LongAvgDt * (Neurons[ni, ActM, di] - NeuronAvgs[ni, ActAvg]) + dTrgSum += ly.Params.LearnTrgAvgErrLRate() * (Neurons[ni, di, CaSpkP] - Neurons[ni, di, CaSpkD]) + avgSum += ly.Params.Acts.Dt.LongAvgDt * (Neurons[ni, di, ActM] - NeuronAvgs[ni, ActAvg]) } NeuronAvgs[ni, DTrgAvg] += dTrgSum NeuronAvgs[ni, ActAvg] += avgSum @@ -1273,10 +1273,10 @@ func (ly *Layer) TargToExt(ctx *Context) { if !NeuronHasFlag(NeuronHasTarg, ni, di) { // will be clamped in plus phase continue } - Neurons[ni, Ext, di] = Neurons[ni, Target, di] + Neurons[ni, di, Ext] = Neurons[ni, di, Target] NeuronSetFlag(NeuronHasExt, ni, di) - Neurons[ni, ISI, di] = -1 // get fresh update on plus phase output acts - Neurons[ni, ISIAvg, di] = -1 + Neurons[ni, di, ISI] = -1 // get fresh update on plus phase output acts + Neurons[ni, di, ISIAvg] = -1 } } } @@ -1294,10 +1294,10 @@ func (ly *Layer) ClearTargExt(ctx *Context) { if !NeuronHasFlag(NeuronHasTarg, ni, di) { // will be clamped in plus phase continue } - Neurons[ni, Ext, di] = 0 + Neurons[ni, di, Ext] = 0 NeuronClearFlag(NeuronHasExt, ni, di) - Neurons[ni, ISI, di] = -1 // get fresh update on plus phase output acts - Neurons[ni, ISIAvg, di] = -1 + Neurons[ni, di, ISI] = -1 // get fresh update on plus phase output acts + Neurons[ni, di, ISIAvg] = -1 } } } @@ -1311,7 +1311,7 @@ func (ly *Layer) SpkSt1(ctx *Context) { continue } for di := uint32(0); di < ctx.NData; di++ { - Neurons[SpkSt1, ni, di] = Neurons[ni, CaSpkP, di] + Neurons[SpkSt1, di, ni] = Neurons[ni, di, CaSpkP] } } } @@ -1325,7 +1325,7 @@ func (ly *Layer) SpkSt2(ctx *Context) { continue } for di := uint32(0); di < ctx.NData; di++ { - Neurons[SpkSt2, ni, di] = Neurons[ni, CaSpkP, di] + Neurons[SpkSt2, di, ni] = Neurons[ni, di, CaSpkP] } } } diff --git a/axon/act-net.go b/axon/act-net.go index 6dc32d5d..e58443e1 100644 --- a/axon/act-net.go +++ b/axon/act-net.go @@ -393,7 +393,7 @@ func GPUTestWrite(i uint32) { //gosl:kernel di := ctx.DataIndex(i) ni := ctx.ItemIndex(i) for vi := Spike; vi < NeuronVarsN; vi++ { - Neurons.Set(float32(ni*1000+uint32(vi)), int(ni), int(vi), int(di)) + Neurons.Set(float32(ni*1000+uint32(vi)), int(ni), int(di), int(vi)) } } diff --git a/axon/act-net.goal b/axon/act-net.goal index 8ec23efb..bee92dad 100644 --- a/axon/act-net.goal +++ b/axon/act-net.goal @@ -387,7 +387,7 @@ func GPUTestWrite(i uint32) { //gosl:kernel di := ctx.DataIndex(i) ni := ctx.ItemIndex(i) for vi := Spike; vi < NeuronVarsN; vi++ { - Neurons[ni, vi, di] = float32(ni*1000 + uint32(vi)) + Neurons[ni, di, vi] = float32(ni*1000 + uint32(vi)) } } diff --git a/axon/act-path.go b/axon/act-path.go index ba6a6d96..cd12992e 100644 --- a/axon/act-path.go +++ b/axon/act-path.go @@ -251,22 +251,22 @@ func (pt *PathParams) GatherSpikesGSyn(ctx *Context, ly *LayerParams, ni, di uin switch pt.Com.GType { case ExcitatoryG: *gSyn = ly.Acts.Dt.GeSynFromRaw(*gSyn, gRaw) - Neurons.SetAdd(gRaw, int(ni), int(GeRaw), int(di)) - Neurons.SetAdd(*gSyn, int(ni), int(GeSyn), int(di)) + Neurons.SetAdd(gRaw, int(ni), int(di), int(GeRaw)) + Neurons.SetAdd(*gSyn, int(ni), int(di), int(GeSyn)) case InhibitoryG: *gSyn = ly.Acts.Dt.GiSynFromRaw(*gSyn, gRaw) - Neurons.SetAdd(gRaw, int(ni), int(GiRaw), int(di)) - Neurons.SetAdd(*gSyn, int(ni), int(GiSyn), int(di)) + Neurons.SetAdd(gRaw, int(ni), int(di), int(GiRaw)) + Neurons.SetAdd(*gSyn, int(ni), int(di), int(GiSyn)) case ModulatoryG: *gSyn = ly.Acts.Dt.GeSynFromRaw(*gSyn, gRaw) - Neurons.SetAdd(gRaw, int(ni), int(GModRaw), int(di)) - Neurons.SetAdd(*gSyn, int(ni), int(GModSyn), int(di)) + Neurons.SetAdd(gRaw, int(ni), int(di), int(GModRaw)) + Neurons.SetAdd(*gSyn, int(ni), int(di), int(GModSyn)) case MaintG: *gSyn = ly.Acts.Dt.GeSynFromRaw(*gSyn, gRaw) - Neurons.SetAdd(gRaw, int(ni), int(GMaintRaw), int(di)) + Neurons.SetAdd(gRaw, int(ni), int(di), int(GMaintRaw)) // note: Syn happens via NMDA in Act case ContextG: - Neurons.SetAdd(gRaw, int(ni), int(CtxtGeRaw), int(di)) + Neurons.SetAdd(gRaw, int(ni), int(di), int(CtxtGeRaw)) default: } } @@ -281,9 +281,9 @@ func (pt *PathParams) SendSpike(ctx *Context, ni, di, lni uint32) { if uint32(ctx.Cycle) != uint32(ctx.ThetaCycles)-1-pt.Com.DelLen { return } - sendVal *= Neurons.Value(int(ni), int(Burst), int(di)) // Burst is regular CaSpkP for all non-SuperLayer neurons + sendVal *= Neurons.Value(int(ni), int(di), int(Burst)) // Burst is regular CaSpkP for all non-SuperLayer neurons } else { - if Neurons.Value(int(ni), int(Spike), int(di)) == 0 { + if Neurons.Value(int(ni), int(di), int(Spike)) == 0 { return } } diff --git a/axon/act-path.goal b/axon/act-path.goal index abdec7e3..15c02669 100644 --- a/axon/act-path.goal +++ b/axon/act-path.goal @@ -249,22 +249,22 @@ func (pt *PathParams) GatherSpikesGSyn(ctx *Context, ly *LayerParams, ni, di uin switch pt.Com.GType { case ExcitatoryG: *gSyn = ly.Acts.Dt.GeSynFromRaw(*gSyn, gRaw) - Neurons[ni, GeRaw, di] += gRaw - Neurons[ni, GeSyn, di] += *gSyn + Neurons[ni, di, GeRaw] += gRaw + Neurons[ni, di, GeSyn] += *gSyn case InhibitoryG: *gSyn = ly.Acts.Dt.GiSynFromRaw(*gSyn, gRaw) - Neurons[ni, GiRaw, di] += gRaw - Neurons[ni, GiSyn, di] += *gSyn + Neurons[ni, di, GiRaw] += gRaw + Neurons[ni, di, GiSyn] += *gSyn case ModulatoryG: *gSyn = ly.Acts.Dt.GeSynFromRaw(*gSyn, gRaw) - Neurons[ni, GModRaw, di] += gRaw - Neurons[ni, GModSyn, di] += *gSyn + Neurons[ni, di, GModRaw] += gRaw + Neurons[ni, di, GModSyn] += *gSyn case MaintG: *gSyn = ly.Acts.Dt.GeSynFromRaw(*gSyn, gRaw) - Neurons[ni, GMaintRaw, di] += gRaw + Neurons[ni, di, GMaintRaw] += gRaw // note: Syn happens via NMDA in Act case ContextG: - Neurons[ni, CtxtGeRaw, di] += gRaw + Neurons[ni, di, CtxtGeRaw] += gRaw default: } } @@ -279,9 +279,9 @@ func (pt *PathParams) SendSpike(ctx *Context, ni, di, lni uint32) { if uint32(ctx.Cycle) != uint32(ctx.ThetaCycles)-1-pt.Com.DelLen { return } - sendVal *= Neurons[ni, Burst, di] // Burst is regular CaSpkP for all non-SuperLayer neurons + sendVal *= Neurons[ni, di, Burst] // Burst is regular CaSpkP for all non-SuperLayer neurons } else { - if Neurons[ni, Spike, di] == 0 { + if Neurons[ni, di, Spike] == 0 { return } } diff --git a/axon/act.go b/axon/act.go index f6ed1209..cb92bc11 100644 --- a/axon/act.go +++ b/axon/act.go @@ -25,15 +25,15 @@ import ( // NeuronHasFlag func NeuronHasFlag(flag NeuronFlags, ni, di uint32) bool { - return (NeuronFlags(math.Float32bits(Neurons.Value(int(ni), int(NeurFlags), int(di)))) & flag) > 0 // weird: != 0 does NOT work on GPU + return (NeuronFlags(math.Float32bits(Neurons.Value(int(ni), int(di), int(NeurFlags)))) & flag) > 0 // weird: != 0 does NOT work on GPU } func NeuronSetFlag(flag NeuronFlags, ni, di uint32) { - Neurons.Set(math.Float32frombits(math.Float32bits(Neurons.Value(int(ni), int(NeurFlags), int(di)))|uint32(flag)), int(ni), int(NeurFlags), int(di)) + Neurons.Set(math.Float32frombits(math.Float32bits(Neurons.Value(int(ni), int(di), int(NeurFlags)))|uint32(flag)), int(ni), int(di), int(NeurFlags)) } func NeuronClearFlag(flag NeuronFlags, ni, di uint32) { - Neurons.Set(math.Float32frombits(math.Float32bits(Neurons.Value(int(ni), int(NeurFlags), int(di)))&^uint32(flag)), int(ni), int(NeurFlags), int(di)) + Neurons.Set(math.Float32frombits(math.Float32bits(Neurons.Value(int(ni), int(di), int(NeurFlags)))&^uint32(flag)), int(ni), int(di), int(NeurFlags)) } // NeuronIsOff returns true if the neuron has been turned off (lesioned) @@ -847,41 +847,41 @@ func (ac *ActParams) Update() { // of the decay parameter that then has impacts on learning rates etc. // see Act.Decay.LearnCa param controlling this func (ac *ActParams) DecayLearnCa(ctx *Context, ni, di uint32, decay float32) { - Neurons.SetSub(decay*Neurons.Value(int(ni), int(GnmdaLrn), int(di)), int(ni), int(GnmdaLrn), int(di)) - Neurons.SetSub(decay*Neurons.Value(int(ni), int(NmdaCa), int(di)), int(ni), int(NmdaCa), int(di)) + Neurons.SetSub(decay*Neurons.Value(int(ni), int(di), int(GnmdaLrn)), int(ni), int(di), int(GnmdaLrn)) + Neurons.SetSub(decay*Neurons.Value(int(ni), int(di), int(NmdaCa)), int(ni), int(di), int(NmdaCa)) - Neurons.SetSub(decay*Neurons.Value(int(ni), int(VgccCa), int(di)), int(ni), int(VgccCa), int(di)) - Neurons.SetSub(decay*Neurons.Value(int(ni), int(VgccCaInt), int(di)), int(ni), int(VgccCaInt), int(di)) + Neurons.SetSub(decay*Neurons.Value(int(ni), int(di), int(VgccCa)), int(ni), int(di), int(VgccCa)) + Neurons.SetSub(decay*Neurons.Value(int(ni), int(di), int(VgccCaInt)), int(ni), int(di), int(VgccCaInt)) - Neurons.SetSub(decay*Neurons.Value(int(ni), int(CaLrn), int(di)), int(ni), int(CaLrn), int(di)) + Neurons.SetSub(decay*Neurons.Value(int(ni), int(di), int(CaLrn)), int(ni), int(di), int(CaLrn)) - Neurons.SetSub(decay*Neurons.Value(int(ni), int(CaSpkM), int(di)), int(ni), int(CaSpkM), int(di)) - Neurons.SetSub(decay*Neurons.Value(int(ni), int(CaSpkP), int(di)), int(ni), int(CaSpkP), int(di)) - Neurons.SetSub(decay*Neurons.Value(int(ni), int(CaSpkD), int(di)), int(ni), int(CaSpkD), int(di)) + Neurons.SetSub(decay*Neurons.Value(int(ni), int(di), int(CaSpkM)), int(ni), int(di), int(CaSpkM)) + Neurons.SetSub(decay*Neurons.Value(int(ni), int(di), int(CaSpkP)), int(ni), int(di), int(CaSpkP)) + Neurons.SetSub(decay*Neurons.Value(int(ni), int(di), int(CaSpkD)), int(ni), int(di), int(CaSpkD)) - Neurons.SetSub(decay*Neurons.Value(int(ni), int(NrnCaM), int(di)), int(ni), int(NrnCaM), int(di)) - Neurons.SetSub(decay*Neurons.Value(int(ni), int(NrnCaP), int(di)), int(ni), int(NrnCaP), int(di)) - Neurons.SetSub(decay*Neurons.Value(int(ni), int(NrnCaD), int(di)), int(ni), int(NrnCaD), int(di)) + Neurons.SetSub(decay*Neurons.Value(int(ni), int(di), int(NrnCaM)), int(ni), int(di), int(NrnCaM)) + Neurons.SetSub(decay*Neurons.Value(int(ni), int(di), int(NrnCaP)), int(ni), int(di), int(NrnCaP)) + Neurons.SetSub(decay*Neurons.Value(int(ni), int(di), int(NrnCaD)), int(ni), int(di), int(NrnCaD)) // recovers - Neurons.SetAdd(decay*(1.0-Neurons.Value(int(ni), int(SKCaIn), int(di))), int(ni), int(SKCaIn), int(di)) - Neurons.SetSub(decay*Neurons.Value(int(ni), int(SKCaR), int(di)), int(ni), int(SKCaR), int(di)) - Neurons.SetSub(decay*Neurons.Value(int(ni), int(SKCaM), int(di)), int(ni), int(SKCaM), int(di)) + Neurons.SetAdd(decay*(1.0-Neurons.Value(int(ni), int(di), int(SKCaIn))), int(ni), int(di), int(SKCaIn)) + Neurons.SetSub(decay*Neurons.Value(int(ni), int(di), int(SKCaR)), int(ni), int(di), int(SKCaR)) + Neurons.SetSub(decay*Neurons.Value(int(ni), int(di), int(SKCaM)), int(ni), int(di), int(SKCaM)) } // DecayAHP decays after-hyperpolarization variables // by given factor (typically Decay.AHP) func (ac *ActParams) DecayAHP(ctx *Context, ni, di uint32, decay float32) { - Neurons.SetSub(decay*Neurons.Value(int(ni), int(MahpN), int(di)), int(ni), int(MahpN), int(di)) - Neurons.SetSub(decay*Neurons.Value(int(ni), int(Gmahp), int(di)), int(ni), int(Gmahp), int(di)) - Neurons.SetSub(decay*Neurons.Value(int(ni), int(SahpCa), int(di)), int(ni), int(SahpCa), int(di)) - Neurons.SetSub(decay*Neurons.Value(int(ni), int(SahpN), int(di)), int(ni), int(SahpN), int(di)) - Neurons.SetSub(decay*Neurons.Value(int(ni), int(Gsahp), int(di)), int(ni), int(Gsahp), int(di)) - Neurons.SetSub(decay*Neurons.Value(int(ni), int(GknaMed), int(di)), int(ni), int(GknaMed), int(di)) - Neurons.SetSub(decay*Neurons.Value(int(ni), int(GknaSlow), int(di)), int(ni), int(GknaSlow), int(di)) + Neurons.SetSub(decay*Neurons.Value(int(ni), int(di), int(MahpN)), int(ni), int(di), int(MahpN)) + Neurons.SetSub(decay*Neurons.Value(int(ni), int(di), int(Gmahp)), int(ni), int(di), int(Gmahp)) + Neurons.SetSub(decay*Neurons.Value(int(ni), int(di), int(SahpCa)), int(ni), int(di), int(SahpCa)) + Neurons.SetSub(decay*Neurons.Value(int(ni), int(di), int(SahpN)), int(ni), int(di), int(SahpN)) + Neurons.SetSub(decay*Neurons.Value(int(ni), int(di), int(Gsahp)), int(ni), int(di), int(Gsahp)) + Neurons.SetSub(decay*Neurons.Value(int(ni), int(di), int(GknaMed)), int(ni), int(di), int(GknaMed)) + Neurons.SetSub(decay*Neurons.Value(int(ni), int(di), int(GknaSlow)), int(ni), int(di), int(GknaSlow)) kirMrest := ac.Kir.Mrest - Neurons.SetAdd(decay*(kirMrest-Neurons.Value(int(ni), int(KirM), int(di))), int(ni), int(KirM), int(di)) - Neurons.SetSub(decay*Neurons.Value(int(ni), int(Gkir), int(di)), int(ni), int(Gkir), int(di)) + Neurons.SetAdd(decay*(kirMrest-Neurons.Value(int(ni), int(di), int(KirM))), int(ni), int(di), int(KirM)) + Neurons.SetSub(decay*Neurons.Value(int(ni), int(di), int(Gkir)), int(ni), int(di), int(Gkir)) } // DecayState decays the activation state toward initial values @@ -891,156 +891,156 @@ func (ac *ActParams) DecayAHP(ctx *Context, ni, di uint32, decay float32) { // Called with ac.Decay.Act by Layer during NewState func (ac *ActParams) DecayState(ctx *Context, ni, di uint32, decay, glong, ahp float32) { // always reset these -- otherwise get insanely large values that take forever to update - Neurons.Set(-1.0, int(ni), int(ISIAvg), int(di)) - Neurons.Set(ac.Init.Act, int(ni), int(ActInt), int(di)) - Neurons.Set(0.0, int(ni), int(Spiked), int(di)) + Neurons.Set(-1.0, int(ni), int(di), int(ISIAvg)) + Neurons.Set(ac.Init.Act, int(ni), int(di), int(ActInt)) + Neurons.Set(0.0, int(ni), int(di), int(Spiked)) for i := range 8 { - Neurons.Set(0.0, int(ni), int(SpkBin0+NeuronVars(i)), int(di)) + Neurons.Set(0.0, int(ni), int(di), int(SpkBin0+NeuronVars(i))) } if decay > 0 { // no-op for most, but not all.. - Neurons.Set(0.0, int(ni), int(Spike), int(di)) - Neurons.SetSub(decay*(Neurons.Value(int(ni), int(Act), int(di))-ac.Init.Act), int(ni), int(Act), int(di)) - Neurons.SetSub(decay*(Neurons.Value(int(ni), int(ActInt), int(di))-ac.Init.Act), int(ni), int(ActInt), int(di)) - Neurons.SetSub(decay*(Neurons.Value(int(ni), int(GeSyn), int(di))-NeuronAvgs.Value(int(ni), int(GeBase))), int(ni), int(GeSyn), int(di)) - Neurons.SetSub(decay*(Neurons.Value(int(ni), int(Ge), int(di))-NeuronAvgs.Value(int(ni), int(GeBase))), int(ni), int(Ge), int(di)) - Neurons.SetSub(decay*(Neurons.Value(int(ni), int(Gi), int(di))-NeuronAvgs.Value(int(ni), int(GiBase))), int(ni), int(Gi), int(di)) - Neurons.SetSub(decay*Neurons.Value(int(ni), int(Gk), int(di)), int(ni), int(Gk), int(di)) + Neurons.Set(0.0, int(ni), int(di), int(Spike)) + Neurons.SetSub(decay*(Neurons.Value(int(ni), int(di), int(Act))-ac.Init.Act), int(ni), int(di), int(Act)) + Neurons.SetSub(decay*(Neurons.Value(int(ni), int(di), int(ActInt))-ac.Init.Act), int(ni), int(di), int(ActInt)) + Neurons.SetSub(decay*(Neurons.Value(int(ni), int(di), int(GeSyn))-NeuronAvgs.Value(int(ni), int(GeBase))), int(ni), int(di), int(GeSyn)) + Neurons.SetSub(decay*(Neurons.Value(int(ni), int(di), int(Ge))-NeuronAvgs.Value(int(ni), int(GeBase))), int(ni), int(di), int(Ge)) + Neurons.SetSub(decay*(Neurons.Value(int(ni), int(di), int(Gi))-NeuronAvgs.Value(int(ni), int(GiBase))), int(ni), int(di), int(Gi)) + Neurons.SetSub(decay*Neurons.Value(int(ni), int(di), int(Gk)), int(ni), int(di), int(Gk)) - Neurons.SetSub(decay*(Neurons.Value(int(ni), int(Vm), int(di))-ac.Init.Vm), int(ni), int(Vm), int(di)) + Neurons.SetSub(decay*(Neurons.Value(int(ni), int(di), int(Vm))-ac.Init.Vm), int(ni), int(di), int(Vm)) - Neurons.SetSub(decay*Neurons.Value(int(ni), int(GeNoise), int(di)), int(ni), int(GeNoise), int(di)) - Neurons.SetSub(decay*Neurons.Value(int(ni), int(GiNoise), int(di)), int(ni), int(GiNoise), int(di)) + Neurons.SetSub(decay*Neurons.Value(int(ni), int(di), int(GeNoise)), int(ni), int(di), int(GeNoise)) + Neurons.SetSub(decay*Neurons.Value(int(ni), int(di), int(GiNoise)), int(ni), int(di), int(GiNoise)) - Neurons.SetSub(decay*Neurons.Value(int(ni), int(GiSyn), int(di)), int(ni), int(GiSyn), int(di)) + Neurons.SetSub(decay*Neurons.Value(int(ni), int(di), int(GiSyn)), int(ni), int(di), int(GiSyn)) - Neurons.SetSub(decay*Neurons.Value(int(ni), int(GeInt), int(di)), int(ni), int(GeInt), int(di)) - Neurons.SetSub(decay*Neurons.Value(int(ni), int(GiInt), int(di)), int(ni), int(GiInt), int(di)) - Neurons.SetSub(decay*Neurons.Value(int(ni), int(GeIntNorm), int(di)), int(ni), int(GeIntNorm), int(di)) + Neurons.SetSub(decay*Neurons.Value(int(ni), int(di), int(GeInt)), int(ni), int(di), int(GeInt)) + Neurons.SetSub(decay*Neurons.Value(int(ni), int(di), int(GiInt)), int(ni), int(di), int(GiInt)) + Neurons.SetSub(decay*Neurons.Value(int(ni), int(di), int(GeIntNorm)), int(ni), int(di), int(GeIntNorm)) } - Neurons.SetSub(glong*(Neurons.Value(int(ni), int(VmDend), int(di))-ac.Init.Vm), int(ni), int(VmDend), int(di)) + Neurons.SetSub(glong*(Neurons.Value(int(ni), int(di), int(VmDend))-ac.Init.Vm), int(ni), int(di), int(VmDend)) if ahp > 0 { ac.DecayAHP(ctx, ni, di, ahp) } - Neurons.SetSub(glong*Neurons.Value(int(ni), int(GgabaB), int(di)), int(ni), int(GgabaB), int(di)) - Neurons.SetSub(glong*Neurons.Value(int(ni), int(GABAB), int(di)), int(ni), int(GABAB), int(di)) - Neurons.SetSub(glong*Neurons.Value(int(ni), int(GABABx), int(di)), int(ni), int(GABABx), int(di)) + Neurons.SetSub(glong*Neurons.Value(int(ni), int(di), int(GgabaB)), int(ni), int(di), int(GgabaB)) + Neurons.SetSub(glong*Neurons.Value(int(ni), int(di), int(GABAB)), int(ni), int(di), int(GABAB)) + Neurons.SetSub(glong*Neurons.Value(int(ni), int(di), int(GABABx)), int(ni), int(di), int(GABABx)) - Neurons.SetSub(glong*Neurons.Value(int(ni), int(GnmdaSyn), int(di)), int(ni), int(GnmdaSyn), int(di)) - Neurons.SetSub(glong*Neurons.Value(int(ni), int(Gnmda), int(di)), int(ni), int(Gnmda), int(di)) - Neurons.SetSub(glong*Neurons.Value(int(ni), int(GMaintSyn), int(di)), int(ni), int(GMaintSyn), int(di)) - Neurons.SetSub(glong*Neurons.Value(int(ni), int(GnmdaMaint), int(di)), int(ni), int(GnmdaMaint), int(di)) + Neurons.SetSub(glong*Neurons.Value(int(ni), int(di), int(GnmdaSyn)), int(ni), int(di), int(GnmdaSyn)) + Neurons.SetSub(glong*Neurons.Value(int(ni), int(di), int(Gnmda)), int(ni), int(di), int(Gnmda)) + Neurons.SetSub(glong*Neurons.Value(int(ni), int(di), int(GMaintSyn)), int(ni), int(di), int(GMaintSyn)) + Neurons.SetSub(glong*Neurons.Value(int(ni), int(di), int(GnmdaMaint)), int(ni), int(di), int(GnmdaMaint)) - Neurons.SetSub(glong*Neurons.Value(int(ni), int(Gvgcc), int(di)), int(ni), int(Gvgcc), int(di)) - Neurons.SetSub(glong*Neurons.Value(int(ni), int(VgccM), int(di)), int(ni), int(VgccM), int(di)) - Neurons.SetSub(glong*Neurons.Value(int(ni), int(VgccH), int(di)), int(ni), int(VgccH), int(di)) - Neurons.SetSub(glong*Neurons.Value(int(ni), int(Gak), int(di)), int(ni), int(Gak), int(di)) + Neurons.SetSub(glong*Neurons.Value(int(ni), int(di), int(Gvgcc)), int(ni), int(di), int(Gvgcc)) + Neurons.SetSub(glong*Neurons.Value(int(ni), int(di), int(VgccM)), int(ni), int(di), int(VgccM)) + Neurons.SetSub(glong*Neurons.Value(int(ni), int(di), int(VgccH)), int(ni), int(di), int(VgccH)) + Neurons.SetSub(glong*Neurons.Value(int(ni), int(di), int(Gak)), int(ni), int(di), int(Gak)) // don't mess with SKCa -- longer time scale - Neurons.SetSub(glong*Neurons.Value(int(ni), int(Gsk), int(di)), int(ni), int(Gsk), int(di)) + Neurons.SetSub(glong*Neurons.Value(int(ni), int(di), int(Gsk)), int(ni), int(di), int(Gsk)) if ac.Decay.LearnCa > 0 { // learning-based Ca values -- not usual ac.DecayLearnCa(ctx, ni, di, ac.Decay.LearnCa) } - Neurons.Set(0.0, int(ni), int(Inet), int(di)) - Neurons.Set(0.0, int(ni), int(GeRaw), int(di)) - Neurons.Set(0.0, int(ni), int(GiRaw), int(di)) - Neurons.Set(0.0, int(ni), int(GModRaw), int(di)) - Neurons.Set(0.0, int(ni), int(GModSyn), int(di)) - Neurons.Set(0.0, int(ni), int(GMaintRaw), int(di)) - Neurons.Set(0.0, int(ni), int(SSGiDend), int(di)) - Neurons.Set(0.0, int(ni), int(GeExt), int(di)) + Neurons.Set(0.0, int(ni), int(di), int(Inet)) + Neurons.Set(0.0, int(ni), int(di), int(GeRaw)) + Neurons.Set(0.0, int(ni), int(di), int(GiRaw)) + Neurons.Set(0.0, int(ni), int(di), int(GModRaw)) + Neurons.Set(0.0, int(ni), int(di), int(GModSyn)) + Neurons.Set(0.0, int(ni), int(di), int(GMaintRaw)) + Neurons.Set(0.0, int(ni), int(di), int(SSGiDend)) + Neurons.Set(0.0, int(ni), int(di), int(GeExt)) - Neurons.SetSub(glong*Neurons.Value(int(ni), int(CtxtGeOrig), int(di)), int(ni), int(CtxtGeOrig), int(di)) + Neurons.SetSub(glong*Neurons.Value(int(ni), int(di), int(CtxtGeOrig)), int(ni), int(di), int(CtxtGeOrig)) } // InitActs initializes activation state in neuron -- called during InitWeights but otherwise not // automatically called (DecayState is used instead) func (ac *ActParams) InitActs(ctx *Context, ni, di uint32) { - Neurons.Set(0, int(ni), int(Spike), int(di)) - Neurons.Set(0, int(ni), int(Spiked), int(di)) - Neurons.Set(-1, int(ni), int(ISI), int(di)) - Neurons.Set(-1, int(ni), int(ISIAvg), int(di)) - Neurons.Set(ac.Init.Act, int(ni), int(Act), int(di)) - Neurons.Set(ac.Init.Act, int(ni), int(ActInt), int(di)) - Neurons.Set(NeuronAvgs.Value(int(ni), int(GeBase)), int(ni), int(GeSyn), int(di)) - Neurons.Set(NeuronAvgs.Value(int(ni), int(GeBase)), int(ni), int(Ge), int(di)) - Neurons.Set(NeuronAvgs.Value(int(ni), int(GiBase)), int(ni), int(Gi), int(di)) - Neurons.Set(0, int(ni), int(Gk), int(di)) - Neurons.Set(0, int(ni), int(Inet), int(di)) - Neurons.Set(ac.Init.Vm, int(ni), int(Vm), int(di)) - Neurons.Set(ac.Init.Vm, int(ni), int(VmDend), int(di)) - Neurons.Set(0, int(ni), int(Target), int(di)) - Neurons.Set(0, int(ni), int(Ext), int(di)) - - Neurons.Set(0, int(ni), int(SpkMaxCa), int(di)) - Neurons.Set(0, int(ni), int(SpkMax), int(di)) - Neurons.Set(1, int(ni), int(RLRate), int(di)) - - Neurons.Set(1, int(ni), int(GeNoiseP), int(di)) - Neurons.Set(0, int(ni), int(GeNoise), int(di)) - Neurons.Set(1, int(ni), int(GiNoiseP), int(di)) - Neurons.Set(0, int(ni), int(GiNoise), int(di)) - Neurons.Set(0, int(ni), int(GiSyn), int(di)) - Neurons.Set(1, int(ni), int(SMaintP), int(di)) - - Neurons.Set(0, int(ni), int(GeInt), int(di)) - Neurons.Set(0, int(ni), int(GeIntNorm), int(di)) - Neurons.Set(0, int(ni), int(GiInt), int(di)) - - Neurons.Set(0, int(ni), int(MahpN), int(di)) - Neurons.Set(0, int(ni), int(Gmahp), int(di)) - Neurons.Set(0, int(ni), int(SahpCa), int(di)) - Neurons.Set(0, int(ni), int(SahpN), int(di)) - Neurons.Set(0, int(ni), int(Gsahp), int(di)) - Neurons.Set(0, int(ni), int(GknaMed), int(di)) - Neurons.Set(0, int(ni), int(GknaSlow), int(di)) - Neurons.Set(ac.Kir.Mrest, int(ni), int(KirM), int(di)) - Neurons.Set(0, int(ni), int(Gkir), int(di)) - - Neurons.Set(0, int(ni), int(GnmdaSyn), int(di)) - Neurons.Set(0, int(ni), int(Gnmda), int(di)) - Neurons.Set(0, int(ni), int(GnmdaMaint), int(di)) - Neurons.Set(0, int(ni), int(GnmdaLrn), int(di)) - Neurons.Set(0, int(ni), int(NmdaCa), int(di)) - - Neurons.Set(0, int(ni), int(GgabaB), int(di)) - Neurons.Set(0, int(ni), int(GABAB), int(di)) - Neurons.Set(0, int(ni), int(GABABx), int(di)) - - Neurons.Set(0, int(ni), int(Gvgcc), int(di)) - Neurons.Set(0, int(ni), int(VgccM), int(di)) - Neurons.Set(0, int(ni), int(VgccH), int(di)) - Neurons.Set(0, int(ni), int(Gak), int(di)) - Neurons.Set(0, int(ni), int(VgccCaInt), int(di)) - - Neurons.Set(1, int(ni), int(SKCaIn), int(di)) - Neurons.Set(0, int(ni), int(SKCaR), int(di)) - Neurons.Set(0, int(ni), int(SKCaM), int(di)) - Neurons.Set(0, int(ni), int(Gsk), int(di)) - - Neurons.Set(0, int(ni), int(GeExt), int(di)) - Neurons.Set(0, int(ni), int(GeRaw), int(di)) - Neurons.Set(0, int(ni), int(GiRaw), int(di)) - Neurons.Set(0, int(ni), int(GModRaw), int(di)) - Neurons.Set(0, int(ni), int(GModSyn), int(di)) - Neurons.Set(0, int(ni), int(GMaintRaw), int(di)) - Neurons.Set(0, int(ni), int(GMaintSyn), int(di)) - - Neurons.Set(0, int(ni), int(SSGiDend), int(di)) - - Neurons.Set(0, int(ni), int(Burst), int(di)) - Neurons.Set(0, int(ni), int(BurstPrv), int(di)) - - Neurons.Set(0, int(ni), int(CtxtGe), int(di)) - Neurons.Set(0, int(ni), int(CtxtGeRaw), int(di)) - Neurons.Set(0, int(ni), int(CtxtGeOrig), int(di)) + Neurons.Set(0, int(ni), int(di), int(Spike)) + Neurons.Set(0, int(ni), int(di), int(Spiked)) + Neurons.Set(-1, int(ni), int(di), int(ISI)) + Neurons.Set(-1, int(ni), int(di), int(ISIAvg)) + Neurons.Set(ac.Init.Act, int(ni), int(di), int(Act)) + Neurons.Set(ac.Init.Act, int(ni), int(di), int(ActInt)) + Neurons.Set(NeuronAvgs.Value(int(ni), int(GeBase)), int(ni), int(di), int(GeSyn)) + Neurons.Set(NeuronAvgs.Value(int(ni), int(GeBase)), int(ni), int(di), int(Ge)) + Neurons.Set(NeuronAvgs.Value(int(ni), int(GiBase)), int(ni), int(di), int(Gi)) + Neurons.Set(0, int(ni), int(di), int(Gk)) + Neurons.Set(0, int(ni), int(di), int(Inet)) + Neurons.Set(ac.Init.Vm, int(ni), int(di), int(Vm)) + Neurons.Set(ac.Init.Vm, int(ni), int(di), int(VmDend)) + Neurons.Set(0, int(ni), int(di), int(Target)) + Neurons.Set(0, int(ni), int(di), int(Ext)) + + Neurons.Set(0, int(ni), int(di), int(SpkMaxCa)) + Neurons.Set(0, int(ni), int(di), int(SpkMax)) + Neurons.Set(1, int(ni), int(di), int(RLRate)) + + Neurons.Set(1, int(ni), int(di), int(GeNoiseP)) + Neurons.Set(0, int(ni), int(di), int(GeNoise)) + Neurons.Set(1, int(ni), int(di), int(GiNoiseP)) + Neurons.Set(0, int(ni), int(di), int(GiNoise)) + Neurons.Set(0, int(ni), int(di), int(GiSyn)) + Neurons.Set(1, int(ni), int(di), int(SMaintP)) + + Neurons.Set(0, int(ni), int(di), int(GeInt)) + Neurons.Set(0, int(ni), int(di), int(GeIntNorm)) + Neurons.Set(0, int(ni), int(di), int(GiInt)) + + Neurons.Set(0, int(ni), int(di), int(MahpN)) + Neurons.Set(0, int(ni), int(di), int(Gmahp)) + Neurons.Set(0, int(ni), int(di), int(SahpCa)) + Neurons.Set(0, int(ni), int(di), int(SahpN)) + Neurons.Set(0, int(ni), int(di), int(Gsahp)) + Neurons.Set(0, int(ni), int(di), int(GknaMed)) + Neurons.Set(0, int(ni), int(di), int(GknaSlow)) + Neurons.Set(ac.Kir.Mrest, int(ni), int(di), int(KirM)) + Neurons.Set(0, int(ni), int(di), int(Gkir)) + + Neurons.Set(0, int(ni), int(di), int(GnmdaSyn)) + Neurons.Set(0, int(ni), int(di), int(Gnmda)) + Neurons.Set(0, int(ni), int(di), int(GnmdaMaint)) + Neurons.Set(0, int(ni), int(di), int(GnmdaLrn)) + Neurons.Set(0, int(ni), int(di), int(NmdaCa)) + + Neurons.Set(0, int(ni), int(di), int(GgabaB)) + Neurons.Set(0, int(ni), int(di), int(GABAB)) + Neurons.Set(0, int(ni), int(di), int(GABABx)) + + Neurons.Set(0, int(ni), int(di), int(Gvgcc)) + Neurons.Set(0, int(ni), int(di), int(VgccM)) + Neurons.Set(0, int(ni), int(di), int(VgccH)) + Neurons.Set(0, int(ni), int(di), int(Gak)) + Neurons.Set(0, int(ni), int(di), int(VgccCaInt)) + + Neurons.Set(1, int(ni), int(di), int(SKCaIn)) + Neurons.Set(0, int(ni), int(di), int(SKCaR)) + Neurons.Set(0, int(ni), int(di), int(SKCaM)) + Neurons.Set(0, int(ni), int(di), int(Gsk)) + + Neurons.Set(0, int(ni), int(di), int(GeExt)) + Neurons.Set(0, int(ni), int(di), int(GeRaw)) + Neurons.Set(0, int(ni), int(di), int(GiRaw)) + Neurons.Set(0, int(ni), int(di), int(GModRaw)) + Neurons.Set(0, int(ni), int(di), int(GModSyn)) + Neurons.Set(0, int(ni), int(di), int(GMaintRaw)) + Neurons.Set(0, int(ni), int(di), int(GMaintSyn)) + + Neurons.Set(0, int(ni), int(di), int(SSGiDend)) + + Neurons.Set(0, int(ni), int(di), int(Burst)) + Neurons.Set(0, int(ni), int(di), int(BurstPrv)) + + Neurons.Set(0, int(ni), int(di), int(CtxtGe)) + Neurons.Set(0, int(ni), int(di), int(CtxtGeRaw)) + Neurons.Set(0, int(ni), int(di), int(CtxtGeOrig)) for i := range 8 { - Neurons.Set(0.0, int(ni), int(SpkBin0+NeuronVars(i)), int(di)) + Neurons.Set(0.0, int(ni), int(di), int(SpkBin0+NeuronVars(i))) } ac.InitLongActs(ctx, ni, di) @@ -1052,11 +1052,11 @@ func (ac *ActParams) InitActs(ctx *Context, ni, di uint32) { // but otherwise not automatically called // (DecayState is used instead) func (ac *ActParams) InitLongActs(ctx *Context, ni, di uint32) { - Neurons.Set(0, int(ni), int(SpkPrv), int(di)) - Neurons.Set(0, int(ni), int(SpkSt1), int(di)) - Neurons.Set(0, int(ni), int(SpkSt2), int(di)) - Neurons.Set(0, int(ni), int(ActM), int(di)) - Neurons.Set(0, int(ni), int(ActP), int(di)) + Neurons.Set(0, int(ni), int(di), int(SpkPrv)) + Neurons.Set(0, int(ni), int(di), int(SpkSt1)) + Neurons.Set(0, int(ni), int(di), int(SpkSt2)) + Neurons.Set(0, int(ni), int(di), int(ActM)) + Neurons.Set(0, int(ni), int(di), int(ActP)) } //////// Cycle @@ -1068,8 +1068,8 @@ func (ac *ActParams) NMDAFromRaw(ctx *Context, ni, di uint32, geTot float32) { return } geT := max(geTot, 0.0) - Neurons.Set(ac.NMDA.NMDASyn(Neurons.Value(int(ni), int(GnmdaSyn), int(di)), geT), int(ni), int(GnmdaSyn), int(di)) - Neurons.Set(ac.NMDA.Gnmda(Neurons.Value(int(ni), int(GnmdaSyn), int(di)), Neurons.Value(int(ni), int(VmDend), int(di))), int(ni), int(Gnmda), int(di)) + Neurons.Set(ac.NMDA.NMDASyn(Neurons.Value(int(ni), int(di), int(GnmdaSyn)), geT), int(ni), int(di), int(GnmdaSyn)) + Neurons.Set(ac.NMDA.Gnmda(Neurons.Value(int(ni), int(di), int(GnmdaSyn)), Neurons.Value(int(ni), int(di), int(VmDend))), int(ni), int(di), int(Gnmda)) // note: nrn.NmdaCa computed via Learn.LrnNMDA in learn.go, CaM method } @@ -1082,26 +1082,26 @@ func (ac *ActParams) MaintNMDAFromRaw(ctx *Context, ni, di uint32) { if ac.SMaint.On.IsTrue() { ac.SMaintFromISI(ctx, ni, di) } - Neurons.Set(ac.MaintNMDA.NMDASyn(Neurons.Value(int(ni), int(GMaintSyn), int(di)), Neurons.Value(int(ni), int(GMaintRaw), int(di))), int(ni), int(GMaintSyn), int(di)) - Neurons.Set(ac.MaintNMDA.Gnmda(Neurons.Value(int(ni), int(GMaintSyn), int(di)), Neurons.Value(int(ni), int(VmDend), int(di))), int(ni), int(GnmdaMaint), int(di)) + Neurons.Set(ac.MaintNMDA.NMDASyn(Neurons.Value(int(ni), int(di), int(GMaintSyn)), Neurons.Value(int(ni), int(di), int(GMaintRaw))), int(ni), int(di), int(GMaintSyn)) + Neurons.Set(ac.MaintNMDA.Gnmda(Neurons.Value(int(ni), int(di), int(GMaintSyn)), Neurons.Value(int(ni), int(di), int(VmDend))), int(ni), int(di), int(GnmdaMaint)) } // SMaintFromISI updates the SMaint self-maintenance current into GMaintRaw func (ac *ActParams) SMaintFromISI(ctx *Context, ni, di uint32) { nix := GetNetworkIxs(0) - isi := Neurons.Value(int(ni), int(ISIAvg), int(di)) + isi := Neurons.Value(int(ni), int(di), int(ISIAvg)) if isi < ac.SMaint.ISI.Min || isi > ac.SMaint.ISI.Max { return } ndi := di*nix.NNeurons + ni - smp := Neurons.Value(int(ni), int(SMaintP), int(di)) + smp := Neurons.Value(int(ni), int(di), int(SMaintP)) smp *= GetRandomNumber(ndi, ctx.RandCounter.Counter, RandFunActSMaintP) trg := ac.SMaint.ExpInt(isi) if smp <= trg { smp = 1 - Neurons.SetAdd(ac.SMaint.Gbar, int(ni), int(GMaintRaw), int(di)) + Neurons.SetAdd(ac.SMaint.Gbar, int(ni), int(di), int(GMaintRaw)) } - Neurons.Set(smp, int(ni), int(SMaintP), int(di)) + Neurons.Set(smp, int(ni), int(di), int(SMaintP)) } // GvgccFromVm updates all the VGCC voltage-gated calcium channel variables @@ -1110,53 +1110,53 @@ func (ac *ActParams) GvgccFromVm(ctx *Context, ni, di uint32) { if ac.VGCC.Gbar == 0 { return } - Neurons.Set(ac.VGCC.Gvgcc(Neurons.Value(int(ni), int(VmDend), int(di)), Neurons.Value(int(ni), int(VgccM), int(di)), Neurons.Value(int(ni), int(VgccH), int(di))), int(ni), int(Gvgcc), int(di)) + Neurons.Set(ac.VGCC.Gvgcc(Neurons.Value(int(ni), int(di), int(VmDend)), Neurons.Value(int(ni), int(di), int(VgccM)), Neurons.Value(int(ni), int(di), int(VgccH))), int(ni), int(di), int(Gvgcc)) var dm, dh float32 - ac.VGCC.DMHFromV(Neurons.Value(int(ni), int(VmDend), int(di)), Neurons.Value(int(ni), int(VgccM), int(di)), Neurons.Value(int(ni), int(VgccH), int(di)), &dm, &dh) - Neurons.SetAdd(dm, int(ni), int(VgccM), int(di)) - Neurons.SetAdd(dh, int(ni), int(VgccH), int(di)) + ac.VGCC.DMHFromV(Neurons.Value(int(ni), int(di), int(VmDend)), Neurons.Value(int(ni), int(di), int(VgccM)), Neurons.Value(int(ni), int(di), int(VgccH)), &dm, &dh) + Neurons.SetAdd(dm, int(ni), int(di), int(VgccM)) + Neurons.SetAdd(dh, int(ni), int(di), int(VgccH)) // note: may be overwritten! - Neurons.Set(ac.VGCC.CaFromG(Neurons.Value(int(ni), int(VmDend), int(di)), Neurons.Value(int(ni), int(Gvgcc), int(di)), Neurons.Value(int(ni), int(VgccCa), int(di))), int(ni), int(VgccCa), int(di)) + Neurons.Set(ac.VGCC.CaFromG(Neurons.Value(int(ni), int(di), int(VmDend)), Neurons.Value(int(ni), int(di), int(Gvgcc)), Neurons.Value(int(ni), int(di), int(VgccCa))), int(ni), int(di), int(VgccCa)) } // GkFromVm updates all the Gk-based conductances: Mahp, KNa, Gak func (ac *ActParams) GkFromVm(ctx *Context, ni, di uint32) { - vm := Neurons.Value(int(ni), int(Vm), int(di)) - vmd := Neurons.Value(int(ni), int(VmDend), int(di)) - mahpN := Neurons.Value(int(ni), int(MahpN), int(di)) + vm := Neurons.Value(int(ni), int(di), int(Vm)) + vmd := Neurons.Value(int(ni), int(di), int(VmDend)) + mahpN := Neurons.Value(int(ni), int(di), int(MahpN)) gmahp := ac.Mahp.GmAHP(vm, &mahpN) - Neurons.Set(gmahp, int(ni), int(Gmahp), int(di)) - Neurons.Set(mahpN, int(ni), int(MahpN), int(di)) + Neurons.Set(gmahp, int(ni), int(di), int(Gmahp)) + Neurons.Set(mahpN, int(ni), int(di), int(MahpN)) - gsahp := Neurons.Value(int(ni), int(Gsahp), int(di)) + gsahp := Neurons.Value(int(ni), int(di), int(Gsahp)) gak := ac.AK.Gak(vmd) - Neurons.Set(gak, int(ni), int(Gak), int(di)) + Neurons.Set(gak, int(ni), int(di), int(Gak)) - nkirM := Neurons.Value(int(ni), int(KirM), int(di)) + nkirM := Neurons.Value(int(ni), int(di), int(KirM)) gkir := ac.Kir.Gkir(vm, nkirM) - Neurons.Set(gkir, int(ni), int(Gkir), int(di)) + Neurons.Set(gkir, int(ni), int(di), int(Gkir)) nkirM += ac.Kir.DM(chans.VToBio(vm), nkirM) - Neurons.Set(nkirM, int(ni), int(KirM), int(di)) + Neurons.Set(nkirM, int(ni), int(di), int(KirM)) gktot := gmahp + gsahp + gak + gkir if ac.KNa.On.IsTrue() { - gknaMed := Neurons.Value(int(ni), int(GknaMed), int(di)) - gknaSlow := Neurons.Value(int(ni), int(GknaSlow), int(di)) - ac.KNa.GcFromSpike(&gknaMed, &gknaSlow, Neurons.Value(int(ni), int(Spike), int(di)) > .5) - Neurons.Set(gknaMed, int(ni), int(GknaMed), int(di)) - Neurons.Set(gknaSlow, int(ni), int(GknaSlow), int(di)) + gknaMed := Neurons.Value(int(ni), int(di), int(GknaMed)) + gknaSlow := Neurons.Value(int(ni), int(di), int(GknaSlow)) + ac.KNa.GcFromSpike(&gknaMed, &gknaSlow, Neurons.Value(int(ni), int(di), int(Spike)) > .5) + Neurons.Set(gknaMed, int(ni), int(di), int(GknaMed)) + Neurons.Set(gknaSlow, int(ni), int(di), int(GknaSlow)) gktot += gknaMed + gknaSlow } - Neurons.Set(gktot, int(ni), int(Gk), int(di)) + Neurons.Set(gktot, int(ni), int(di), int(Gk)) } // KNaNewState does TrialSlow version of KNa during NewState if option is set func (ac *ActParams) KNaNewState(ctx *Context, ni, di uint32) { if ac.KNa.On.IsTrue() && ac.KNa.TrialSlow.IsTrue() { - Neurons.SetAdd(ac.KNa.Slow.Max*Neurons.Value(int(ni), int(SpkPrv), int(di)), int(ni), int(GknaSlow), int(di)) + Neurons.SetAdd(ac.KNa.Slow.Max*Neurons.Value(int(ni), int(di), int(SpkPrv)), int(ni), int(di), int(GknaSlow)) } } @@ -1165,36 +1165,36 @@ func (ac *ActParams) GSkCaFromCa(ctx *Context, ni, di uint32) { if ac.SKCa.Gbar == 0 { return } - skcar := Neurons.Value(int(ni), int(SKCaR), int(di)) - skcain := Neurons.Value(int(ni), int(SKCaIn), int(di)) - Neurons.Set(ac.SKCa.MFromCa(skcar, Neurons.Value(int(ni), int(SKCaM), int(di))), int(ni), int(SKCaM), int(di)) - ac.SKCa.CaInRFromSpike(Neurons.Value(int(ni), int(Spike), int(di)), Neurons.Value(int(ni), int(CaSpkD), int(di)), &skcain, &skcar) - Neurons.Set(skcar, int(ni), int(SKCaR), int(di)) - Neurons.Set(skcain, int(ni), int(SKCaIn), int(di)) - Neurons.Set(ac.SKCa.Gbar*Neurons.Value(int(ni), int(SKCaM), int(di)), int(ni), int(Gsk), int(di)) - Neurons.SetAdd(Neurons.Value(int(ni), int(Gsk), int(di)), int(ni), int(Gk), int(di)) + skcar := Neurons.Value(int(ni), int(di), int(SKCaR)) + skcain := Neurons.Value(int(ni), int(di), int(SKCaIn)) + Neurons.Set(ac.SKCa.MFromCa(skcar, Neurons.Value(int(ni), int(di), int(SKCaM))), int(ni), int(di), int(SKCaM)) + ac.SKCa.CaInRFromSpike(Neurons.Value(int(ni), int(di), int(Spike)), Neurons.Value(int(ni), int(di), int(CaSpkD)), &skcain, &skcar) + Neurons.Set(skcar, int(ni), int(di), int(SKCaR)) + Neurons.Set(skcain, int(ni), int(di), int(SKCaIn)) + Neurons.Set(ac.SKCa.Gbar*Neurons.Value(int(ni), int(di), int(SKCaM)), int(ni), int(di), int(Gsk)) + Neurons.SetAdd(Neurons.Value(int(ni), int(di), int(Gsk)), int(ni), int(di), int(Gk)) } // GeFromSyn integrates Ge excitatory conductance from GeSyn. // geExt is extra conductance to add to the final Ge value func (ac *ActParams) GeFromSyn(ctx *Context, ni, di uint32, geSyn, geExt float32) { - Neurons.Set(0.0, int(ni), int(GeExt), int(di)) + Neurons.Set(0.0, int(ni), int(di), int(GeExt)) geS := geSyn geE := geExt if ac.Clamp.Add.IsTrue() && NeuronHasFlag(NeuronHasExt, ni, di) { - Neurons.Set(Neurons.Value(int(ni), int(Ext), int(di))*ac.Clamp.Ge, int(ni), int(GeExt), int(di)) - geS += Neurons.Value(int(ni), int(GeExt), int(di)) + Neurons.Set(Neurons.Value(int(ni), int(di), int(Ext))*ac.Clamp.Ge, int(ni), int(di), int(GeExt)) + geS += Neurons.Value(int(ni), int(di), int(GeExt)) } if ac.Clamp.Add.IsFalse() && NeuronHasFlag(NeuronHasExt, ni, di) { - geS = Neurons.Value(int(ni), int(Ext), int(di)) * ac.Clamp.Ge - Neurons.Set(geS, int(ni), int(GeExt), int(di)) + geS = Neurons.Value(int(ni), int(di), int(Ext)) * ac.Clamp.Ge + Neurons.Set(geS, int(ni), int(di), int(GeExt)) geE = 0 // no extra in this case } - Neurons.Set(geS+geE, int(ni), int(Ge), int(di)) - if Neurons.Value(int(ni), int(Ge), int(di)) < 0.0 { - Neurons.Set(0.0, int(ni), int(Ge), int(di)) + Neurons.Set(geS+geE, int(ni), int(di), int(Ge)) + if Neurons.Value(int(ni), int(di), int(Ge)) < 0.0 { + Neurons.Set(0.0, int(ni), int(di), int(Ge)) } ac.AddGeNoise(ctx, ni, di) } @@ -1204,11 +1204,11 @@ func (ac *ActParams) AddGeNoise(ctx *Context, ni, di uint32) { if ac.Noise.On.IsFalse() || ac.Noise.Ge == 0 { return } - p := Neurons.Value(int(ni), int(GeNoiseP), int(di)) + p := Neurons.Value(int(ni), int(di), int(GeNoiseP)) ge := ac.Noise.PGe(ctx, &p, ni, di) - Neurons.Set(p, int(ni), int(GeNoiseP), int(di)) - Neurons.Set(ac.Dt.GeSynFromRaw(Neurons.Value(int(ni), int(GeNoise), int(di)), ge), int(ni), int(GeNoise), int(di)) - Neurons.SetAdd(Neurons.Value(int(ni), int(GeNoise), int(di)), int(ni), int(Ge), int(di)) + Neurons.Set(p, int(ni), int(di), int(GeNoiseP)) + Neurons.Set(ac.Dt.GeSynFromRaw(Neurons.Value(int(ni), int(di), int(GeNoise)), ge), int(ni), int(di), int(GeNoise)) + Neurons.SetAdd(Neurons.Value(int(ni), int(di), int(GeNoise)), int(ni), int(di), int(Ge)) } // AddGiNoise updates nrn.GiNoise if active @@ -1216,10 +1216,10 @@ func (ac *ActParams) AddGiNoise(ctx *Context, ni, di uint32) { if ac.Noise.On.IsFalse() || ac.Noise.Gi == 0 { return } - p := Neurons.Value(int(ni), int(GiNoiseP), int(di)) + p := Neurons.Value(int(ni), int(di), int(GiNoiseP)) gi := ac.Noise.PGi(ctx, &p, ni, di) - Neurons.Set(p, int(ni), int(GiNoiseP), int(di)) - Neurons.Set(ac.Dt.GiSynFromRaw(Neurons.Value(int(ni), int(GiNoise), int(di)), gi), int(ni), int(GiNoise), int(di)) + Neurons.Set(p, int(ni), int(di), int(GiNoiseP)) + Neurons.Set(ac.Dt.GiSynFromRaw(Neurons.Value(int(ni), int(di), int(GiNoise)), gi), int(ni), int(di), int(GiNoise)) } // GiFromSyn integrates GiSyn inhibitory synaptic conductance from GiRaw value @@ -1264,20 +1264,20 @@ func (ac *ActParams) VmFromG(ctx *Context, ni, di uint32) { updtVm := true // note: nrn.ISI has NOT yet been updated at this point: 0 right after spike, etc // so it takes a full 3 time steps after spiking for Tr period - isi := Neurons.Value(int(ni), int(ISI), int(di)) + isi := Neurons.Value(int(ni), int(di), int(ISI)) if ac.Spikes.Tr > 0 && isi >= 0 && isi < float32(ac.Spikes.Tr) { updtVm = false // don't update the spiking vm during refract } - ge := Neurons.Value(int(ni), int(Ge), int(di)) * ac.Gbar.E - gi := Neurons.Value(int(ni), int(Gi), int(di)) * ac.Gbar.I - gk := Neurons.Value(int(ni), int(Gk), int(di)) * ac.Gbar.K + ge := Neurons.Value(int(ni), int(di), int(Ge)) * ac.Gbar.E + gi := Neurons.Value(int(ni), int(di), int(Gi)) * ac.Gbar.I + gk := Neurons.Value(int(ni), int(di), int(Gk)) * ac.Gbar.K var nvm, inet, expi float32 if updtVm { - ac.VmInteg(Neurons.Value(int(ni), int(Vm), int(di)), ac.Dt.VmDt, ge, 1, gi, gk, &nvm, &inet) + ac.VmInteg(Neurons.Value(int(ni), int(di), int(Vm)), ac.Dt.VmDt, ge, 1, gi, gk, &nvm, &inet) if updtVm && ac.Spikes.Exp.IsTrue() { // add spike current if relevant var exVm float32 - exVm = 0.5 * (nvm + Neurons.Value(int(ni), int(Vm), int(di))) // midpoint for this + exVm = 0.5 * (nvm + Neurons.Value(int(ni), int(di), int(Vm))) // midpoint for this expi = ac.Gbar.L * ac.Spikes.ExpSlope * math32.FastExp((exVm-ac.Spikes.Thr)/ac.Spikes.ExpSlope) if expi > ac.Dt.VmTau { @@ -1286,17 +1286,17 @@ func (ac *ActParams) VmFromG(ctx *Context, ni, di uint32) { inet += expi nvm = ac.VmFromInet(nvm, ac.Dt.VmDt, expi) } - Neurons.Set(nvm, int(ni), int(Vm), int(di)) - Neurons.Set(inet, int(ni), int(Inet), int(di)) + Neurons.Set(nvm, int(ni), int(di), int(Vm)) + Neurons.Set(inet, int(ni), int(di), int(Inet)) } else { // decay back to VmR var dvm float32 if int32(isi) == ac.Spikes.Tr-1 { - dvm = ac.Spikes.VmR - Neurons.Value(int(ni), int(Vm), int(di)) + dvm = ac.Spikes.VmR - Neurons.Value(int(ni), int(di), int(Vm)) } else { - dvm = ac.Spikes.RDt * (ac.Spikes.VmR - Neurons.Value(int(ni), int(Vm), int(di))) + dvm = ac.Spikes.RDt * (ac.Spikes.VmR - Neurons.Value(int(ni), int(di), int(Vm))) } - Neurons.SetAdd(dvm, int(ni), int(Vm), int(di)) - Neurons.Set(dvm*ac.Dt.VmTau, int(ni), int(Inet), int(di)) + Neurons.SetAdd(dvm, int(ni), int(di), int(Vm)) + Neurons.Set(dvm*ac.Dt.VmTau, int(ni), int(di), int(Inet)) } glEff := float32(1) @@ -1304,12 +1304,12 @@ func (ac *ActParams) VmFromG(ctx *Context, ni, di uint32) { glEff += ac.Dend.GbarR } var giEff float32 - giEff = gi + ac.Gbar.I*Neurons.Value(int(ni), int(SSGiDend), int(di)) - ac.VmInteg(Neurons.Value(int(ni), int(VmDend), int(di)), ac.Dt.VmDendDt, ge, glEff, giEff, gk, &nvm, &inet) + giEff = gi + ac.Gbar.I*Neurons.Value(int(ni), int(di), int(SSGiDend)) + ac.VmInteg(Neurons.Value(int(ni), int(di), int(VmDend)), ac.Dt.VmDendDt, ge, glEff, giEff, gk, &nvm, &inet) if updtVm { nvm = ac.VmFromInet(nvm, ac.Dt.VmDendDt, ac.Dend.GbarExp*expi) } - Neurons.Set(nvm, int(ni), int(VmDend), int(di)) + Neurons.Set(nvm, int(ni), int(di), int(VmDend)) } // SpikeFromVmVars computes Spike from Vm and ISI-based activation, using pointers to variables @@ -1360,18 +1360,18 @@ func (ac *ActParams) SpikeFromVmVars(nrnISI, nrnISIAvg, nrnSpike, nrnSpiked, nrn // SpikeFromVm computes Spike from Vm and ISI-based activation func (ac *ActParams) SpikeFromVm(ctx *Context, ni, di uint32) { - nrnISI := Neurons.Value(int(ni), int(ISI), int(di)) - nrnISIAvg := Neurons.Value(int(ni), int(ISIAvg), int(di)) - nrnSpike := Neurons.Value(int(ni), int(Spike), int(di)) - nrnSpiked := Neurons.Value(int(ni), int(Spiked), int(di)) - nrnAct := Neurons.Value(int(ni), int(Act), int(di)) - nrnVm := Neurons.Value(int(ni), int(Vm), int(di)) + nrnISI := Neurons.Value(int(ni), int(di), int(ISI)) + nrnISIAvg := Neurons.Value(int(ni), int(di), int(ISIAvg)) + nrnSpike := Neurons.Value(int(ni), int(di), int(Spike)) + nrnSpiked := Neurons.Value(int(ni), int(di), int(Spiked)) + nrnAct := Neurons.Value(int(ni), int(di), int(Act)) + nrnVm := Neurons.Value(int(ni), int(di), int(Vm)) ac.SpikeFromVmVars(&nrnISI, &nrnISIAvg, &nrnSpike, &nrnSpiked, &nrnAct, nrnVm) - Neurons.Set(nrnISI, int(ni), int(ISI), int(di)) - Neurons.Set(nrnISIAvg, int(ni), int(ISIAvg), int(di)) - Neurons.Set(nrnSpike, int(ni), int(Spike), int(di)) - Neurons.Set(nrnSpiked, int(ni), int(Spiked), int(di)) - Neurons.Set(nrnAct, int(ni), int(Act), int(di)) + Neurons.Set(nrnISI, int(ni), int(di), int(ISI)) + Neurons.Set(nrnISIAvg, int(ni), int(di), int(ISIAvg)) + Neurons.Set(nrnSpike, int(ni), int(di), int(Spike)) + Neurons.Set(nrnSpiked, int(ni), int(di), int(Spiked)) + Neurons.Set(nrnAct, int(ni), int(di), int(Act)) } //gosl:end diff --git a/axon/act.goal b/axon/act.goal index 55efcf4b..193e5afb 100644 --- a/axon/act.goal +++ b/axon/act.goal @@ -23,15 +23,15 @@ import ( // NeuronHasFlag func NeuronHasFlag(flag NeuronFlags, ni, di uint32) bool { - return (NeuronFlags(math.Float32bits(Neurons[ni, NeurFlags, di])) & flag) > 0 // weird: != 0 does NOT work on GPU + return (NeuronFlags(math.Float32bits(Neurons[ni, di, NeurFlags])) & flag) > 0 // weird: != 0 does NOT work on GPU } func NeuronSetFlag(flag NeuronFlags, ni, di uint32) { - Neurons[ni, NeurFlags, di] = math.Float32frombits(math.Float32bits(Neurons[ni, NeurFlags, di]) | uint32(flag)) + Neurons[ni, di, NeurFlags] = math.Float32frombits(math.Float32bits(Neurons[ni, di, NeurFlags]) | uint32(flag)) } func NeuronClearFlag(flag NeuronFlags, ni, di uint32) { - Neurons[ni, NeurFlags, di] = math.Float32frombits(math.Float32bits(Neurons[ni, NeurFlags, di]) &^ uint32(flag)) + Neurons[ni, di, NeurFlags] = math.Float32frombits(math.Float32bits(Neurons[ni, di, NeurFlags]) &^ uint32(flag)) } // NeuronIsOff returns true if the neuron has been turned off (lesioned) @@ -845,41 +845,41 @@ func (ac *ActParams) Update() { // of the decay parameter that then has impacts on learning rates etc. // see Act.Decay.LearnCa param controlling this func (ac *ActParams) DecayLearnCa(ctx *Context, ni, di uint32, decay float32) { - Neurons[ni, GnmdaLrn, di] -= decay * Neurons[ni, GnmdaLrn, di] - Neurons[ni, NmdaCa, di] -= decay * Neurons[ni, NmdaCa, di] + Neurons[ni, di, GnmdaLrn] -= decay * Neurons[ni, di, GnmdaLrn] + Neurons[ni, di, NmdaCa] -= decay * Neurons[ni, di, NmdaCa] - Neurons[ni, VgccCa, di] -= decay * Neurons[ni, VgccCa, di] - Neurons[ni, VgccCaInt, di] -= decay * Neurons[ni, VgccCaInt, di] + Neurons[ni, di, VgccCa] -= decay * Neurons[ni, di, VgccCa] + Neurons[ni, di, VgccCaInt] -= decay * Neurons[ni, di, VgccCaInt] - Neurons[ni, CaLrn, di] -= decay * Neurons[ni, CaLrn, di] + Neurons[ni, di, CaLrn] -= decay * Neurons[ni, di, CaLrn] - Neurons[ni, CaSpkM, di] -= decay * Neurons[ni, CaSpkM, di] - Neurons[ni, CaSpkP, di] -= decay * Neurons[ni, CaSpkP, di] - Neurons[ni, CaSpkD, di] -= decay * Neurons[ni, CaSpkD, di] + Neurons[ni, di, CaSpkM] -= decay * Neurons[ni, di, CaSpkM] + Neurons[ni, di, CaSpkP] -= decay * Neurons[ni, di, CaSpkP] + Neurons[ni, di, CaSpkD] -= decay * Neurons[ni, di, CaSpkD] - Neurons[ni, NrnCaM, di] -= decay * Neurons[ni, NrnCaM, di] - Neurons[ni, NrnCaP, di] -= decay * Neurons[ni, NrnCaP, di] - Neurons[ni, NrnCaD, di] -= decay * Neurons[ni, NrnCaD, di] + Neurons[ni, di, NrnCaM] -= decay * Neurons[ni, di, NrnCaM] + Neurons[ni, di, NrnCaP] -= decay * Neurons[ni, di, NrnCaP] + Neurons[ni, di, NrnCaD] -= decay * Neurons[ni, di, NrnCaD] // recovers - Neurons[ni, SKCaIn, di] += decay * (1.0 - Neurons[ni, SKCaIn, di]) - Neurons[ni, SKCaR, di] -= decay * Neurons[ni, SKCaR, di] - Neurons[ni, SKCaM, di] -= decay * Neurons[ni, SKCaM, di] + Neurons[ni, di, SKCaIn] += decay * (1.0 - Neurons[ni, di, SKCaIn]) + Neurons[ni, di, SKCaR] -= decay * Neurons[ni, di, SKCaR] + Neurons[ni, di, SKCaM] -= decay * Neurons[ni, di, SKCaM] } // DecayAHP decays after-hyperpolarization variables // by given factor (typically Decay.AHP) func (ac *ActParams) DecayAHP(ctx *Context, ni, di uint32, decay float32) { - Neurons[ni, MahpN, di] -= decay * Neurons[ni, MahpN, di] - Neurons[ni, Gmahp, di] -= decay * Neurons[ni, Gmahp, di] - Neurons[ni, SahpCa, di] -= decay * Neurons[ni, SahpCa, di] - Neurons[ni, SahpN, di] -= decay * Neurons[ni, SahpN, di] - Neurons[ni, Gsahp, di] -= decay * Neurons[ni, Gsahp, di] - Neurons[ni, GknaMed, di] -= decay * Neurons[ni, GknaMed, di] - Neurons[ni, GknaSlow, di] -= decay * Neurons[ni, GknaSlow, di] + Neurons[ni, di, MahpN] -= decay * Neurons[ni, di, MahpN] + Neurons[ni, di, Gmahp] -= decay * Neurons[ni, di, Gmahp] + Neurons[ni, di, SahpCa] -= decay * Neurons[ni, di, SahpCa] + Neurons[ni, di, SahpN] -= decay * Neurons[ni, di, SahpN] + Neurons[ni, di, Gsahp] -= decay * Neurons[ni, di, Gsahp] + Neurons[ni, di, GknaMed] -= decay * Neurons[ni, di, GknaMed] + Neurons[ni, di, GknaSlow] -= decay * Neurons[ni, di, GknaSlow] kirMrest := ac.Kir.Mrest - Neurons[ni, KirM, di] += decay * (kirMrest - Neurons[ni, KirM, di]) - Neurons[ni, Gkir, di] -= decay * Neurons[ni, Gkir, di] + Neurons[ni, di, KirM] += decay * (kirMrest - Neurons[ni, di, KirM]) + Neurons[ni, di, Gkir] -= decay * Neurons[ni, di, Gkir] } // DecayState decays the activation state toward initial values @@ -889,156 +889,156 @@ func (ac *ActParams) DecayAHP(ctx *Context, ni, di uint32, decay float32) { // Called with ac.Decay.Act by Layer during NewState func (ac *ActParams) DecayState(ctx *Context, ni, di uint32, decay, glong, ahp float32) { // always reset these -- otherwise get insanely large values that take forever to update - Neurons[ni, ISIAvg, di] = -1.0 - Neurons[ni, ActInt, di] = ac.Init.Act - Neurons[ni, Spiked, di] = 0.0 + Neurons[ni, di, ISIAvg] = -1.0 + Neurons[ni, di, ActInt] = ac.Init.Act + Neurons[ni, di, Spiked] = 0.0 for i := range 8 { - Neurons[ni, SpkBin0+NeuronVars(i), di] = 0.0 + Neurons[ni, di, SpkBin0+NeuronVars(i)] = 0.0 } if decay > 0 { // no-op for most, but not all.. - Neurons[ni, Spike, di] = 0.0 - Neurons[ni, Act, di] -= decay * (Neurons[ni, Act, di] - ac.Init.Act) - Neurons[ni, ActInt, di] -= decay * (Neurons[ni, ActInt, di] - ac.Init.Act) - Neurons[ni, GeSyn, di] -= decay * (Neurons[ni, GeSyn, di] - NeuronAvgs[ni, GeBase]) - Neurons[ni, Ge, di] -= decay * (Neurons[ni, Ge, di] - NeuronAvgs[ni, GeBase]) - Neurons[ni, Gi, di] -= decay * (Neurons[ni, Gi, di] - NeuronAvgs[ni, GiBase]) - Neurons[ni, Gk, di] -= decay * Neurons[ni, Gk, di] + Neurons[ni, di, Spike] = 0.0 + Neurons[ni, di, Act] -= decay * (Neurons[ni, di, Act] - ac.Init.Act) + Neurons[ni, di, ActInt] -= decay * (Neurons[ni, di, ActInt] - ac.Init.Act) + Neurons[ni, di, GeSyn] -= decay * (Neurons[ni, di, GeSyn] - NeuronAvgs[ni, GeBase]) + Neurons[ni, di, Ge] -= decay * (Neurons[ni, di, Ge] - NeuronAvgs[ni, GeBase]) + Neurons[ni, di, Gi] -= decay * (Neurons[ni, di, Gi] - NeuronAvgs[ni, GiBase]) + Neurons[ni, di, Gk] -= decay * Neurons[ni, di, Gk] - Neurons[ni, Vm, di] -= decay * (Neurons[ni, Vm, di] - ac.Init.Vm) + Neurons[ni, di, Vm] -= decay * (Neurons[ni, di, Vm] - ac.Init.Vm) - Neurons[ni, GeNoise, di] -= decay * Neurons[ni, GeNoise, di] - Neurons[ni, GiNoise, di] -= decay * Neurons[ni, GiNoise, di] + Neurons[ni, di, GeNoise] -= decay * Neurons[ni, di, GeNoise] + Neurons[ni, di, GiNoise] -= decay * Neurons[ni, di, GiNoise] - Neurons[ni, GiSyn, di] -= decay * Neurons[ni, GiSyn, di] + Neurons[ni, di, GiSyn] -= decay * Neurons[ni, di, GiSyn] - Neurons[ni, GeInt, di] -= decay * Neurons[ni, GeInt, di] - Neurons[ni, GiInt, di] -= decay * Neurons[ni, GiInt, di] - Neurons[ni, GeIntNorm, di] -= decay * Neurons[ni, GeIntNorm, di] + Neurons[ni, di, GeInt] -= decay * Neurons[ni, di, GeInt] + Neurons[ni, di, GiInt] -= decay * Neurons[ni, di, GiInt] + Neurons[ni, di, GeIntNorm] -= decay * Neurons[ni, di, GeIntNorm] } - Neurons[ni, VmDend, di] -= glong * (Neurons[ni, VmDend, di] - ac.Init.Vm) + Neurons[ni, di, VmDend] -= glong * (Neurons[ni, di, VmDend] - ac.Init.Vm) if ahp > 0 { ac.DecayAHP(ctx, ni, di, ahp) } - Neurons[ni, GgabaB, di] -= glong * Neurons[ni, GgabaB, di] - Neurons[ni, GABAB, di] -= glong * Neurons[ni, GABAB, di] - Neurons[ni, GABABx, di] -= glong * Neurons[ni, GABABx, di] + Neurons[ni, di, GgabaB] -= glong * Neurons[ni, di, GgabaB] + Neurons[ni, di, GABAB] -= glong * Neurons[ni, di, GABAB] + Neurons[ni, di, GABABx] -= glong * Neurons[ni, di, GABABx] - Neurons[ni, GnmdaSyn, di] -= glong * Neurons[ni, GnmdaSyn, di] - Neurons[ni, Gnmda, di] -= glong * Neurons[ni, Gnmda, di] - Neurons[ni, GMaintSyn, di] -= glong * Neurons[ni, GMaintSyn, di] - Neurons[ni, GnmdaMaint, di] -= glong * Neurons[ni, GnmdaMaint, di] + Neurons[ni, di, GnmdaSyn] -= glong * Neurons[ni, di, GnmdaSyn] + Neurons[ni, di, Gnmda] -= glong * Neurons[ni, di, Gnmda] + Neurons[ni, di, GMaintSyn] -= glong * Neurons[ni, di, GMaintSyn] + Neurons[ni, di, GnmdaMaint] -= glong * Neurons[ni, di, GnmdaMaint] - Neurons[ni, Gvgcc, di] -= glong * Neurons[ni, Gvgcc, di] - Neurons[ni, VgccM, di] -= glong * Neurons[ni, VgccM, di] - Neurons[ni, VgccH, di] -= glong * Neurons[ni, VgccH, di] - Neurons[ni, Gak, di] -= glong * Neurons[ni, Gak, di] + Neurons[ni, di, Gvgcc] -= glong * Neurons[ni, di, Gvgcc] + Neurons[ni, di, VgccM] -= glong * Neurons[ni, di, VgccM] + Neurons[ni, di, VgccH] -= glong * Neurons[ni, di, VgccH] + Neurons[ni, di, Gak] -= glong * Neurons[ni, di, Gak] // don't mess with SKCa -- longer time scale - Neurons[ni, Gsk, di] -= glong * Neurons[ni, Gsk, di] + Neurons[ni, di, Gsk] -= glong * Neurons[ni, di, Gsk] if ac.Decay.LearnCa > 0 { // learning-based Ca values -- not usual ac.DecayLearnCa(ctx, ni, di, ac.Decay.LearnCa) } - Neurons[ni, Inet, di] = 0.0 - Neurons[ni, GeRaw, di] = 0.0 - Neurons[ni, GiRaw, di] = 0.0 - Neurons[ni, GModRaw, di] = 0.0 - Neurons[ni, GModSyn, di] = 0.0 - Neurons[ni, GMaintRaw, di] = 0.0 - Neurons[ni, SSGiDend, di] = 0.0 - Neurons[ni, GeExt, di] = 0.0 + Neurons[ni, di, Inet] = 0.0 + Neurons[ni, di, GeRaw] = 0.0 + Neurons[ni, di, GiRaw] = 0.0 + Neurons[ni, di, GModRaw] = 0.0 + Neurons[ni, di, GModSyn] = 0.0 + Neurons[ni, di, GMaintRaw] = 0.0 + Neurons[ni, di, SSGiDend] = 0.0 + Neurons[ni, di, GeExt] = 0.0 - Neurons[ni, CtxtGeOrig, di] -= glong * Neurons[ni, CtxtGeOrig, di] + Neurons[ni, di, CtxtGeOrig] -= glong * Neurons[ni, di, CtxtGeOrig] } // InitActs initializes activation state in neuron -- called during InitWeights but otherwise not // automatically called (DecayState is used instead) func (ac *ActParams) InitActs(ctx *Context, ni, di uint32) { - Neurons[ni, Spike, di] = 0 - Neurons[ni, Spiked, di] = 0 - Neurons[ni, ISI, di] = -1 - Neurons[ni, ISIAvg, di] = -1 - Neurons[ni, Act, di] = ac.Init.Act - Neurons[ni, ActInt, di] = ac.Init.Act - Neurons[ni, GeSyn, di] = NeuronAvgs[ni, GeBase] - Neurons[ni, Ge, di] = NeuronAvgs[ni, GeBase] - Neurons[ni, Gi, di] = NeuronAvgs[ni, GiBase] - Neurons[ni, Gk, di] = 0 - Neurons[ni, Inet, di] = 0 - Neurons[ni, Vm, di] = ac.Init.Vm - Neurons[ni, VmDend, di] = ac.Init.Vm - Neurons[ni, Target, di] = 0 - Neurons[ni, Ext, di] = 0 - - Neurons[ni, SpkMaxCa, di] = 0 - Neurons[ni, SpkMax, di] = 0 - Neurons[ni, RLRate, di] = 1 - - Neurons[ni, GeNoiseP, di] = 1 - Neurons[ni, GeNoise, di] = 0 - Neurons[ni, GiNoiseP, di] = 1 - Neurons[ni, GiNoise, di] = 0 - Neurons[ni, GiSyn, di] = 0 - Neurons[ni, SMaintP, di] = 1 - - Neurons[ni, GeInt, di] = 0 - Neurons[ni, GeIntNorm, di] = 0 - Neurons[ni, GiInt, di] = 0 - - Neurons[ni, MahpN, di] = 0 - Neurons[ni, Gmahp, di] = 0 - Neurons[ni, SahpCa, di] = 0 - Neurons[ni, SahpN, di] = 0 - Neurons[ni, Gsahp, di] = 0 - Neurons[ni, GknaMed, di] = 0 - Neurons[ni, GknaSlow, di] = 0 - Neurons[ni, KirM, di] = ac.Kir.Mrest - Neurons[ni, Gkir, di] = 0 - - Neurons[ni, GnmdaSyn, di] = 0 - Neurons[ni, Gnmda, di] = 0 - Neurons[ni, GnmdaMaint, di] = 0 - Neurons[ni, GnmdaLrn, di] = 0 - Neurons[ni, NmdaCa, di] = 0 - - Neurons[ni, GgabaB, di] = 0 - Neurons[ni, GABAB, di] = 0 - Neurons[ni, GABABx, di] = 0 - - Neurons[ni, Gvgcc, di] = 0 - Neurons[ni, VgccM, di] = 0 - Neurons[ni, VgccH, di] = 0 - Neurons[ni, Gak, di] = 0 - Neurons[ni, VgccCaInt, di] = 0 - - Neurons[ni, SKCaIn, di] = 1 - Neurons[ni, SKCaR, di] = 0 - Neurons[ni, SKCaM, di] = 0 - Neurons[ni, Gsk, di] = 0 - - Neurons[ni, GeExt, di] = 0 - Neurons[ni, GeRaw, di] = 0 - Neurons[ni, GiRaw, di] = 0 - Neurons[ni, GModRaw, di] = 0 - Neurons[ni, GModSyn, di] = 0 - Neurons[ni, GMaintRaw, di] = 0 - Neurons[ni, GMaintSyn, di] = 0 - - Neurons[ni, SSGiDend, di] = 0 - - Neurons[ni, Burst, di] = 0 - Neurons[ni, BurstPrv, di] = 0 - - Neurons[ni, CtxtGe, di] = 0 - Neurons[ni, CtxtGeRaw, di] = 0 - Neurons[ni, CtxtGeOrig, di] = 0 + Neurons[ni, di, Spike] = 0 + Neurons[ni, di, Spiked] = 0 + Neurons[ni, di, ISI] = -1 + Neurons[ni, di, ISIAvg] = -1 + Neurons[ni, di, Act] = ac.Init.Act + Neurons[ni, di, ActInt] = ac.Init.Act + Neurons[ni, di, GeSyn] = NeuronAvgs[ni, GeBase] + Neurons[ni, di, Ge] = NeuronAvgs[ni, GeBase] + Neurons[ni, di, Gi] = NeuronAvgs[ni, GiBase] + Neurons[ni, di, Gk] = 0 + Neurons[ni, di, Inet] = 0 + Neurons[ni, di, Vm] = ac.Init.Vm + Neurons[ni, di, VmDend] = ac.Init.Vm + Neurons[ni, di, Target] = 0 + Neurons[ni, di, Ext] = 0 + + Neurons[ni, di, SpkMaxCa] = 0 + Neurons[ni, di, SpkMax] = 0 + Neurons[ni, di, RLRate] = 1 + + Neurons[ni, di, GeNoiseP] = 1 + Neurons[ni, di, GeNoise] = 0 + Neurons[ni, di, GiNoiseP] = 1 + Neurons[ni, di, GiNoise] = 0 + Neurons[ni, di, GiSyn] = 0 + Neurons[ni, di, SMaintP] = 1 + + Neurons[ni, di, GeInt] = 0 + Neurons[ni, di, GeIntNorm] = 0 + Neurons[ni, di, GiInt] = 0 + + Neurons[ni, di, MahpN] = 0 + Neurons[ni, di, Gmahp] = 0 + Neurons[ni, di, SahpCa] = 0 + Neurons[ni, di, SahpN] = 0 + Neurons[ni, di, Gsahp] = 0 + Neurons[ni, di, GknaMed] = 0 + Neurons[ni, di, GknaSlow] = 0 + Neurons[ni, di, KirM] = ac.Kir.Mrest + Neurons[ni, di, Gkir] = 0 + + Neurons[ni, di, GnmdaSyn] = 0 + Neurons[ni, di, Gnmda] = 0 + Neurons[ni, di, GnmdaMaint] = 0 + Neurons[ni, di, GnmdaLrn] = 0 + Neurons[ni, di, NmdaCa] = 0 + + Neurons[ni, di, GgabaB] = 0 + Neurons[ni, di, GABAB] = 0 + Neurons[ni, di, GABABx] = 0 + + Neurons[ni, di, Gvgcc] = 0 + Neurons[ni, di, VgccM] = 0 + Neurons[ni, di, VgccH] = 0 + Neurons[ni, di, Gak] = 0 + Neurons[ni, di, VgccCaInt] = 0 + + Neurons[ni, di, SKCaIn] = 1 + Neurons[ni, di, SKCaR] = 0 + Neurons[ni, di, SKCaM] = 0 + Neurons[ni, di, Gsk] = 0 + + Neurons[ni, di, GeExt] = 0 + Neurons[ni, di, GeRaw] = 0 + Neurons[ni, di, GiRaw] = 0 + Neurons[ni, di, GModRaw] = 0 + Neurons[ni, di, GModSyn] = 0 + Neurons[ni, di, GMaintRaw] = 0 + Neurons[ni, di, GMaintSyn] = 0 + + Neurons[ni, di, SSGiDend] = 0 + + Neurons[ni, di, Burst] = 0 + Neurons[ni, di, BurstPrv] = 0 + + Neurons[ni, di, CtxtGe] = 0 + Neurons[ni, di, CtxtGeRaw] = 0 + Neurons[ni, di, CtxtGeOrig] = 0 for i := range 8 { - Neurons[ni, SpkBin0+NeuronVars(i), di] = 0.0 + Neurons[ni, di, SpkBin0+NeuronVars(i)] = 0.0 } ac.InitLongActs(ctx, ni, di) @@ -1050,11 +1050,11 @@ func (ac *ActParams) InitActs(ctx *Context, ni, di uint32) { // but otherwise not automatically called // (DecayState is used instead) func (ac *ActParams) InitLongActs(ctx *Context, ni, di uint32) { - Neurons[ni, SpkPrv, di] = 0 - Neurons[ni, SpkSt1, di] = 0 - Neurons[ni, SpkSt2, di] = 0 - Neurons[ni, ActM, di] = 0 - Neurons[ni, ActP, di] = 0 + Neurons[ni, di, SpkPrv] = 0 + Neurons[ni, di, SpkSt1] = 0 + Neurons[ni, di, SpkSt2] = 0 + Neurons[ni, di, ActM] = 0 + Neurons[ni, di, ActP] = 0 } //////// Cycle @@ -1066,8 +1066,8 @@ func (ac *ActParams) NMDAFromRaw(ctx *Context, ni, di uint32, geTot float32) { return } geT := max(geTot, 0.0) - Neurons[ni, GnmdaSyn, di] = ac.NMDA.NMDASyn(Neurons[ni, GnmdaSyn, di], geT) - Neurons[ni, Gnmda, di] = ac.NMDA.Gnmda(Neurons[ni, GnmdaSyn, di], Neurons[ni, VmDend, di]) + Neurons[ni, di, GnmdaSyn] = ac.NMDA.NMDASyn(Neurons[ni, di, GnmdaSyn], geT) + Neurons[ni, di, Gnmda] = ac.NMDA.Gnmda(Neurons[ni, di, GnmdaSyn], Neurons[ni, di, VmDend]) // note: nrn.NmdaCa computed via Learn.LrnNMDA in learn.go, CaM method } @@ -1080,26 +1080,26 @@ func (ac *ActParams) MaintNMDAFromRaw(ctx *Context, ni, di uint32) { if ac.SMaint.On.IsTrue() { ac.SMaintFromISI(ctx, ni, di) } - Neurons[ni, GMaintSyn, di] = ac.MaintNMDA.NMDASyn(Neurons[ni, GMaintSyn, di], Neurons[ni, GMaintRaw, di]) - Neurons[ni, GnmdaMaint, di] = ac.MaintNMDA.Gnmda(Neurons[ni, GMaintSyn, di], Neurons[ni, VmDend, di]) + Neurons[ni, di, GMaintSyn] = ac.MaintNMDA.NMDASyn(Neurons[ni, di, GMaintSyn], Neurons[ni, di, GMaintRaw]) + Neurons[ni, di, GnmdaMaint] = ac.MaintNMDA.Gnmda(Neurons[ni, di, GMaintSyn], Neurons[ni, di, VmDend]) } // SMaintFromISI updates the SMaint self-maintenance current into GMaintRaw func (ac *ActParams) SMaintFromISI(ctx *Context, ni, di uint32) { nix := GetNetworkIxs(0) - isi := Neurons[ni, ISIAvg, di] + isi := Neurons[ni, di, ISIAvg] if isi < ac.SMaint.ISI.Min || isi > ac.SMaint.ISI.Max { return } ndi := di*nix.NNeurons + ni - smp := Neurons[ni, SMaintP, di] + smp := Neurons[ni, di, SMaintP] smp *= GetRandomNumber(ndi, ctx.RandCounter.Counter, RandFunActSMaintP) trg := ac.SMaint.ExpInt(isi) if smp <= trg { smp = 1 - Neurons[ni, GMaintRaw, di] += ac.SMaint.Gbar + Neurons[ni, di, GMaintRaw] += ac.SMaint.Gbar } - Neurons[ni, SMaintP, di] = smp + Neurons[ni, di, SMaintP] = smp } // GvgccFromVm updates all the VGCC voltage-gated calcium channel variables @@ -1108,53 +1108,53 @@ func (ac *ActParams) GvgccFromVm(ctx *Context, ni, di uint32) { if ac.VGCC.Gbar == 0 { return } - Neurons[ni, Gvgcc, di] = ac.VGCC.Gvgcc(Neurons[ni, VmDend, di], Neurons[ni, VgccM, di], Neurons[ni, VgccH, di]) + Neurons[ni, di, Gvgcc] = ac.VGCC.Gvgcc(Neurons[ni, di, VmDend], Neurons[ni, di, VgccM], Neurons[ni, di, VgccH]) var dm, dh float32 - ac.VGCC.DMHFromV(Neurons[ni, VmDend, di], Neurons[ni, VgccM, di], Neurons[ni, VgccH, di], &dm, &dh) - Neurons[ni, VgccM, di] += dm - Neurons[ni, VgccH, di] += dh + ac.VGCC.DMHFromV(Neurons[ni, di, VmDend], Neurons[ni, di, VgccM], Neurons[ni, di, VgccH], &dm, &dh) + Neurons[ni, di, VgccM] += dm + Neurons[ni, di, VgccH] += dh // note: may be overwritten! - Neurons[ni, VgccCa, di] = ac.VGCC.CaFromG(Neurons[ni, VmDend, di], Neurons[ni, Gvgcc, di], Neurons[ni, VgccCa, di]) + Neurons[ni, di, VgccCa] = ac.VGCC.CaFromG(Neurons[ni, di, VmDend], Neurons[ni, di, Gvgcc], Neurons[ni, di, VgccCa]) } // GkFromVm updates all the Gk-based conductances: Mahp, KNa, Gak func (ac *ActParams) GkFromVm(ctx *Context, ni, di uint32) { - vm := Neurons[ni, Vm, di] - vmd := Neurons[ni, VmDend, di] - mahpN := Neurons[ni, MahpN, di] + vm := Neurons[ni, di, Vm] + vmd := Neurons[ni, di, VmDend] + mahpN := Neurons[ni, di, MahpN] gmahp := ac.Mahp.GmAHP(vm, &mahpN) - Neurons[ni, Gmahp, di] = gmahp - Neurons[ni, MahpN, di] = mahpN + Neurons[ni, di, Gmahp] = gmahp + Neurons[ni, di, MahpN] = mahpN - gsahp := Neurons[ni, Gsahp, di] + gsahp := Neurons[ni, di, Gsahp] gak := ac.AK.Gak(vmd) - Neurons[ni, Gak, di] = gak + Neurons[ni, di, Gak] = gak - nkirM := Neurons[ni, KirM, di] + nkirM := Neurons[ni, di, KirM] gkir := ac.Kir.Gkir(vm, nkirM) - Neurons[ni, Gkir, di] = gkir + Neurons[ni, di, Gkir] = gkir nkirM += ac.Kir.DM(chans.VToBio(vm), nkirM) - Neurons[ni, KirM, di] = nkirM + Neurons[ni, di, KirM] = nkirM gktot := gmahp + gsahp + gak + gkir if ac.KNa.On.IsTrue() { - gknaMed := Neurons[ni, GknaMed, di] - gknaSlow := Neurons[ni, GknaSlow, di] - ac.KNa.GcFromSpike(&gknaMed, &gknaSlow, Neurons[ni, Spike, di] > .5) - Neurons[ni, GknaMed, di] = gknaMed - Neurons[ni, GknaSlow, di] = gknaSlow + gknaMed := Neurons[ni, di, GknaMed] + gknaSlow := Neurons[ni, di, GknaSlow] + ac.KNa.GcFromSpike(&gknaMed, &gknaSlow, Neurons[ni, di, Spike] > .5) + Neurons[ni, di, GknaMed] = gknaMed + Neurons[ni, di, GknaSlow] = gknaSlow gktot += gknaMed + gknaSlow } - Neurons[ni, Gk, di] = gktot + Neurons[ni, di, Gk] = gktot } // KNaNewState does TrialSlow version of KNa during NewState if option is set func (ac *ActParams) KNaNewState(ctx *Context, ni, di uint32) { if ac.KNa.On.IsTrue() && ac.KNa.TrialSlow.IsTrue() { - Neurons[ni, GknaSlow, di] += ac.KNa.Slow.Max * Neurons[ni, SpkPrv, di] + Neurons[ni, di, GknaSlow] += ac.KNa.Slow.Max * Neurons[ni, di, SpkPrv] } } @@ -1163,36 +1163,36 @@ func (ac *ActParams) GSkCaFromCa(ctx *Context, ni, di uint32) { if ac.SKCa.Gbar == 0 { return } - skcar := Neurons[ni, SKCaR, di] - skcain := Neurons[ni, SKCaIn, di] - Neurons[ni, SKCaM, di] = ac.SKCa.MFromCa(skcar, Neurons[ni, SKCaM, di]) - ac.SKCa.CaInRFromSpike(Neurons[ni, Spike, di], Neurons[ni, CaSpkD, di], &skcain, &skcar) - Neurons[ni, SKCaR, di] = skcar - Neurons[ni, SKCaIn, di] = skcain - Neurons[ni, Gsk, di] = ac.SKCa.Gbar * Neurons[ni, SKCaM, di] - Neurons[ni, Gk, di] += Neurons[ni, Gsk, di] + skcar := Neurons[ni, di, SKCaR] + skcain := Neurons[ni, di, SKCaIn] + Neurons[ni, di, SKCaM] = ac.SKCa.MFromCa(skcar, Neurons[ni, di, SKCaM]) + ac.SKCa.CaInRFromSpike(Neurons[ni, di, Spike], Neurons[ni, di, CaSpkD], &skcain, &skcar) + Neurons[ni, di, SKCaR] = skcar + Neurons[ni, di, SKCaIn] = skcain + Neurons[ni, di, Gsk] = ac.SKCa.Gbar * Neurons[ni, di, SKCaM] + Neurons[ni, di, Gk] += Neurons[ni, di, Gsk] } // GeFromSyn integrates Ge excitatory conductance from GeSyn. // geExt is extra conductance to add to the final Ge value func (ac *ActParams) GeFromSyn(ctx *Context, ni, di uint32, geSyn, geExt float32) { - Neurons[ni, GeExt, di] = 0.0 + Neurons[ni, di, GeExt] = 0.0 geS := geSyn geE := geExt if ac.Clamp.Add.IsTrue() && NeuronHasFlag(NeuronHasExt, ni, di) { - Neurons[ni, GeExt, di] = Neurons[ni, Ext, di] * ac.Clamp.Ge - geS += Neurons[ni, GeExt, di] + Neurons[ni, di, GeExt] = Neurons[ni, di, Ext] * ac.Clamp.Ge + geS += Neurons[ni, di, GeExt] } if ac.Clamp.Add.IsFalse() && NeuronHasFlag(NeuronHasExt, ni, di) { - geS = Neurons[ni, Ext, di] * ac.Clamp.Ge - Neurons[ni, GeExt, di] = geS + geS = Neurons[ni, di, Ext] * ac.Clamp.Ge + Neurons[ni, di, GeExt] = geS geE = 0 // no extra in this case } - Neurons[ni, Ge, di] = geS + geE - if Neurons[ni, Ge, di] < 0.0 { - Neurons[ni, Ge, di] = 0.0 + Neurons[ni, di, Ge] = geS + geE + if Neurons[ni, di, Ge] < 0.0 { + Neurons[ni, di, Ge] = 0.0 } ac.AddGeNoise(ctx, ni, di) } @@ -1202,11 +1202,11 @@ func (ac *ActParams) AddGeNoise(ctx *Context, ni, di uint32) { if ac.Noise.On.IsFalse() || ac.Noise.Ge == 0 { return } - p := Neurons[ni, GeNoiseP, di] + p := Neurons[ni, di, GeNoiseP] ge := ac.Noise.PGe(ctx, &p, ni, di) - Neurons[ni, GeNoiseP, di] = p - Neurons[ni, GeNoise, di] = ac.Dt.GeSynFromRaw(Neurons[ni, GeNoise, di], ge) - Neurons[ni, Ge, di] += Neurons[ni, GeNoise, di] + Neurons[ni, di, GeNoiseP] = p + Neurons[ni, di, GeNoise] = ac.Dt.GeSynFromRaw(Neurons[ni, di, GeNoise], ge) + Neurons[ni, di, Ge] += Neurons[ni, di, GeNoise] } // AddGiNoise updates nrn.GiNoise if active @@ -1214,10 +1214,10 @@ func (ac *ActParams) AddGiNoise(ctx *Context, ni, di uint32) { if ac.Noise.On.IsFalse() || ac.Noise.Gi == 0 { return } - p := Neurons[ni, GiNoiseP, di] + p := Neurons[ni, di, GiNoiseP] gi := ac.Noise.PGi(ctx, &p, ni, di) - Neurons[ni, GiNoiseP, di] = p - Neurons[ni, GiNoise, di] = ac.Dt.GiSynFromRaw(Neurons[ni, GiNoise, di], gi) + Neurons[ni, di, GiNoiseP] = p + Neurons[ni, di, GiNoise] = ac.Dt.GiSynFromRaw(Neurons[ni, di, GiNoise], gi) } // GiFromSyn integrates GiSyn inhibitory synaptic conductance from GiRaw value @@ -1262,20 +1262,20 @@ func (ac *ActParams) VmFromG(ctx *Context, ni, di uint32) { updtVm := true // note: nrn.ISI has NOT yet been updated at this point: 0 right after spike, etc // so it takes a full 3 time steps after spiking for Tr period - isi := Neurons[ni, ISI, di] + isi := Neurons[ni, di, ISI] if ac.Spikes.Tr > 0 && isi >= 0 && isi < float32(ac.Spikes.Tr) { updtVm = false // don't update the spiking vm during refract } - ge := Neurons[ni, Ge, di] * ac.Gbar.E - gi := Neurons[ni, Gi, di] * ac.Gbar.I - gk := Neurons[ni, Gk, di] * ac.Gbar.K + ge := Neurons[ni, di, Ge] * ac.Gbar.E + gi := Neurons[ni, di, Gi] * ac.Gbar.I + gk := Neurons[ni, di, Gk] * ac.Gbar.K var nvm, inet, expi float32 if updtVm { - ac.VmInteg(Neurons[ni, Vm, di], ac.Dt.VmDt, ge, 1, gi, gk, &nvm, &inet) + ac.VmInteg(Neurons[ni, di, Vm], ac.Dt.VmDt, ge, 1, gi, gk, &nvm, &inet) if updtVm && ac.Spikes.Exp.IsTrue() { // add spike current if relevant var exVm float32 - exVm = 0.5 * (nvm + Neurons[ni, Vm, di]) // midpoint for this + exVm = 0.5 * (nvm + Neurons[ni, di, Vm]) // midpoint for this expi = ac.Gbar.L * ac.Spikes.ExpSlope * math32.FastExp((exVm-ac.Spikes.Thr)/ac.Spikes.ExpSlope) if expi > ac.Dt.VmTau { @@ -1284,17 +1284,17 @@ func (ac *ActParams) VmFromG(ctx *Context, ni, di uint32) { inet += expi nvm = ac.VmFromInet(nvm, ac.Dt.VmDt, expi) } - Neurons[ni, Vm, di] = nvm - Neurons[ni, Inet, di] = inet + Neurons[ni, di, Vm] = nvm + Neurons[ni, di, Inet] = inet } else { // decay back to VmR var dvm float32 if int32(isi) == ac.Spikes.Tr-1 { - dvm = ac.Spikes.VmR - Neurons[ni, Vm, di] + dvm = ac.Spikes.VmR - Neurons[ni, di, Vm] } else { - dvm = ac.Spikes.RDt * (ac.Spikes.VmR - Neurons[ni, Vm, di]) + dvm = ac.Spikes.RDt * (ac.Spikes.VmR - Neurons[ni, di, Vm]) } - Neurons[ni, Vm, di] += dvm - Neurons[ni, Inet, di] = dvm * ac.Dt.VmTau + Neurons[ni, di, Vm] += dvm + Neurons[ni, di, Inet] = dvm * ac.Dt.VmTau } glEff := float32(1) @@ -1302,12 +1302,12 @@ func (ac *ActParams) VmFromG(ctx *Context, ni, di uint32) { glEff += ac.Dend.GbarR } var giEff float32 - giEff = gi + ac.Gbar.I*Neurons[ni, SSGiDend, di] - ac.VmInteg(Neurons[ni, VmDend, di], ac.Dt.VmDendDt, ge, glEff, giEff, gk, &nvm, &inet) + giEff = gi + ac.Gbar.I*Neurons[ni, di, SSGiDend] + ac.VmInteg(Neurons[ni, di, VmDend], ac.Dt.VmDendDt, ge, glEff, giEff, gk, &nvm, &inet) if updtVm { nvm = ac.VmFromInet(nvm, ac.Dt.VmDendDt, ac.Dend.GbarExp*expi) } - Neurons[ni, VmDend, di] = nvm + Neurons[ni, di, VmDend] = nvm } // SpikeFromVmVars computes Spike from Vm and ISI-based activation, using pointers to variables @@ -1358,18 +1358,18 @@ func (ac *ActParams) SpikeFromVmVars(nrnISI, nrnISIAvg, nrnSpike, nrnSpiked, nrn // SpikeFromVm computes Spike from Vm and ISI-based activation func (ac *ActParams) SpikeFromVm(ctx *Context, ni, di uint32) { - nrnISI := Neurons[ni, ISI, di] - nrnISIAvg := Neurons[ni, ISIAvg, di] - nrnSpike := Neurons[ni, Spike, di] - nrnSpiked := Neurons[ni, Spiked, di] - nrnAct := Neurons[ni, Act, di] - nrnVm := Neurons[ni, Vm, di] + nrnISI := Neurons[ni, di, ISI] + nrnISIAvg := Neurons[ni, di, ISIAvg] + nrnSpike := Neurons[ni, di, Spike] + nrnSpiked := Neurons[ni, di, Spiked] + nrnAct := Neurons[ni, di, Act] + nrnVm := Neurons[ni, di, Vm] ac.SpikeFromVmVars(&nrnISI, &nrnISIAvg, &nrnSpike, &nrnSpiked, &nrnAct, nrnVm) - Neurons[ni, ISI, di] = nrnISI - Neurons[ni, ISIAvg, di] = nrnISIAvg - Neurons[ni, Spike, di] = nrnSpike - Neurons[ni, Spiked, di] = nrnSpiked - Neurons[ni, Act, di] = nrnAct + Neurons[ni, di, ISI] = nrnISI + Neurons[ni, di, ISIAvg] = nrnISIAvg + Neurons[ni, di, Spike] = nrnSpike + Neurons[ni, di, Spiked] = nrnSpiked + Neurons[ni, di, Act] = nrnAct } //gosl:end diff --git a/axon/act_test.go b/axon/act_test.go index ed885d61..ce8a22fc 100644 --- a/axon/act_test.go +++ b/axon/act_test.go @@ -38,17 +38,17 @@ func TestActUpdate(t *testing.T) { di := uint32(0) for i := range geinc { - Neurons.SetAdd(geinc[i], int(ni), int(GeRaw), int(di)) - Neurons.Set(ac.Dt.GeSynFromRaw(Neurons.Value(int(ni), int(GeSyn), int(di)), Neurons.Value(int(ni), int(GeRaw), int(di))), int(ni), int(GeSyn), int(di)) - ac.GeFromSyn(ctx, ni, di, Neurons.Value(int(ni), int(GeSyn), int(di)), Neurons.Value(int(ni), int(GeExt), int(di))) - ac.GiFromSyn(ctx, ni, di, Neurons.Value(int(ni), int(GiSyn), int(di))) + Neurons.SetAdd(geinc[i], int(ni), int(di), int(GeRaw)) + Neurons.Set(ac.Dt.GeSynFromRaw(Neurons.Value(int(ni), int(di), int(GeSyn)), Neurons.Value(int(ni), int(di), int(GeRaw))), int(ni), int(di), int(GeSyn)) + ac.GeFromSyn(ctx, ni, di, Neurons.Value(int(ni), int(di), int(GeSyn)), Neurons.Value(int(ni), int(di), int(GeExt))) + ac.GiFromSyn(ctx, ni, di, Neurons.Value(int(ni), int(di), int(GiSyn))) ac.VmFromG(ctx, ni, di) ac.SpikeFromVm(ctx, ni, di) - ge[i] = Neurons.Value(int(ni), int(Ge), int(di)) - inet[i] = Neurons.Value(int(ni), int(Inet), int(di)) - vm[i] = Neurons.Value(int(ni), int(Vm), int(di)) - spike[i] = Neurons.Value(int(ni), int(Spike), int(di)) - act[i] = Neurons.Value(int(ni), int(Act), int(di)) + ge[i] = Neurons.Value(int(ni), int(di), int(Ge)) + inet[i] = Neurons.Value(int(ni), int(di), int(Inet)) + vm[i] = Neurons.Value(int(ni), int(di), int(Vm)) + spike[i] = Neurons.Value(int(ni), int(di), int(Spike)) + act[i] = Neurons.Value(int(ni), int(di), int(Act)) difge := math32.Abs(ge[i] - correctGe[i]) if difge > TOLERANCE { // allow for small numerical diffs t.Errorf("ge err: idx: %v, geinc: %v, ge: %v, corge: %v, dif: %v\n", i, geinc[i], ge[i], correctGe[i], difge) diff --git a/axon/act_test.goal b/axon/act_test.goal index 2426f54e..77c59eb7 100644 --- a/axon/act_test.goal +++ b/axon/act_test.goal @@ -36,17 +36,17 @@ func TestActUpdate(t *testing.T) { di := uint32(0) for i := range geinc { - Neurons[ni, GeRaw, di] += geinc[i] - Neurons[ni, GeSyn, di] = ac.Dt.GeSynFromRaw(Neurons[ni, GeSyn, di], Neurons[ni, GeRaw, di]) - ac.GeFromSyn(ctx, ni, di, Neurons[ni, GeSyn, di], Neurons[ni, GeExt, di]) - ac.GiFromSyn(ctx, ni, di, Neurons[ni, GiSyn, di]) + Neurons[ni, di, GeRaw] += geinc[i] + Neurons[ni, di, GeSyn] = ac.Dt.GeSynFromRaw(Neurons[ni, di, GeSyn], Neurons[ni, di, GeRaw]) + ac.GeFromSyn(ctx, ni, di, Neurons[ni, di, GeSyn], Neurons[ni, di, GeExt]) + ac.GiFromSyn(ctx, ni, di, Neurons[ni, di, GiSyn]) ac.VmFromG(ctx, ni, di) ac.SpikeFromVm(ctx, ni, di) - ge[i] = Neurons[ni, Ge, di] - inet[i] = Neurons[ni, Inet, di] - vm[i] = Neurons[ni, Vm, di] - spike[i] = Neurons[ni, Spike, di] - act[i] = Neurons[ni, Act, di] + ge[i] = Neurons[ni, di, Ge] + inet[i] = Neurons[ni, di, Inet] + vm[i] = Neurons[ni, di, Vm] + spike[i] = Neurons[ni, di, Spike] + act[i] = Neurons[ni, di, Act] difge := math32.Abs(ge[i] - correctGe[i]) if difge > TOLERANCE { // allow for small numerical diffs t.Errorf("ge err: idx: %v, geinc: %v, ge: %v, corge: %v, dif: %v\n", i, geinc[i], ge[i], correctGe[i], difge) diff --git a/axon/basic_test.go b/axon/basic_test.go index 5b95f768..425edbe7 100644 --- a/axon/basic_test.go +++ b/axon/basic_test.go @@ -230,13 +230,13 @@ func TestSpikeProp(t *testing.T) { hidCyc := 0 for cyc := range 100 { net.Cycle(1, true) - // fmt.Println(cyc, Neurons[hidLay.NeurStIndex, Ge, 0], Neurons[hidLay.NeurStIndex, GeRaw, 0]) - if Neurons.Value(int(inLay.NeurStIndex), int(Spike), int(0)) > 0 { + // fmt.Println(cyc, Neurons[hidLay.NeurStIndex, 0, Ge], Neurons[hidLay.NeurStIndex, 0, GeRaw]) + if Neurons.Value(int(inLay.NeurStIndex), int(0), int(Spike)) > 0 { // fmt.Println("in spike:", cyc) inCyc = cyc } - ge := Neurons.Value(int(hidLay.NeurStIndex), int(Ge), int(0)) + ge := Neurons.Value(int(hidLay.NeurStIndex), int(0), int(Ge)) if ge > 0 { // fmt.Println("hid recv:", cyc, ge) hidCyc = cyc @@ -690,14 +690,14 @@ func RunDebugAct(t *testing.T, testNet *Network, printValues bool, gpu bool, ini // these control what is printed. // the whole thing is run and returned in the valMap valsPerRow := 4 - nQtrs := 4 // max 4 - cycPerQtr := 50 // max 50 + nQtrs := 1 // max 4 + cycPerQtr := 40 // max 50 nPats := 1 // max 4 - stLayer := 2 // max 2 - edLayer := 3 // max 3 + stLayer := 1 // max 2 + edLayer := 2 // max 3 nNeurs := 1 // max 4 -- number of neuron values to print - for pi := 0; pi < 4; pi++ { + for pi := 0; pi < nPats; pi++ { if initWts { testNet.SetRandSeed(42) // critical for ActAvg values testNet.InitWeights() @@ -1669,7 +1669,7 @@ func TestRubiconGiveUp(t *testing.T) { // pj.Defaults() // // nsamp := 100 -// dt := &table.Table{} +// dt := table.New() // dt.AddFloat32Column("Wt") // dt.AddFloat32Column("LWt") // dt.AddFloat32Column("SWt") diff --git a/axon/basic_test.goal b/axon/basic_test.goal index f79bfd6c..eb46aa1f 100644 --- a/axon/basic_test.goal +++ b/axon/basic_test.goal @@ -230,13 +230,13 @@ func TestSpikeProp(t *testing.T) { hidCyc := 0 for cyc := range 100 { net.Cycle(1, true) - // fmt.Println(cyc, Neurons[hidLay.NeurStIndex, Ge, 0], Neurons[hidLay.NeurStIndex, GeRaw, 0]) - if Neurons[inLay.NeurStIndex, Spike, 0] > 0 { + // fmt.Println(cyc, Neurons[hidLay.NeurStIndex, 0, Ge], Neurons[hidLay.NeurStIndex, 0, GeRaw]) + if Neurons[inLay.NeurStIndex, 0, Spike] > 0 { // fmt.Println("in spike:", cyc) inCyc = cyc } - ge := Neurons[hidLay.NeurStIndex, Ge, 0] + ge := Neurons[hidLay.NeurStIndex, 0, Ge] if ge > 0 { // fmt.Println("hid recv:", cyc, ge) hidCyc = cyc @@ -690,14 +690,14 @@ func RunDebugAct(t *testing.T, testNet *Network, printValues bool, gpu bool, ini // these control what is printed. // the whole thing is run and returned in the valMap valsPerRow := 4 - nQtrs := 4 // max 4 - cycPerQtr := 50 // max 50 + nQtrs := 1 // max 4 + cycPerQtr := 40 // max 50 nPats := 1 // max 4 - stLayer := 2 // max 2 - edLayer := 3 // max 3 + stLayer := 1 // max 2 + edLayer := 2 // max 3 nNeurs := 1 // max 4 -- number of neuron values to print - for pi := 0; pi < 4; pi++ { + for pi := 0; pi < nPats; pi++ { if initWts { testNet.SetRandSeed(42) // critical for ActAvg values testNet.InitWeights() diff --git a/axon/init-layer.go b/axon/init-layer.go index e8951dd2..d6ee7822 100644 --- a/axon/init-layer.go +++ b/axon/init-layer.go @@ -310,9 +310,9 @@ func (ly *Layer) DecayState(ctx *Context, di uint32, decay, glong, ahp float32) if ahp == 1 { lt := ly.Type if lt == PTMaintLayer { - Neurons.Set(0, int(ni), int(CtxtGe), int(di)) - Neurons.Set(0, int(ni), int(CtxtGeRaw), int(di)) - Neurons.Set(0, int(ni), int(CtxtGeOrig), int(di)) + Neurons.Set(0, int(ni), int(di), int(CtxtGe)) + Neurons.Set(0, int(ni), int(di), int(CtxtGeRaw)) + Neurons.Set(0, int(ni), int(di), int(CtxtGeOrig)) } } } diff --git a/axon/init-layer.goal b/axon/init-layer.goal index 76eee1c5..ab4598ab 100644 --- a/axon/init-layer.goal +++ b/axon/init-layer.goal @@ -307,9 +307,9 @@ func (ly *Layer) DecayState(ctx *Context, di uint32, decay, glong, ahp float32) if ahp == 1 { lt := ly.Type if lt == PTMaintLayer { - Neurons[ni, CtxtGe, di] = 0 - Neurons[ni, CtxtGeRaw, di] = 0 - Neurons[ni, CtxtGeOrig, di] = 0 + Neurons[ni, di, CtxtGe] = 0 + Neurons[ni, di, CtxtGeRaw] = 0 + Neurons[ni, di, CtxtGeOrig] = 0 } } } diff --git a/axon/layer.go b/axon/layer.go index ae8e6f8d..d38891e5 100644 --- a/axon/layer.go +++ b/axon/layer.go @@ -487,7 +487,7 @@ func (ly *Layer) UnitValue1D(varIndex int, idx, di int) float32 { } else if NeuronVars(varIndex) >= NeuronVarsN { return NeuronAvgs.Value(int(ni), int(NeuronVars(varIndex)-NeuronVarsN)) } else { - return Neurons.Value(int(ni), int(varIndex), int(di)) + return Neurons.Value(int(ni), int(di), int(varIndex)) } return math32.NaN() } @@ -600,12 +600,12 @@ func (ly *Layer) VarRange(varNm string) (min, max float32, err error) { } nvar := vidx - v0 := Neurons.Value(int(ly.NeurStIndex), int(nvar), int(0)) + v0 := Neurons.Value(int(ly.NeurStIndex), int(0), int(nvar)) min = v0 max = v0 for lni := uint32(1); lni < nn; lni++ { ni := ly.NeurStIndex + lni - vl := Neurons.Value(int(ni), int(nvar), int(0)) + vl := Neurons.Value(int(ni), int(0), int(nvar)) if vl < min { min = vl } diff --git a/axon/layer.goal b/axon/layer.goal index 25b89966..d7059717 100644 --- a/axon/layer.goal +++ b/axon/layer.goal @@ -485,7 +485,7 @@ func (ly *Layer) UnitValue1D(varIndex int, idx, di int) float32 { } else if NeuronVars(varIndex) >= NeuronVarsN { return NeuronAvgs[ni, NeuronVars(varIndex)-NeuronVarsN] } else { - return Neurons[ni, varIndex, di] + return Neurons[ni, di, varIndex] } return math32.NaN() } @@ -598,12 +598,12 @@ func (ly *Layer) VarRange(varNm string) (min, max float32, err error) { } nvar := vidx - v0 := Neurons[ly.NeurStIndex, nvar, 0] + v0 := Neurons[ly.NeurStIndex, 0, nvar] min = v0 max = v0 for lni := uint32(1); lni < nn; lni++ { ni := ly.NeurStIndex + lni - vl := Neurons[ni, nvar, 0] + vl := Neurons[ni, 0, nvar] if vl < min { min = vl } diff --git a/axon/learn-path.go b/axon/learn-path.go index 0c19f706..4734a4ec 100644 --- a/axon/learn-path.go +++ b/axon/learn-path.go @@ -48,22 +48,22 @@ func (pt *PathParams) DWtSyn(ctx *Context, rlay *LayerParams, syni, si, ri, di u // SynCa gets the synaptic calcium P (potentiation) and D (depression) // values, using optimized computation. func (pt *PathParams) SynCa(ctx *Context, si, ri, di uint32, syCaP, syCaD *float32) { - rb0 := Neurons.Value(int(ri), int(SpkBin0), int(di)) - sb0 := Neurons.Value(int(si), int(SpkBin0), int(di)) - rb1 := Neurons.Value(int(ri), int(SpkBin1), int(di)) - sb1 := Neurons.Value(int(si), int(SpkBin1), int(di)) - rb2 := Neurons.Value(int(ri), int(SpkBin2), int(di)) - sb2 := Neurons.Value(int(si), int(SpkBin2), int(di)) - rb3 := Neurons.Value(int(ri), int(SpkBin3), int(di)) - sb3 := Neurons.Value(int(si), int(SpkBin3), int(di)) - rb4 := Neurons.Value(int(ri), int(SpkBin4), int(di)) - sb4 := Neurons.Value(int(si), int(SpkBin4), int(di)) - rb5 := Neurons.Value(int(ri), int(SpkBin5), int(di)) - sb5 := Neurons.Value(int(si), int(SpkBin5), int(di)) - rb6 := Neurons.Value(int(ri), int(SpkBin6), int(di)) - sb6 := Neurons.Value(int(si), int(SpkBin6), int(di)) - rb7 := Neurons.Value(int(ri), int(SpkBin7), int(di)) - sb7 := Neurons.Value(int(si), int(SpkBin7), int(di)) + rb0 := Neurons.Value(int(ri), int(di), int(SpkBin0)) + sb0 := Neurons.Value(int(si), int(di), int(SpkBin0)) + rb1 := Neurons.Value(int(ri), int(di), int(SpkBin1)) + sb1 := Neurons.Value(int(si), int(di), int(SpkBin1)) + rb2 := Neurons.Value(int(ri), int(di), int(SpkBin2)) + sb2 := Neurons.Value(int(si), int(di), int(SpkBin2)) + rb3 := Neurons.Value(int(ri), int(di), int(SpkBin3)) + sb3 := Neurons.Value(int(si), int(di), int(SpkBin3)) + rb4 := Neurons.Value(int(ri), int(di), int(SpkBin4)) + sb4 := Neurons.Value(int(si), int(di), int(SpkBin4)) + rb5 := Neurons.Value(int(ri), int(di), int(SpkBin5)) + sb5 := Neurons.Value(int(si), int(di), int(SpkBin5)) + rb6 := Neurons.Value(int(ri), int(di), int(SpkBin6)) + sb6 := Neurons.Value(int(si), int(di), int(SpkBin6)) + rb7 := Neurons.Value(int(ri), int(di), int(SpkBin7)) + sb7 := Neurons.Value(int(si), int(di), int(SpkBin7)) b0 := 0.1 * (rb0 * sb0) b1 := 0.1 * (rb1 * sb1) @@ -86,7 +86,7 @@ func (pt *PathParams) DWtSynCortex(ctx *Context, syni, si, ri, lpi, pi, di uint3 dtr := syCaD // delta trace, caD reflects entire window if pt.Type == CTCtxtPath { // layer 6 CT pathway - dtr = Neurons.Value(int(si), int(BurstPrv), int(di)) + dtr = Neurons.Value(int(si), int(di), int(BurstPrv)) } // save delta trace for GUI SynapseTraces.Set(dtr, int(syni), int(DTr), int(di)) @@ -104,7 +104,7 @@ func (pt *PathParams) DWtSynCortex(ctx *Context, syni, si, ri, lpi, pi, di uint3 if isTarget { err = syCaP - syCaD // for target layers, syn Ca drives error signal directly } else { - err = tr * (Neurons.Value(int(ri), int(NrnCaP), int(di)) - Neurons.Value(int(ri), int(NrnCaD), int(di))) // hiddens: recv NMDA Ca drives error signal w/ trace credit + err = tr * (Neurons.Value(int(ri), int(di), int(NrnCaP)) - Neurons.Value(int(ri), int(di), int(NrnCaD))) // hiddens: recv NMDA Ca drives error signal w/ trace credit } // note: trace ensures that nothing changes for inactive synapses.. // sb immediately -- enters into zero sum. @@ -118,7 +118,7 @@ func (pt *PathParams) DWtSynCortex(ctx *Context, syni, si, ri, lpi, pi, di uint3 if pt.Type == CTCtxtPath { // rn.RLRate IS needed for other pathways, just not the context one SynapseTraces.Set(pt.Learn.LRate.Eff*err, int(syni), int(DiDWt), int(di)) } else { - SynapseTraces.Set(Neurons.Value(int(ri), int(RLRate), int(di))*pt.Learn.LRate.Eff*err, int(syni), int(DiDWt), int(di)) + SynapseTraces.Set(Neurons.Value(int(ri), int(di), int(RLRate))*pt.Learn.LRate.Eff*err, int(syni), int(DiDWt), int(di)) } } @@ -126,11 +126,11 @@ func (pt *PathParams) DWtSynCortex(ctx *Context, syni, si, ri, lpi, pi, di uint3 // Uses synaptically integrated spiking, computed at the Theta cycle interval. // This is the trace version for hidden units, and uses syn CaP - CaD for targets. func (pt *PathParams) DWtSynHebb(ctx *Context, syni, si, ri, lpi, pi, di uint32) { - rNrnCaP := Neurons.Value(int(ri), int(NrnCaP), int(di)) - sNrnCap := Neurons.Value(int(si), int(NrnCaP), int(di)) + rNrnCaP := Neurons.Value(int(ri), int(di), int(NrnCaP)) + sNrnCap := Neurons.Value(int(si), int(di), int(NrnCaP)) lwt := Synapses.Value(int(syni), int(LWt)) // linear weight hebb := rNrnCaP * (pt.Learn.Hebb.Up*sNrnCap*(1-lwt) - pt.Learn.Hebb.Down*(1-sNrnCap)*lwt) - // not: Neurons[ri, RLRate, di]* + // not: Neurons[ri, di, RLRate]* SynapseTraces.Set(pt.Learn.LRate.Eff*hebb, int(syni), int(DiDWt), int(di)) } @@ -154,8 +154,8 @@ func (pt *PathParams) DWtSynHip(ctx *Context, syni, si, ri, lpi, pi, di uint32, } // error-driven learning part - rNrnCaP := Neurons.Value(int(ri), int(NrnCaP), int(di)) - rNrnCaD := Neurons.Value(int(ri), int(NrnCaD), int(di)) + rNrnCaP := Neurons.Value(int(ri), int(di), int(NrnCaP)) + rNrnCaD := Neurons.Value(int(ri), int(di), int(NrnCaD)) var err float32 if isTarget { err = syCaP - syCaD // for target layers, syn Ca drives error signal directly @@ -173,13 +173,13 @@ func (pt *PathParams) DWtSynHip(ctx *Context, syni, si, ri, lpi, pi, di uint32, } // hebbian-learning part - sNrnCap := Neurons.Value(int(si), int(NrnCaP), int(di)) + sNrnCap := Neurons.Value(int(si), int(di), int(NrnCaP)) savg := 0.5 + pt.Hip.SAvgCor*(pt.Hip.SNominal-0.5) savg = 0.5 / math32.Max(pt.Hip.SAvgThr, savg) // keep this Sending Average Correction term within bounds (SAvgThr) hebb := rNrnCaP * (sNrnCap*(savg-lwt) - (1-sNrnCap)*lwt) // setting delta weight (note: impossible to be CTCtxtPath) - dwt := Neurons.Value(int(ri), int(RLRate), int(di)) * pt.Learn.LRate.Eff * (pt.Hip.Hebb*hebb + pt.Hip.Err*err) + dwt := Neurons.Value(int(ri), int(di), int(RLRate)) * pt.Learn.LRate.Eff * (pt.Hip.Hebb*hebb + pt.Hip.Err*err) SynapseTraces.Set(dwt, int(syni), int(DiDWt), int(di)) } @@ -191,14 +191,14 @@ func (pt *PathParams) DWtSynBLA(ctx *Context, syni, si, ri, lpi, pi, di uint32) dwt := float32(0) ach := GlobalScalars.Value(int(GvACh), int(di)) if GlobalScalars.Value(int(GvHasRew), int(di)) > 0 { // learn and reset - ract := Neurons.Value(int(ri), int(CaSpkD), int(di)) + ract := Neurons.Value(int(ri), int(di), int(CaSpkD)) if ract < pt.Learn.Trace.LearnThr { ract = 0 } tr := SynapseTraces.Value(int(syni), int(Tr), int(di)) ustr := pt.BLA.USTrace - tr = ustr*Neurons.Value(int(si), int(Burst), int(di)) + (1.0-ustr)*tr - delta := Neurons.Value(int(ri), int(CaSpkP), int(di)) - Neurons.Value(int(ri), int(SpkPrv), int(di)) + tr = ustr*Neurons.Value(int(si), int(di), int(Burst)) + (1.0-ustr)*tr + delta := Neurons.Value(int(ri), int(di), int(CaSpkP)) - Neurons.Value(int(ri), int(di), int(SpkPrv)) if delta < 0 { // neg delta learns slower in Acq, not Ext delta *= pt.BLA.NegDeltaLRate } @@ -206,7 +206,7 @@ func (pt *PathParams) DWtSynBLA(ctx *Context, syni, si, ri, lpi, pi, di uint32) SynapseTraces.Set(0.0, int(syni), int(Tr), int(di)) } else if ach > pt.BLA.AChThr { // note: the former NonUSLRate parameter is not used -- Trace update Tau replaces it.. elegant - dtr := ach * Neurons.Value(int(si), int(Burst), int(di)) + dtr := ach * Neurons.Value(int(si), int(di), int(Burst)) SynapseTraces.Set(dtr, int(syni), int(DTr), int(di)) tr := pt.Learn.Trace.TrFromCa(SynapseTraces.Value(int(syni), int(Tr), int(di)), dtr) SynapseTraces.Set(tr, int(syni), int(Tr), int(di)) @@ -219,7 +219,7 @@ func (pt *PathParams) DWtSynBLA(ctx *Context, syni, si, ri, lpi, pi, di uint32) } else { dwt *= lwt } - SynapseTraces.Set(Neurons.Value(int(ri), int(RLRate), int(di))*pt.Learn.LRate.Eff*dwt, int(syni), int(DiDWt), int(di)) + SynapseTraces.Set(Neurons.Value(int(ri), int(di), int(RLRate))*pt.Learn.LRate.Eff*dwt, int(syni), int(DiDWt), int(di)) } // DWtSynRWPred computes the weight change (learning) at given synapse, @@ -231,10 +231,10 @@ func (pt *PathParams) DWtSynRWPred(ctx *Context, syni, si, ri, lpi, pi, di uint3 lr := pt.Learn.LRate.Eff eff_lr := lr if NeuronIxs.Value(int(ri), int(NrnNeurIndex)) == 0 { - if Neurons.Value(int(ri), int(Ge), int(di)) > Neurons.Value(int(ri), int(Act), int(di)) && da > 0 { // clipped at top, saturate up + if Neurons.Value(int(ri), int(di), int(Ge)) > Neurons.Value(int(ri), int(di), int(Act)) && da > 0 { // clipped at top, saturate up da = 0 } - if Neurons.Value(int(ri), int(Ge), int(di)) < Neurons.Value(int(ri), int(Act), int(di)) && da < 0 { // clipped at bottom, saturate down + if Neurons.Value(int(ri), int(di), int(Ge)) < Neurons.Value(int(ri), int(di), int(Act)) && da < 0 { // clipped at bottom, saturate down da = 0 } if da < 0 { @@ -242,10 +242,10 @@ func (pt *PathParams) DWtSynRWPred(ctx *Context, syni, si, ri, lpi, pi, di uint3 } } else { eff_lr = -eff_lr // negative case - if Neurons.Value(int(ri), int(Ge), int(di)) > Neurons.Value(int(ri), int(Act), int(di)) && da < 0 { // clipped at top, saturate up + if Neurons.Value(int(ri), int(di), int(Ge)) > Neurons.Value(int(ri), int(di), int(Act)) && da < 0 { // clipped at top, saturate up da = 0 } - if Neurons.Value(int(ri), int(Ge), int(di)) < Neurons.Value(int(ri), int(Act), int(di)) && da > 0 { // clipped at bottom, saturate down + if Neurons.Value(int(ri), int(di), int(Ge)) < Neurons.Value(int(ri), int(di), int(Act)) && da > 0 { // clipped at bottom, saturate down da = 0 } if da >= 0 { @@ -253,7 +253,7 @@ func (pt *PathParams) DWtSynRWPred(ctx *Context, syni, si, ri, lpi, pi, di uint3 } } - dwt := da * Neurons.Value(int(si), int(CaSpkP), int(di)) // no recv unit activation + dwt := da * Neurons.Value(int(si), int(di), int(CaSpkP)) // no recv unit activation SynapseTraces.Set(eff_lr*dwt, int(syni), int(DiDWt), int(di)) } @@ -277,7 +277,7 @@ func (pt *PathParams) DWtSynTDPred(ctx *Context, syni, si, ri, lpi, pi, di uint3 } } - dwt := da * Neurons.Value(int(si), int(SpkPrv), int(di)) // no recv unit activation, prior trial act + dwt := da * Neurons.Value(int(si), int(di), int(SpkPrv)) // no recv unit activation, prior trial act SynapseTraces.Set(eff_lr*dwt, int(syni), int(DiDWt), int(di)) } @@ -292,11 +292,11 @@ func (pt *PathParams) DWtSynVSMatrix(ctx *Context, syni, si, ri, lpi, pi, di uin SynapseTraces.Set(0.0, int(syni), int(DTr), int(di)) return } - rlr := Neurons.Value(int(ri), int(RLRate), int(di)) + rlr := Neurons.Value(int(ri), int(di), int(RLRate)) - rplus := Neurons.Value(int(ri), int(CaSpkP), int(di)) - rminus := Neurons.Value(int(ri), int(CaSpkD), int(di)) - sact := Neurons.Value(int(si), int(CaSpkD), int(di)) + rplus := Neurons.Value(int(ri), int(di), int(CaSpkP)) + rminus := Neurons.Value(int(ri), int(di), int(CaSpkD)) + sact := Neurons.Value(int(si), int(di), int(CaSpkD)) dtr := ach * (pt.Matrix.Delta * sact * (rplus - rminus)) if rminus > pt.Learn.Trace.LearnThr { // key: prevents learning if < threshold dtr += ach * (pt.Matrix.Credit * sact * rminus) @@ -322,7 +322,7 @@ func (pt *PathParams) DWtSynVSMatrix(ctx *Context, syni, si, ri, lpi, pi, di uin func (pt *PathParams) DWtSynDSMatrix(ctx *Context, syni, si, ri, lpi, pi, di uint32) { // note: rn.RLRate already has ACh * DA * (D1 vs. D2 sign reversal) factored in. - rlr := Neurons.Value(int(ri), int(RLRate), int(di)) + rlr := Neurons.Value(int(ri), int(di), int(RLRate)) if GlobalScalars.Value(int(GvHasRew), int(di)) > 0 { // US time -- use DA and current recv activity tr := SynapseTraces.Value(int(syni), int(Tr), int(di)) dwt := rlr * pt.Learn.LRate.Eff * tr @@ -330,10 +330,10 @@ func (pt *PathParams) DWtSynDSMatrix(ctx *Context, syni, si, ri, lpi, pi, di uin SynapseTraces.Set(0.0, int(syni), int(Tr), int(di)) SynapseTraces.Set(0.0, int(syni), int(DTr), int(di)) } else { - pfmod := pt.Matrix.BasePF + Neurons.Value(int(ri), int(GModSyn), int(di)) - rplus := Neurons.Value(int(ri), int(CaSpkP), int(di)) - rminus := Neurons.Value(int(ri), int(CaSpkD), int(di)) - sact := Neurons.Value(int(si), int(CaSpkD), int(di)) + pfmod := pt.Matrix.BasePF + Neurons.Value(int(ri), int(di), int(GModSyn)) + rplus := Neurons.Value(int(ri), int(di), int(CaSpkP)) + rminus := Neurons.Value(int(ri), int(di), int(CaSpkD)) + sact := Neurons.Value(int(si), int(di), int(CaSpkD)) dtr := rlr * (pt.Matrix.Delta * sact * (rplus - rminus)) if rminus > pt.Learn.Trace.LearnThr { // key: prevents learning if < threshold dtr += rlr * (pt.Matrix.Credit * pfmod * sact * rminus) @@ -346,14 +346,14 @@ func (pt *PathParams) DWtSynDSMatrix(ctx *Context, syni, si, ri, lpi, pi, di uin // DWtSynVSPatch computes the weight change (learning) at given synapse, // for the VSPatchPath type. func (pt *PathParams) DWtSynVSPatch(ctx *Context, syni, si, ri, lpi, pi, di uint32) { - ract := Neurons.Value(int(ri), int(SpkPrv), int(di)) // t-1 + ract := Neurons.Value(int(ri), int(di), int(SpkPrv)) // t-1 if ract < pt.Learn.Trace.LearnThr { ract = 0 } // note: rn.RLRate already has ACh * DA * (D1 vs. D2 sign reversal) factored in. // and also the logic that non-positive DA leads to weight decreases. - sact := Neurons.Value(int(si), int(SpkPrv), int(di)) // t-1 - dwt := Neurons.Value(int(ri), int(RLRate), int(di)) * pt.Learn.LRate.Eff * sact * ract + sact := Neurons.Value(int(si), int(di), int(SpkPrv)) // t-1 + dwt := Neurons.Value(int(ri), int(di), int(RLRate)) * pt.Learn.LRate.Eff * sact * ract SynapseTraces.Set(dwt, int(syni), int(DiDWt), int(di)) } diff --git a/axon/learn-path.goal b/axon/learn-path.goal index aea728d6..a37079f8 100644 --- a/axon/learn-path.goal +++ b/axon/learn-path.goal @@ -46,22 +46,22 @@ func (pt *PathParams) DWtSyn(ctx *Context, rlay *LayerParams, syni, si, ri, di u // SynCa gets the synaptic calcium P (potentiation) and D (depression) // values, using optimized computation. func (pt *PathParams) SynCa(ctx *Context, si, ri, di uint32, syCaP, syCaD *float32) { - rb0 := Neurons[ri, SpkBin0, di] - sb0 := Neurons[si, SpkBin0, di] - rb1 := Neurons[ri, SpkBin1, di] - sb1 := Neurons[si, SpkBin1, di] - rb2 := Neurons[ri, SpkBin2, di] - sb2 := Neurons[si, SpkBin2, di] - rb3 := Neurons[ri, SpkBin3, di] - sb3 := Neurons[si, SpkBin3, di] - rb4 := Neurons[ri, SpkBin4, di] - sb4 := Neurons[si, SpkBin4, di] - rb5 := Neurons[ri, SpkBin5, di] - sb5 := Neurons[si, SpkBin5, di] - rb6 := Neurons[ri, SpkBin6, di] - sb6 := Neurons[si, SpkBin6, di] - rb7 := Neurons[ri, SpkBin7, di] - sb7 := Neurons[si, SpkBin7, di] + rb0 := Neurons[ri, di, SpkBin0] + sb0 := Neurons[si, di, SpkBin0] + rb1 := Neurons[ri, di, SpkBin1] + sb1 := Neurons[si, di, SpkBin1] + rb2 := Neurons[ri, di, SpkBin2] + sb2 := Neurons[si, di, SpkBin2] + rb3 := Neurons[ri, di, SpkBin3] + sb3 := Neurons[si, di, SpkBin3] + rb4 := Neurons[ri, di, SpkBin4] + sb4 := Neurons[si, di, SpkBin4] + rb5 := Neurons[ri, di, SpkBin5] + sb5 := Neurons[si, di, SpkBin5] + rb6 := Neurons[ri, di, SpkBin6] + sb6 := Neurons[si, di, SpkBin6] + rb7 := Neurons[ri, di, SpkBin7] + sb7 := Neurons[si, di, SpkBin7] b0 := 0.1 * (rb0 * sb0) b1 := 0.1 * (rb1 * sb1) @@ -84,7 +84,7 @@ func (pt *PathParams) DWtSynCortex(ctx *Context, syni, si, ri, lpi, pi, di uint3 dtr := syCaD // delta trace, caD reflects entire window if pt.Type == CTCtxtPath { // layer 6 CT pathway - dtr = Neurons[si, BurstPrv, di] + dtr = Neurons[si, di, BurstPrv] } // save delta trace for GUI SynapseTraces[syni, DTr, di] = dtr @@ -102,7 +102,7 @@ func (pt *PathParams) DWtSynCortex(ctx *Context, syni, si, ri, lpi, pi, di uint3 if isTarget { err = syCaP - syCaD // for target layers, syn Ca drives error signal directly } else { - err = tr * (Neurons[ri, NrnCaP, di] - Neurons[ri, NrnCaD, di]) // hiddens: recv NMDA Ca drives error signal w/ trace credit + err = tr * (Neurons[ri, di, NrnCaP] - Neurons[ri, di, NrnCaD]) // hiddens: recv NMDA Ca drives error signal w/ trace credit } // note: trace ensures that nothing changes for inactive synapses.. // sb immediately -- enters into zero sum. @@ -116,7 +116,7 @@ func (pt *PathParams) DWtSynCortex(ctx *Context, syni, si, ri, lpi, pi, di uint3 if pt.Type == CTCtxtPath { // rn.RLRate IS needed for other pathways, just not the context one SynapseTraces[syni, DiDWt, di] = pt.Learn.LRate.Eff * err } else { - SynapseTraces[syni, DiDWt, di] = Neurons[ri, RLRate, di] * pt.Learn.LRate.Eff * err + SynapseTraces[syni, DiDWt, di] = Neurons[ri, di, RLRate] * pt.Learn.LRate.Eff * err } } @@ -124,11 +124,11 @@ func (pt *PathParams) DWtSynCortex(ctx *Context, syni, si, ri, lpi, pi, di uint3 // Uses synaptically integrated spiking, computed at the Theta cycle interval. // This is the trace version for hidden units, and uses syn CaP - CaD for targets. func (pt *PathParams) DWtSynHebb(ctx *Context, syni, si, ri, lpi, pi, di uint32) { - rNrnCaP := Neurons[ri, NrnCaP, di] - sNrnCap := Neurons[si, NrnCaP, di] + rNrnCaP := Neurons[ri, di, NrnCaP] + sNrnCap := Neurons[si, di, NrnCaP] lwt := Synapses[syni, LWt] // linear weight hebb := rNrnCaP * (pt.Learn.Hebb.Up*sNrnCap*(1-lwt) - pt.Learn.Hebb.Down*(1-sNrnCap)*lwt) - // not: Neurons[ri, RLRate, di]* + // not: Neurons[ri, di, RLRate]* SynapseTraces[syni, DiDWt, di] = pt.Learn.LRate.Eff * hebb } @@ -152,8 +152,8 @@ func (pt *PathParams) DWtSynHip(ctx *Context, syni, si, ri, lpi, pi, di uint32, } // error-driven learning part - rNrnCaP := Neurons[ri, NrnCaP, di] - rNrnCaD := Neurons[ri, NrnCaD, di] + rNrnCaP := Neurons[ri, di, NrnCaP] + rNrnCaD := Neurons[ri, di, NrnCaD] var err float32 if isTarget { err = syCaP - syCaD // for target layers, syn Ca drives error signal directly @@ -171,13 +171,13 @@ func (pt *PathParams) DWtSynHip(ctx *Context, syni, si, ri, lpi, pi, di uint32, } // hebbian-learning part - sNrnCap := Neurons[si, NrnCaP, di] + sNrnCap := Neurons[si, di, NrnCaP] savg := 0.5 + pt.Hip.SAvgCor*(pt.Hip.SNominal-0.5) savg = 0.5 / math32.Max(pt.Hip.SAvgThr, savg) // keep this Sending Average Correction term within bounds (SAvgThr) hebb := rNrnCaP * (sNrnCap*(savg-lwt) - (1-sNrnCap)*lwt) // setting delta weight (note: impossible to be CTCtxtPath) - dwt := Neurons[ri, RLRate, di] * pt.Learn.LRate.Eff * (pt.Hip.Hebb*hebb + pt.Hip.Err*err) + dwt := Neurons[ri, di, RLRate] * pt.Learn.LRate.Eff * (pt.Hip.Hebb*hebb + pt.Hip.Err*err) SynapseTraces[syni, DiDWt, di] = dwt } @@ -189,14 +189,14 @@ func (pt *PathParams) DWtSynBLA(ctx *Context, syni, si, ri, lpi, pi, di uint32) dwt := float32(0) ach := GlobalScalars[GvACh, di] if GlobalScalars[GvHasRew, di] > 0 { // learn and reset - ract := Neurons[ri, CaSpkD, di] + ract := Neurons[ri, di, CaSpkD] if ract < pt.Learn.Trace.LearnThr { ract = 0 } tr := SynapseTraces[syni, Tr, di] ustr := pt.BLA.USTrace - tr = ustr*Neurons[si, Burst, di] + (1.0-ustr)*tr - delta := Neurons[ri, CaSpkP, di] - Neurons[ri, SpkPrv, di] + tr = ustr*Neurons[si, di, Burst] + (1.0-ustr)*tr + delta := Neurons[ri, di, CaSpkP] - Neurons[ri, di, SpkPrv] if delta < 0 { // neg delta learns slower in Acq, not Ext delta *= pt.BLA.NegDeltaLRate } @@ -204,7 +204,7 @@ func (pt *PathParams) DWtSynBLA(ctx *Context, syni, si, ri, lpi, pi, di uint32) SynapseTraces[syni, Tr, di] = 0.0 } else if ach > pt.BLA.AChThr { // note: the former NonUSLRate parameter is not used -- Trace update Tau replaces it.. elegant - dtr := ach * Neurons[si, Burst, di] + dtr := ach * Neurons[si, di, Burst] SynapseTraces[syni, DTr, di] = dtr tr := pt.Learn.Trace.TrFromCa(SynapseTraces[syni, Tr, di], dtr) SynapseTraces[syni, Tr, di] = tr @@ -217,7 +217,7 @@ func (pt *PathParams) DWtSynBLA(ctx *Context, syni, si, ri, lpi, pi, di uint32) } else { dwt *= lwt } - SynapseTraces[syni, DiDWt, di] = Neurons[ri, RLRate, di] * pt.Learn.LRate.Eff * dwt + SynapseTraces[syni, DiDWt, di] = Neurons[ri, di, RLRate] * pt.Learn.LRate.Eff * dwt } // DWtSynRWPred computes the weight change (learning) at given synapse, @@ -229,10 +229,10 @@ func (pt *PathParams) DWtSynRWPred(ctx *Context, syni, si, ri, lpi, pi, di uint3 lr := pt.Learn.LRate.Eff eff_lr := lr if NeuronIxs[ri, NrnNeurIndex] == 0 { - if Neurons[ri, Ge, di] > Neurons[ri, Act, di] && da > 0 { // clipped at top, saturate up + if Neurons[ri, di, Ge] > Neurons[ri, di, Act] && da > 0 { // clipped at top, saturate up da = 0 } - if Neurons[ri, Ge, di] < Neurons[ri, Act, di] && da < 0 { // clipped at bottom, saturate down + if Neurons[ri, di, Ge] < Neurons[ri, di, Act] && da < 0 { // clipped at bottom, saturate down da = 0 } if da < 0 { @@ -240,10 +240,10 @@ func (pt *PathParams) DWtSynRWPred(ctx *Context, syni, si, ri, lpi, pi, di uint3 } } else { eff_lr = -eff_lr // negative case - if Neurons[ri, Ge, di] > Neurons[ri, Act, di] && da < 0 { // clipped at top, saturate up + if Neurons[ri, di, Ge] > Neurons[ri, di, Act] && da < 0 { // clipped at top, saturate up da = 0 } - if Neurons[ri, Ge, di] < Neurons[ri, Act, di] && da > 0 { // clipped at bottom, saturate down + if Neurons[ri, di, Ge] < Neurons[ri, di, Act] && da > 0 { // clipped at bottom, saturate down da = 0 } if da >= 0 { @@ -251,7 +251,7 @@ func (pt *PathParams) DWtSynRWPred(ctx *Context, syni, si, ri, lpi, pi, di uint3 } } - dwt := da * Neurons[si, CaSpkP, di] // no recv unit activation + dwt := da * Neurons[si, di, CaSpkP] // no recv unit activation SynapseTraces[syni, DiDWt, di] = eff_lr * dwt } @@ -275,7 +275,7 @@ func (pt *PathParams) DWtSynTDPred(ctx *Context, syni, si, ri, lpi, pi, di uint3 } } - dwt := da * Neurons[si, SpkPrv, di] // no recv unit activation, prior trial act + dwt := da * Neurons[si, di, SpkPrv] // no recv unit activation, prior trial act SynapseTraces[syni, DiDWt, di] = eff_lr * dwt } @@ -290,11 +290,11 @@ func (pt *PathParams) DWtSynVSMatrix(ctx *Context, syni, si, ri, lpi, pi, di uin SynapseTraces[syni, DTr, di] = 0.0 return } - rlr := Neurons[ri, RLRate, di] + rlr := Neurons[ri, di, RLRate] - rplus := Neurons[ri, CaSpkP, di] - rminus := Neurons[ri, CaSpkD, di] - sact := Neurons[si, CaSpkD, di] + rplus := Neurons[ri, di, CaSpkP] + rminus := Neurons[ri, di, CaSpkD] + sact := Neurons[si, di, CaSpkD] dtr := ach * (pt.Matrix.Delta * sact * (rplus - rminus)) if rminus > pt.Learn.Trace.LearnThr { // key: prevents learning if < threshold dtr += ach * (pt.Matrix.Credit * sact * rminus) @@ -320,7 +320,7 @@ func (pt *PathParams) DWtSynVSMatrix(ctx *Context, syni, si, ri, lpi, pi, di uin func (pt *PathParams) DWtSynDSMatrix(ctx *Context, syni, si, ri, lpi, pi, di uint32) { // note: rn.RLRate already has ACh * DA * (D1 vs. D2 sign reversal) factored in. - rlr := Neurons[ri, RLRate, di] + rlr := Neurons[ri, di, RLRate] if GlobalScalars[GvHasRew, di] > 0 { // US time -- use DA and current recv activity tr := SynapseTraces[syni, Tr, di] dwt := rlr * pt.Learn.LRate.Eff * tr @@ -328,10 +328,10 @@ func (pt *PathParams) DWtSynDSMatrix(ctx *Context, syni, si, ri, lpi, pi, di uin SynapseTraces[syni, Tr, di] = 0.0 SynapseTraces[syni, DTr, di] = 0.0 } else { - pfmod := pt.Matrix.BasePF + Neurons[ri, GModSyn, di] - rplus := Neurons[ri, CaSpkP, di] - rminus := Neurons[ri, CaSpkD, di] - sact := Neurons[si, CaSpkD, di] + pfmod := pt.Matrix.BasePF + Neurons[ri, di, GModSyn] + rplus := Neurons[ri, di, CaSpkP] + rminus := Neurons[ri, di, CaSpkD] + sact := Neurons[si, di, CaSpkD] dtr := rlr * (pt.Matrix.Delta * sact * (rplus - rminus)) if rminus > pt.Learn.Trace.LearnThr { // key: prevents learning if < threshold dtr += rlr * (pt.Matrix.Credit * pfmod * sact * rminus) @@ -344,14 +344,14 @@ func (pt *PathParams) DWtSynDSMatrix(ctx *Context, syni, si, ri, lpi, pi, di uin // DWtSynVSPatch computes the weight change (learning) at given synapse, // for the VSPatchPath type. func (pt *PathParams) DWtSynVSPatch(ctx *Context, syni, si, ri, lpi, pi, di uint32) { - ract := Neurons[ri, SpkPrv, di] // t-1 + ract := Neurons[ri, di, SpkPrv] // t-1 if ract < pt.Learn.Trace.LearnThr { ract = 0 } // note: rn.RLRate already has ACh * DA * (D1 vs. D2 sign reversal) factored in. // and also the logic that non-positive DA leads to weight decreases. - sact := Neurons[si, SpkPrv, di] // t-1 - dwt := Neurons[ri, RLRate, di] * pt.Learn.LRate.Eff * sact * ract + sact := Neurons[si, di, SpkPrv] // t-1 + dwt := Neurons[ri, di, RLRate] * pt.Learn.LRate.Eff * sact * ract SynapseTraces[syni, DiDWt, di] = dwt } diff --git a/axon/learn.go b/axon/learn.go index d09682ab..d4a81c91 100644 --- a/axon/learn.go +++ b/axon/learn.go @@ -75,9 +75,9 @@ func (np *CaLrnParams) Update() { // and performs time-integration of VgccCa func (np *CaLrnParams) VgccCaFromSpike(ctx *Context, ni, di uint32) { if np.SpkVGCC.IsTrue() { - Neurons.Set(np.SpkVgccCa*Neurons.Value(int(ni), int(Spike), int(di)), int(ni), int(VgccCa), int(di)) + Neurons.Set(np.SpkVgccCa*Neurons.Value(int(ni), int(di), int(Spike)), int(ni), int(di), int(VgccCa)) } - Neurons.SetAdd(Neurons.Value(int(ni), int(VgccCa), int(di))-np.VgccDt*Neurons.Value(int(ni), int(VgccCaInt), int(di)), int(ni), int(VgccCaInt), int(di)) + Neurons.SetAdd(Neurons.Value(int(ni), int(di), int(VgccCa))-np.VgccDt*Neurons.Value(int(ni), int(di), int(VgccCaInt)), int(ni), int(di), int(VgccCaInt)) // Dt only affects decay, not rise time } @@ -86,11 +86,11 @@ func (np *CaLrnParams) VgccCaFromSpike(ctx *Context, ni, di uint32) { // perform its time-integration. func (np *CaLrnParams) CaLrns(ctx *Context, ni, di uint32) { np.VgccCaFromSpike(ctx, ni, di) - Neurons.Set(np.NormInv*(Neurons.Value(int(ni), int(NmdaCa), int(di))+Neurons.Value(int(ni), int(VgccCaInt), int(di))), int(ni), int(CaLrn), int(di)) - Neurons.SetAdd(np.Dt.MDt*(Neurons.Value(int(ni), int(CaLrn), int(di))-Neurons.Value(int(ni), int(NrnCaM), int(di))), int(ni), int(NrnCaM), int(di)) - Neurons.SetAdd(np.Dt.PDt*(Neurons.Value(int(ni), int(NrnCaM), int(di))-Neurons.Value(int(ni), int(NrnCaP), int(di))), int(ni), int(NrnCaP), int(di)) - Neurons.SetAdd(np.Dt.DDt*(Neurons.Value(int(ni), int(NrnCaP), int(di))-Neurons.Value(int(ni), int(NrnCaD), int(di))), int(ni), int(NrnCaD), int(di)) - Neurons.Set(Neurons.Value(int(ni), int(NrnCaP), int(di))-Neurons.Value(int(ni), int(NrnCaD), int(di)), int(ni), int(CaDiff), int(di)) + Neurons.Set(np.NormInv*(Neurons.Value(int(ni), int(di), int(NmdaCa))+Neurons.Value(int(ni), int(di), int(VgccCaInt))), int(ni), int(di), int(CaLrn)) + Neurons.SetAdd(np.Dt.MDt*(Neurons.Value(int(ni), int(di), int(CaLrn))-Neurons.Value(int(ni), int(di), int(NrnCaM))), int(ni), int(di), int(NrnCaM)) + Neurons.SetAdd(np.Dt.PDt*(Neurons.Value(int(ni), int(di), int(NrnCaM))-Neurons.Value(int(ni), int(di), int(NrnCaP))), int(ni), int(di), int(NrnCaP)) + Neurons.SetAdd(np.Dt.DDt*(Neurons.Value(int(ni), int(di), int(NrnCaP))-Neurons.Value(int(ni), int(di), int(NrnCaD))), int(ni), int(di), int(NrnCaD)) + Neurons.Set(Neurons.Value(int(ni), int(di), int(NrnCaP))-Neurons.Value(int(ni), int(di), int(NrnCaD)), int(ni), int(di), int(CaDiff)) } ////////////////////////////////////////////////////////////////////////////////////// @@ -304,23 +304,23 @@ func (ln *LearnNeurParams) Defaults() { // InitCaLrnSpk initializes the neuron-level calcium learning and spking variables. // Called by InitWeights (at start of learning). func (ln *LearnNeurParams) InitNeurCa(ctx *Context, ni, di uint32) { - Neurons.Set(0, int(ni), int(GnmdaLrn), int(di)) - Neurons.Set(0, int(ni), int(NmdaCa), int(di)) + Neurons.Set(0, int(ni), int(di), int(GnmdaLrn)) + Neurons.Set(0, int(ni), int(di), int(NmdaCa)) - Neurons.Set(0, int(ni), int(VgccCa), int(di)) - Neurons.Set(0, int(ni), int(VgccCaInt), int(di)) + Neurons.Set(0, int(ni), int(di), int(VgccCa)) + Neurons.Set(0, int(ni), int(di), int(VgccCaInt)) - Neurons.Set(0, int(ni), int(CaLrn), int(di)) + Neurons.Set(0, int(ni), int(di), int(CaLrn)) - Neurons.Set(0, int(ni), int(CaSpkM), int(di)) - Neurons.Set(0, int(ni), int(CaSpkP), int(di)) - Neurons.Set(0, int(ni), int(CaSpkD), int(di)) - Neurons.Set(0, int(ni), int(CaSpkPM), int(di)) + Neurons.Set(0, int(ni), int(di), int(CaSpkM)) + Neurons.Set(0, int(ni), int(di), int(CaSpkP)) + Neurons.Set(0, int(ni), int(di), int(CaSpkD)) + Neurons.Set(0, int(ni), int(di), int(CaSpkPM)) - Neurons.Set(0, int(ni), int(NrnCaM), int(di)) - Neurons.Set(0, int(ni), int(NrnCaP), int(di)) - Neurons.Set(0, int(ni), int(NrnCaD), int(di)) - Neurons.Set(0, int(ni), int(CaDiff), int(di)) + Neurons.Set(0, int(ni), int(di), int(NrnCaM)) + Neurons.Set(0, int(ni), int(di), int(NrnCaP)) + Neurons.Set(0, int(ni), int(di), int(NrnCaD)) + Neurons.Set(0, int(ni), int(di), int(CaDiff)) } // LrnNMDAFromRaw updates the separate NMDA conductance and calcium values @@ -329,23 +329,23 @@ func (ln *LearnNeurParams) InitNeurCa(ctx *Context, ni, di uint32) { // for testing learning Ca effects independent of activation effects. func (ln *LearnNeurParams) LrnNMDAFromRaw(ctx *Context, ni, di uint32, geTot float32) { geEff := max(geTot, 0.0) - vmd := Neurons.Value(int(ni), int(VmDend), int(di)) - Neurons.Set(ln.LrnNMDA.NMDASyn(Neurons.Value(int(ni), int(GnmdaLrn), int(di)), geEff), int(ni), int(GnmdaLrn), int(di)) - gnmda := ln.LrnNMDA.Gnmda(Neurons.Value(int(ni), int(GnmdaLrn), int(di)), vmd) - Neurons.Set(float32(gnmda*ln.LrnNMDA.CaFromV(vmd)), int(ni), int(NmdaCa), int(di)) + vmd := Neurons.Value(int(ni), int(di), int(VmDend)) + Neurons.Set(ln.LrnNMDA.NMDASyn(Neurons.Value(int(ni), int(di), int(GnmdaLrn)), geEff), int(ni), int(di), int(GnmdaLrn)) + gnmda := ln.LrnNMDA.Gnmda(Neurons.Value(int(ni), int(di), int(GnmdaLrn)), vmd) + Neurons.Set(float32(gnmda*ln.LrnNMDA.CaFromV(vmd)), int(ni), int(di), int(NmdaCa)) } // CaFromSpike updates all spike-driven calcium variables, including CaLrn and CaSpk. // Computed after new activation for current cycle is updated. func (ln *LearnNeurParams) CaFromSpike(ctx *Context, ni, di uint32) { var caSyn float32 - caSpkM := Neurons.Value(int(ni), int(CaSpkM), int(di)) - caSpkP := Neurons.Value(int(ni), int(CaSpkP), int(di)) - caSpkD := Neurons.Value(int(ni), int(CaSpkD), int(di)) - ln.CaSpk.CaFromSpike(Neurons.Value(int(ni), int(Spike), int(di)), &caSyn, &caSpkM, &caSpkP, &caSpkD) - Neurons.Set(caSpkM, int(ni), int(CaSpkM), int(di)) - Neurons.Set(caSpkP, int(ni), int(CaSpkP), int(di)) - Neurons.Set(caSpkD, int(ni), int(CaSpkD), int(di)) + caSpkM := Neurons.Value(int(ni), int(di), int(CaSpkM)) + caSpkP := Neurons.Value(int(ni), int(di), int(CaSpkP)) + caSpkD := Neurons.Value(int(ni), int(di), int(CaSpkD)) + ln.CaSpk.CaFromSpike(Neurons.Value(int(ni), int(di), int(Spike)), &caSyn, &caSpkM, &caSpkP, &caSpkD) + Neurons.Set(caSpkM, int(ni), int(di), int(CaSpkM)) + Neurons.Set(caSpkP, int(ni), int(di), int(CaSpkP)) + Neurons.Set(caSpkD, int(ni), int(di), int(CaSpkD)) ln.CaLearn.CaLrns(ctx, ni, di) } diff --git a/axon/learn.goal b/axon/learn.goal index ca5ad5f1..7da47ee0 100644 --- a/axon/learn.goal +++ b/axon/learn.goal @@ -73,9 +73,9 @@ func (np *CaLrnParams) Update() { // and performs time-integration of VgccCa func (np *CaLrnParams) VgccCaFromSpike(ctx *Context, ni, di uint32) { if np.SpkVGCC.IsTrue() { - Neurons[ni, VgccCa, di] = np.SpkVgccCa * Neurons[ni, Spike, di] + Neurons[ni, di, VgccCa] = np.SpkVgccCa * Neurons[ni, di, Spike] } - Neurons[ni, VgccCaInt, di] += Neurons[ni, VgccCa, di] - np.VgccDt*Neurons[ni, VgccCaInt, di] + Neurons[ni, di, VgccCaInt] += Neurons[ni, di, VgccCa] - np.VgccDt*Neurons[ni, di, VgccCaInt] // Dt only affects decay, not rise time } @@ -84,11 +84,11 @@ func (np *CaLrnParams) VgccCaFromSpike(ctx *Context, ni, di uint32) { // perform its time-integration. func (np *CaLrnParams) CaLrns(ctx *Context, ni, di uint32) { np.VgccCaFromSpike(ctx, ni, di) - Neurons[ni, CaLrn, di] = np.NormInv * (Neurons[ni, NmdaCa, di] + Neurons[ni, VgccCaInt, di]) - Neurons[ni, NrnCaM, di] += np.Dt.MDt * (Neurons[ni, CaLrn, di] - Neurons[ni, NrnCaM, di]) - Neurons[ni, NrnCaP, di] += np.Dt.PDt * (Neurons[ni, NrnCaM, di] - Neurons[ni, NrnCaP, di]) - Neurons[ni, NrnCaD, di] += np.Dt.DDt * (Neurons[ni, NrnCaP, di] - Neurons[ni, NrnCaD, di]) - Neurons[ni, CaDiff, di] = Neurons[ni, NrnCaP, di] - Neurons[ni, NrnCaD, di] + Neurons[ni, di, CaLrn] = np.NormInv * (Neurons[ni, di, NmdaCa] + Neurons[ni, di, VgccCaInt]) + Neurons[ni, di, NrnCaM] += np.Dt.MDt * (Neurons[ni, di, CaLrn] - Neurons[ni, di, NrnCaM]) + Neurons[ni, di, NrnCaP] += np.Dt.PDt * (Neurons[ni, di, NrnCaM] - Neurons[ni, di, NrnCaP]) + Neurons[ni, di, NrnCaD] += np.Dt.DDt * (Neurons[ni, di, NrnCaP] - Neurons[ni, di, NrnCaD]) + Neurons[ni, di, CaDiff] = Neurons[ni, di, NrnCaP] - Neurons[ni, di, NrnCaD] } ////////////////////////////////////////////////////////////////////////////////////// @@ -302,23 +302,23 @@ func (ln *LearnNeurParams) Defaults() { // InitCaLrnSpk initializes the neuron-level calcium learning and spking variables. // Called by InitWeights (at start of learning). func (ln *LearnNeurParams) InitNeurCa(ctx *Context, ni, di uint32) { - Neurons[ni, GnmdaLrn, di] = 0 - Neurons[ni, NmdaCa, di] = 0 + Neurons[ni, di, GnmdaLrn] = 0 + Neurons[ni, di, NmdaCa] = 0 - Neurons[ni, VgccCa, di] = 0 - Neurons[ni, VgccCaInt, di] = 0 + Neurons[ni, di, VgccCa] = 0 + Neurons[ni, di, VgccCaInt] = 0 - Neurons[ni, CaLrn, di] = 0 + Neurons[ni, di, CaLrn] = 0 - Neurons[ni, CaSpkM, di] = 0 - Neurons[ni, CaSpkP, di] = 0 - Neurons[ni, CaSpkD, di] = 0 - Neurons[ni, CaSpkPM, di] = 0 + Neurons[ni, di, CaSpkM] = 0 + Neurons[ni, di, CaSpkP] = 0 + Neurons[ni, di, CaSpkD] = 0 + Neurons[ni, di, CaSpkPM] = 0 - Neurons[ni, NrnCaM, di] = 0 - Neurons[ni, NrnCaP, di] = 0 - Neurons[ni, NrnCaD, di] = 0 - Neurons[ni, CaDiff, di] = 0 + Neurons[ni, di, NrnCaM] = 0 + Neurons[ni, di, NrnCaP] = 0 + Neurons[ni, di, NrnCaD] = 0 + Neurons[ni, di, CaDiff] = 0 } // LrnNMDAFromRaw updates the separate NMDA conductance and calcium values @@ -327,23 +327,23 @@ func (ln *LearnNeurParams) InitNeurCa(ctx *Context, ni, di uint32) { // for testing learning Ca effects independent of activation effects. func (ln *LearnNeurParams) LrnNMDAFromRaw(ctx *Context, ni, di uint32, geTot float32) { geEff := max(geTot, 0.0) - vmd := Neurons[ni, VmDend, di] - Neurons[ni, GnmdaLrn, di] = ln.LrnNMDA.NMDASyn(Neurons[ni, GnmdaLrn, di], geEff) - gnmda := ln.LrnNMDA.Gnmda(Neurons[ni, GnmdaLrn, di], vmd) - Neurons[ni, NmdaCa, di] = float32(gnmda * ln.LrnNMDA.CaFromV(vmd)) + vmd := Neurons[ni, di, VmDend] + Neurons[ni, di, GnmdaLrn] = ln.LrnNMDA.NMDASyn(Neurons[ni, di, GnmdaLrn], geEff) + gnmda := ln.LrnNMDA.Gnmda(Neurons[ni, di, GnmdaLrn], vmd) + Neurons[ni, di, NmdaCa] = float32(gnmda * ln.LrnNMDA.CaFromV(vmd)) } // CaFromSpike updates all spike-driven calcium variables, including CaLrn and CaSpk. // Computed after new activation for current cycle is updated. func (ln *LearnNeurParams) CaFromSpike(ctx *Context, ni, di uint32) { var caSyn float32 - caSpkM := Neurons[ni, CaSpkM, di] - caSpkP := Neurons[ni, CaSpkP, di] - caSpkD := Neurons[ni, CaSpkD, di] - ln.CaSpk.CaFromSpike(Neurons[ni, Spike, di], &caSyn, &caSpkM, &caSpkP, &caSpkD) - Neurons[ni, CaSpkM, di] = caSpkM - Neurons[ni, CaSpkP, di] = caSpkP - Neurons[ni, CaSpkD, di] = caSpkD + caSpkM := Neurons[ni, di, CaSpkM] + caSpkP := Neurons[ni, di, CaSpkP] + caSpkD := Neurons[ni, di, CaSpkD] + ln.CaSpk.CaFromSpike(Neurons[ni, di, Spike], &caSyn, &caSpkM, &caSpkP, &caSpkD) + Neurons[ni, di, CaSpkM] = caSpkM + Neurons[ni, di, CaSpkP] = caSpkP + Neurons[ni, di, CaSpkD] = caSpkD ln.CaLearn.CaLrns(ctx, ni, di) } diff --git a/axon/network.go b/axon/network.go index c9594c97..57efde0b 100644 --- a/axon/network.go +++ b/axon/network.go @@ -742,7 +742,7 @@ func (nt *Network) Build() error { //types:add 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.Neurons, totNeurons, int(NeuronVarsN), maxData) + sltensor.SetShapeSizes(&nt.Neurons, totNeurons, maxData, int(NeuronVarsN)) sltensor.SetShapeSizes(&nt.NeuronAvgs, totNeurons, int(NeuronAvgVarsN)) sltensor.SetShapeSizes(&nt.NeuronIxs, totNeurons, int(NeuronIndexVarsN)) nt.Paths = make([]*Path, totPaths) @@ -1225,8 +1225,8 @@ func (nt *Network) DiffFrom(ctx *Context, on *Network, maxDiff int) string { for di := uint32(0); di < ctx.NData; di++ { for ni := uint32(0); ni < nix.NNeurons; ni++ { for nvar := Spike; nvar < NeuronVarsN; nvar++ { - nv := nt.Neurons.Value(int(ni), int(nvar), int(di)) - ov := on.Neurons.Value(int(ni), int(nvar), int(di)) + nv := nt.Neurons.Value(int(ni), int(di), int(nvar)) + ov := on.Neurons.Value(int(ni), int(di), int(nvar)) if nv != ov { diffs += fmt.Sprintf("Neuron: di: %d\tni: %d\tvar: %s\tval: %g\toth: %g\n", di, ni, nvar.String(), nv, ov) ndif++ diff --git a/axon/network.goal b/axon/network.goal index 692adb54..2b031899 100644 --- a/axon/network.goal +++ b/axon/network.goal @@ -739,7 +739,7 @@ func (nt *Network) Build() error { //types:add 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.Neurons, totNeurons, int(NeuronVarsN), maxData) + sltensor.SetShapeSizes(&nt.Neurons, totNeurons, maxData, int(NeuronVarsN)) sltensor.SetShapeSizes(&nt.NeuronAvgs, totNeurons, int(NeuronAvgVarsN)) sltensor.SetShapeSizes(&nt.NeuronIxs, totNeurons, int(NeuronIndexVarsN)) nt.Paths = make([]*Path, totPaths) @@ -1221,8 +1221,8 @@ func (nt *Network) DiffFrom(ctx *Context, on *Network, maxDiff int) string { for di := uint32(0); di < ctx.NData; di++ { for ni := uint32(0); ni < nix.NNeurons; ni++ { for nvar := Spike; nvar < NeuronVarsN; nvar++ { - nv := nt.Neurons[ni, nvar, di] - ov := on.Neurons[ni, nvar, di] + nv := nt.Neurons[ni, di, nvar] + ov := on.Neurons[ni, di, nvar] if nv != ov { diffs += fmt.Sprintf("Neuron: di: %d\tni: %d\tvar: %s\tval: %g\toth: %g\n", di, ni, nvar.String(), nv, ov) ndif++ diff --git a/axon/pool.go b/axon/pool.go index c5b7ea90..13f825b2 100644 --- a/axon/pool.go +++ b/axon/pool.go @@ -193,12 +193,12 @@ func PoolAvgMaxUpdateVar(vr AvgMaxVars, pi, di uint32, val float32) { // PoolAvgMaxUpdate updates the AvgMax values based on current neuron values. // pi = global pool index. func PoolAvgMaxUpdate(pi, di, ni uint32) { - PoolAvgMaxUpdateVar(AMCaSpkP, pi, di, math32.Abs(Neurons.Value(int(ni), int(avgMaxToNeuron[AMCaSpkP]), int(di)))) - PoolAvgMaxUpdateVar(AMCaSpkD, pi, di, math32.Abs(Neurons.Value(int(ni), int(avgMaxToNeuron[AMCaSpkD]), int(di)))) - PoolAvgMaxUpdateVar(AMSpkMax, pi, di, math32.Abs(Neurons.Value(int(ni), int(avgMaxToNeuron[AMSpkMax]), int(di)))) - PoolAvgMaxUpdateVar(AMAct, pi, di, math32.Abs(Neurons.Value(int(ni), int(avgMaxToNeuron[AMAct]), int(di)))) - PoolAvgMaxUpdateVar(AMGeInt, pi, di, math32.Abs(Neurons.Value(int(ni), int(avgMaxToNeuron[AMGeInt]), int(di)))) - PoolAvgMaxUpdateVar(AMGiInt, pi, di, math32.Abs(Neurons.Value(int(ni), int(avgMaxToNeuron[AMGiInt]), int(di)))) + PoolAvgMaxUpdateVar(AMCaSpkP, pi, di, math32.Abs(Neurons.Value(int(ni), int(di), int(avgMaxToNeuron[AMCaSpkP])))) + PoolAvgMaxUpdateVar(AMCaSpkD, pi, di, math32.Abs(Neurons.Value(int(ni), int(di), int(avgMaxToNeuron[AMCaSpkD])))) + PoolAvgMaxUpdateVar(AMSpkMax, pi, di, math32.Abs(Neurons.Value(int(ni), int(di), int(avgMaxToNeuron[AMSpkMax])))) + PoolAvgMaxUpdateVar(AMAct, pi, di, math32.Abs(Neurons.Value(int(ni), int(di), int(avgMaxToNeuron[AMAct])))) + PoolAvgMaxUpdateVar(AMGeInt, pi, di, math32.Abs(Neurons.Value(int(ni), int(di), int(avgMaxToNeuron[AMGeInt])))) + PoolAvgMaxUpdateVar(AMGiInt, pi, di, math32.Abs(Neurons.Value(int(ni), int(di), int(avgMaxToNeuron[AMGiInt])))) } // PoolAvgMaxCalcVar does Calc on Cycle level, and re-inits, for given Var diff --git a/axon/pool.goal b/axon/pool.goal index 8384185f..fca549f8 100644 --- a/axon/pool.goal +++ b/axon/pool.goal @@ -191,12 +191,12 @@ func PoolAvgMaxUpdateVar(vr AvgMaxVars, pi, di uint32, val float32) { // PoolAvgMaxUpdate updates the AvgMax values based on current neuron values. // pi = global pool index. func PoolAvgMaxUpdate(pi, di, ni uint32) { - PoolAvgMaxUpdateVar(AMCaSpkP, pi, di, math32.Abs(Neurons[ni, avgMaxToNeuron[AMCaSpkP], di])) - PoolAvgMaxUpdateVar(AMCaSpkD, pi, di, math32.Abs(Neurons[ni, avgMaxToNeuron[AMCaSpkD], di])) - PoolAvgMaxUpdateVar(AMSpkMax, pi, di, math32.Abs(Neurons[ni, avgMaxToNeuron[AMSpkMax], di])) - PoolAvgMaxUpdateVar(AMAct, pi, di, math32.Abs(Neurons[ni, avgMaxToNeuron[AMAct], di])) - PoolAvgMaxUpdateVar(AMGeInt, pi, di, math32.Abs(Neurons[ni, avgMaxToNeuron[AMGeInt], di])) - PoolAvgMaxUpdateVar(AMGiInt, pi, di, math32.Abs(Neurons[ni, avgMaxToNeuron[AMGiInt], di])) + PoolAvgMaxUpdateVar(AMCaSpkP, pi, di, math32.Abs(Neurons[ni, di, avgMaxToNeuron[AMCaSpkP]])) + PoolAvgMaxUpdateVar(AMCaSpkD, pi, di, math32.Abs(Neurons[ni, di, avgMaxToNeuron[AMCaSpkD]])) + PoolAvgMaxUpdateVar(AMSpkMax, pi, di, math32.Abs(Neurons[ni, di, avgMaxToNeuron[AMSpkMax]])) + PoolAvgMaxUpdateVar(AMAct, pi, di, math32.Abs(Neurons[ni, di, avgMaxToNeuron[AMAct]])) + PoolAvgMaxUpdateVar(AMGeInt, pi, di, math32.Abs(Neurons[ni, di, avgMaxToNeuron[AMGeInt]])) + PoolAvgMaxUpdateVar(AMGiInt, pi, di, math32.Abs(Neurons[ni, di, avgMaxToNeuron[AMGiInt]])) } // PoolAvgMaxCalcVar does Calc on Cycle level, and re-inits, for given Var diff --git a/axon/shaders/ApplyExtsNeuron.wgsl b/axon/shaders/ApplyExtsNeuron.wgsl index 1c6c9de1..ced87742 100644 --- a/axon/shaders/ApplyExtsNeuron.wgsl +++ b/axon/shaders/ApplyExtsNeuron.wgsl @@ -99,8 +99,8 @@ fn LayerParams_ApplyExtFlags(ly: ptr, clearMask: ptr, ni: u32,di: u32) { - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Ext),u32(di))] = 0.0; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Target),u32(di))] = 0.0; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Ext))] = 0.0; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Target))] = 0.0; NeuronClearFlag(NeuronHasExt|NeuronHasTarg|NeuronHasCmpr, ni, di); } fn LayerParams_ApplyExtValue(ly: ptr, ni: u32,di: u32, val: f32) { @@ -112,9 +112,9 @@ fn LayerParams_ApplyExtValue(ly: ptr, ni: u32,di: u32, val var toTarg: bool; LayerParams_ApplyExtFlags(ly, &clearMask, &setMask, &toTarg); if (toTarg) { - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Target),u32(di))] = val; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Target))] = val; } else { - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Ext),u32(di))] = val; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Ext))] = val; } NeuronClearFlag(clearMask, ni, di); NeuronSetFlag(setMask, ni, di); @@ -160,10 +160,10 @@ struct PathScaleParams { ///////////// import: "act.go" fn NeuronSetFlag(flag: NeuronFlags, ni: u32,di: u32) { - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(NeurFlags),u32(di))] = bitcast(bitcast(Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(NeurFlags),u32(di))]) | u32(flag)); + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(NeurFlags))] = bitcast(bitcast(Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(NeurFlags))]) | u32(flag)); } fn NeuronClearFlag(flag: NeuronFlags, ni: u32,di: u32) { - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(NeurFlags),u32(di))] = bitcast(bitcast(Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(NeurFlags),u32(di))]) & ~ u32(flag)); + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(NeurFlags))] = bitcast(bitcast(Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(NeurFlags))]) & ~ u32(flag)); } struct SpikeParams { Thr: f32, diff --git a/axon/shaders/CycleNeuron.wgsl b/axon/shaders/CycleNeuron.wgsl index eb84dbba..589fa180 100644 --- a/axon/shaders/CycleNeuron.wgsl +++ b/axon/shaders/CycleNeuron.wgsl @@ -84,15 +84,15 @@ fn IndexI323D(s0: i32, s1: i32, s2: i32, i0: u32, i1: u32, i2: u32) -> u32 { fn SetNeuronExtPosNeg(ctx: ptr, ni: u32,di: u32, val: f32) { if (ni == 0) { if (val >= 0) { - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Ext),u32(di))] = val; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Ext))] = val; } else { - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Ext),u32(di))] = f32(0); + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Ext))] = f32(0); } } else { if (val >= 0) { - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Ext),u32(di))] = f32(0); + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Ext))] = f32(0); } else { - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Ext),u32(di))] = -val; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Ext))] = -val; } } } @@ -108,7 +108,7 @@ fn LayerParams_PulvinarDriver(ly: ptr, ctx: ptr, ctx: ptr, pi: u32,ni: u32,di: u32) { @@ -116,7 +116,7 @@ fn LayerParams_GInteg(ly: ptr, ctx: ptr, var nonDrivePct = f32(0); if ((*ly).Type == PulvinarLayer) { LayerParams_PulvinarDriver(ly, ctx, ni-(*ly).Indexes.NeurSt, di, &drvGe, &nonDrivePct); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Ext),u32(di))] = nonDrivePct; // use for regulating inhibition + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Ext))] = nonDrivePct; // use for regulating inhibition } var saveVal = LayerParams_SpecialPreGs(ly, ctx, pi, ni, di, drvGe, nonDrivePct); LayerParams_GFromRawSyn(ly, ctx, ni, di); @@ -129,33 +129,33 @@ fn LayerParams_SpecialPreGs(ly: ptr, ctx: ptr 0; switch ((*ly).Type) { case PTPredLayer, CTLayer: { var geCtxt = (*ly).CT.GeGain * nrnCtxtGe; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeRaw),u32(di))] += geCtxt; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeRaw))] += geCtxt; if ((*ly).CT.DecayDt > 0) { - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(CtxtGe),u32(di))] -= (*ly).CT.DecayDt * nrnCtxtGe; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(CtxtGe))] -= (*ly).CT.DecayDt * nrnCtxtGe; } var ctxExt = DtParams_GeSynFromRawSteady(&(*ly).Acts.Dt, geCtxt); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeSyn),u32(di))] += ctxExt; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeSyn))] += ctxExt; saveVal = ctxExt; } // used In PostGs to set nrn.GeExt case PTMaintLayer: { if ((*ly).Acts.SMaint.On == 1) { saveVal = (*ly).Acts.SMaint.Inhib * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[ // used In PostGs to set nrn.GeExt - 2], u32(ni),u32(GMaintRaw),u32(di))]; + 2], u32(ni),u32(di),u32(GMaintRaw))]; } } case PulvinarLayer: { if ((*ctx).PlusPhase == 0) { break; } - saveVal = nonDrivePct*Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeSyn),u32(di))] + DtParams_GeSynFromRawSteady(&(*ly).Acts.Dt, drvGe); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeRaw),u32(di))] = nonDrivePct*nrnGeRaw + drvGe; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeSyn),u32(di))] = saveVal; + saveVal = nonDrivePct*Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeSyn))] + DtParams_GeSynFromRawSteady(&(*ly).Acts.Dt, drvGe); + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeRaw))] = nonDrivePct*nrnGeRaw + drvGe; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeSyn))] = saveVal; } case VSGatedLayer: { var dr = f32(0); @@ -165,17 +165,17 @@ fn LayerParams_SpecialPreGs(ly: ptr, ctx: ptr, ctx: ptr, ctx: ptr 0) { geRaw = PopCodeParams_EncodeGe(&(*ly).Acts.PopCode, pni, pnn, dr); } - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeRaw),u32(di))] = geRaw; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeSyn),u32(di))] = DtParams_GeSynFromRawSteady(&(*ly).Acts.Dt, geRaw); + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeRaw))] = geRaw; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeSyn))] = DtParams_GeSynFromRawSteady(&(*ly).Acts.Dt, geRaw); } case UrgencyLayer: { var ur = GlobalScalars[IndexF322D(GlobalScalars[0], GlobalScalars[1], u32(GvUrgency),u32(di))]; @@ -204,8 +204,8 @@ fn LayerParams_SpecialPreGs(ly: ptr, ctx: ptr 0) { geRaw = PopCodeParams_EncodeGe(&(*ly).Acts.PopCode, pni, pnn, ur); } - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeRaw),u32(di))] = geRaw; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeSyn),u32(di))] = DtParams_GeSynFromRawSteady(&(*ly).Acts.Dt, geRaw); + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeRaw))] = geRaw; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeSyn))] = DtParams_GeSynFromRawSteady(&(*ly).Acts.Dt, geRaw); } case USLayer: { var us = RubiconUSStimValue(di, pil-1, (*ly).Learn.NeuroMod.Valence); @@ -214,8 +214,8 @@ fn LayerParams_SpecialPreGs(ly: ptr, ctx: ptr, ctx: ptr, ctx: ptr, ctx: ptr, ctx: ptr, ni: u32,di: u32, saveVal: f32) { switch ((*ly).Type) { case PulvinarLayer, PTMaintLayer, CTLayer, BLALayer: { - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeExt),u32(di))] = saveVal; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeExt))] = saveVal; } case PTPredLayer: { - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeExt),u32(di))] = saveVal; - var orig = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(CtxtGeOrig),u32(di))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeExt))] = saveVal; + var orig = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(CtxtGeOrig))]; if (orig < 0.05) { - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Ge),u32(di))] = 0.0; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Ge))] = 0.0; } } default: { @@ -283,8 +283,8 @@ fn LayerParams_SpecialPostGs(ly: ptr, ctx: ptr, ctx: ptr, ni: u32,di: u32) { var extraRaw = f32(0); var extraSyn = f32(0); - var nrnGModRaw = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GModRaw),u32(di))]; - var nrnGModSyn = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GModSyn),u32(di))]; + var nrnGModRaw = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GModRaw))]; + var nrnGModSyn = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GModSyn))]; var ach = GlobalScalars[IndexF322D(GlobalScalars[0], GlobalScalars[1], u32(GvACh),u32(di))]; switch ((*ly).Type) { case PTMaintLayer: { @@ -293,8 +293,8 @@ fn LayerParams_GFromRawSyn(ly: ptr, ctx: ptr, ctx: ptr 1) { md = f32(1); } - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeRaw),u32(di))] *= md; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeSyn),u32(di))] *= md; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeRaw))] *= md; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeSyn))] *= md; } } } - var geRaw = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeRaw),u32(di))]; - var geSyn = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeSyn),u32(di))]; + var geRaw = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeRaw))]; + var geSyn = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeSyn))]; ActParams_NMDAFromRaw(&(*ly).Acts, ctx, ni, di, geRaw+extraRaw); ActParams_MaintNMDAFromRaw(&(*ly).Acts, ctx, ni, di); // uses GMaintRaw directly LearnNeurParams_LrnNMDAFromRaw(&(*ly).Learn, ctx, ni, di, geRaw); ActParams_GvgccFromVm(&(*ly).Acts, ctx, ni, di); - var ege = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Gnmda),u32(di))] + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GnmdaMaint),u32(di))] + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Gvgcc),u32(di))] + extraSyn; + var ege = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Gnmda))] + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GnmdaMaint))] + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Gvgcc))] + extraSyn; ActParams_GeFromSyn(&(*ly).Acts, ctx, ni, di, geSyn, ege); // sets nrn.GeExt too ActParams_GkFromVm(&(*ly).Acts, ctx, ni, di); ActParams_GSkCaFromCa(&(*ly).Acts, ctx, ni, di); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GiSyn),u32(di))] = ActParams_GiFromSyn(&(*ly).Acts, ctx, ni, di, Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GiSyn),u32(di))]); + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GiSyn))] = ActParams_GiFromSyn(&(*ly).Acts, ctx, ni, di, Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GiSyn))]); } fn LayerParams_GiInteg(ly: 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(GiSyn),u32(di))] + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GiNoise),u32(di))] + NeuroModParams_GiFromACh(&(*ly).Learn.NeuroMod, GlobalScalars[IndexF322D(GlobalScalars[0], GlobalScalars[1], u32(GvACh),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))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Gi),u32(di))] = gi; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(SSGiDend),u32(di))] = 0.0; + 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) { var ext = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[ // nonDrivePct - 2], u32(ni),u32(Ext),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(SSGiDend),u32(di))] = ext * (*ly).Acts.Dend.SSGi * ssgi; + 2], u32(ni),u32(di),u32(Ext))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(SSGiDend))] = ext * (*ly).Acts.Dend.SSGi * ssgi; } else { if (!((*ly).Acts.Clamp.IsInput == 1 || (*ly).Acts.Clamp.IsTarget == 1)) { - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(SSGiDend),u32(di))] = (*ly).Acts.Dend.SSGi * ssgi; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(SSGiDend))] = (*ly).Acts.Dend.SSGi * ssgi; } } - var vm = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(VmDend),u32(di))]; - var nrnGABAB = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GABAB),u32(di))]; - var nrnGABABx = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GABABx),u32(di))]; + var vm = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(VmDend))]; + var nrnGABAB = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GABAB))]; + var nrnGABABx = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GABABx))]; GABABParams_GABAB(&(*ly).Acts.GabaB, gi, &nrnGABAB, &nrnGABABx); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GABAB),u32(di))] = nrnGABAB; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GABABx),u32(di))] = nrnGABABx; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GABAB))] = nrnGABAB; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GABABx))] = nrnGABABx; var nrnGgabaB = GABABParams_GgabaB(&(*ly).Acts.GabaB, nrnGABAB, vm); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GgabaB),u32(di))] = nrnGgabaB; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Gk),u32(di))] += nrnGgabaB; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GgabaB))] = nrnGgabaB; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Gk))] += nrnGgabaB; } fn LayerParams_GNeuroMod(ly: ptr, ctx: ptr, ni: u32,di: u32) { var ggain = NeuroModParams_GGain(&(*ly).Learn.NeuroMod, GlobalScalars[IndexF322D(GlobalScalars[0], GlobalScalars[1], u32(GvDA),u32(di))] + GlobalScalars[IndexF322D(GlobalScalars[0], GlobalScalars[1], u32(GvDAtonic),u32(di))]); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Ge),u32(di))] *= ggain; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Gi),u32(di))] *= ggain; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Ge))] *= ggain; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Gi))] *= ggain; } fn LayerParams_SpikeFromG(ly: ptr, ctx: ptr, lpi: u32,ni: u32,di: u32) { ActParams_VmFromG(&(*ly).Acts, ctx, ni, di); @@ -366,22 +366,22 @@ fn LayerParams_SpikeFromG(ly: ptr, ctx: ptr 0) { - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeIntNorm),u32(di))] = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeInt),u32(di))] / lmax; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeIntNorm))] = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeInt))] / lmax; } else { - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeIntNorm),u32(di))] = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeInt),u32(di))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeIntNorm))] = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeInt))]; } if ((*ctx).Cycle >= (*ly).Acts.Dt.MaxCycStart) { - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(SpkMaxCa),u32(di))] += (*ly).Learn.CaSpk.Dt.PDt * (Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(CaSpkM),u32(di))] - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(SpkMaxCa),u32(di))]); - var spkmax = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(SpkMaxCa),u32(di))]; - if (spkmax > Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(SpkMax),u32(di))]) { - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(SpkMax),u32(di))] = spkmax; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(SpkMaxCa))] += (*ly).Learn.CaSpk.Dt.PDt * (Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(CaSpkM))] - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(SpkMaxCa))]); + var spkmax = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(SpkMaxCa))]; + if (spkmax > Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(SpkMax))]) { + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(SpkMax))] = spkmax; } } - var spk = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Spike),u32(di))]; + var spk = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Spike))]; if (spk > 0) { var spksper = (*ctx).ThetaCycles / 8; var bin = min((*ctx).Cycle/spksper, 7); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(SpkBin0 + NeuronVars(bin)),u32(di))] += spk; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(SpkBin0 + NeuronVars(bin)))] += spk; } } @@ -417,10 +417,10 @@ struct PathScaleParams { ///////////// import: "act.go" fn NeuronHasFlag(flag: NeuronFlags, ni: u32,di: u32) -> bool { - return (NeuronFlags(bitcast(Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(NeurFlags),u32(di))])) & flag) > 0; // weird: != 0 does NOT work on GPU + return (NeuronFlags(bitcast(Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(NeurFlags))])) & flag) > 0; // weird: != 0 does NOT work on GPU } fn NeuronSetFlag(flag: NeuronFlags, ni: u32,di: u32) { - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(NeurFlags),u32(di))] = bitcast(bitcast(Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(NeurFlags),u32(di))]) | u32(flag)); + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(NeurFlags))] = bitcast(bitcast(Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(NeurFlags))]) | u32(flag)); } struct SpikeParams { Thr: f32, @@ -634,8 +634,8 @@ fn ActParams_NMDAFromRaw(ac: ptr, ctx: ptr return; } var geT = max(geTot, 0.0); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GnmdaSyn),u32(di))] = NMDAParams_NMDASyn(&(*ac).NMDA, Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GnmdaSyn),u32(di))], geT); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Gnmda),u32(di))] = NMDAParams_Gnmda(&(*ac).NMDA, Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GnmdaSyn),u32(di))], Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(VmDend),u32(di))]); + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GnmdaSyn))] = NMDAParams_NMDASyn(&(*ac).NMDA, Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GnmdaSyn))], geT); + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Gnmda))] = NMDAParams_Gnmda(&(*ac).NMDA, Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GnmdaSyn))], Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(VmDend))]); } fn ActParams_MaintNMDAFromRaw(ac: ptr, ctx: ptr, ni: u32,di: u32) { if ((*ac).MaintNMDA.Gbar == 0) { @@ -644,94 +644,94 @@ fn ActParams_MaintNMDAFromRaw(ac: ptr, ctx: ptr, ctx: ptr, ni: u32,di: u32) { var nix = NetworkIxs[0]; - var isi = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(ISIAvg),u32(di))]; + var isi = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(ISIAvg))]; if (isi < (*ac).SMaint.ISI.Min || isi > (*ac).SMaint.ISI.Max) { return; } var ndi = di*nix.NNeurons + ni; - var smp = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(SMaintP),u32(di))]; + var smp = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(SMaintP))]; smp *= GetRandomNumber(ndi, (*ctx).RandCounter.Counter, RandFunActSMaintP); var trg = SMaintParams_ExpInt(&(*ac).SMaint, isi); if (smp <= trg) { smp = f32(1); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GMaintRaw),u32(di))] += (*ac).SMaint.Gbar; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GMaintRaw))] += (*ac).SMaint.Gbar; } - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(SMaintP),u32(di))] = smp; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(SMaintP))] = smp; } fn ActParams_GvgccFromVm(ac: ptr, ctx: ptr, ni: u32,di: u32) { if ((*ac).VGCC.Gbar == 0) { return; } - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Gvgcc),u32(di))] = VGCCParams_Gvgcc(&(*ac).VGCC, Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(VmDend),u32(di))], Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(VgccM),u32(di))], Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(VgccH),u32(di))]); + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Gvgcc))] = VGCCParams_Gvgcc(&(*ac).VGCC, Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(VmDend))], Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(VgccM))], Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(VgccH))]); var dm: f32; var dh: f32; - VGCCParams_DMHFromV(&(*ac).VGCC, Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(VmDend),u32(di))], Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(VgccM),u32(di))], Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(VgccH),u32(di))], &dm, &dh); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(VgccM),u32(di))] += dm; + VGCCParams_DMHFromV(&(*ac).VGCC, Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(VmDend))], Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(VgccM))], Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(VgccH))], &dm, &dh); + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(VgccM))] += dm; Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], - u32(ni),u32(VgccH),u32(di))] += dh; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(VgccCa),u32(di))] = VGCCParams_CaFromG(&(*ac).VGCC, Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(VmDend),u32(di))], Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Gvgcc),u32(di))], Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(VgccCa),u32(di))]); + u32(ni),u32(di),u32(VgccH))] += dh; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(VgccCa))] = VGCCParams_CaFromG(&(*ac).VGCC, Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(VmDend))], Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Gvgcc))], Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(VgccCa))]); } fn ActParams_GkFromVm(ac: ptr, ctx: ptr, ni: u32,di: u32) { - var vm = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Vm),u32(di))]; - var vmd = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(VmDend),u32(di))]; - var mahpN = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(MahpN),u32(di))]; + var vm = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Vm))]; + var vmd = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(VmDend))]; + var mahpN = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(MahpN))]; var gmahp = MahpParams_GmAHP(&(*ac).Mahp, vm, &mahpN); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Gmahp),u32(di))] = gmahp; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(MahpN),u32(di))] = mahpN; - var gsahp = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Gsahp),u32(di))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Gmahp))] = gmahp; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(MahpN))] = mahpN; + var gsahp = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Gsahp))]; var gak = AKsParams_Gak(&(*ac).AK, vmd); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Gak),u32(di))] = gak; - var nkirM = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(KirM),u32(di))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Gak))] = gak; + var nkirM = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(KirM))]; var gkir = KirParams_Gkir(&(*ac).Kir, vm, nkirM); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Gkir),u32(di))] = gkir; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Gkir))] = gkir; nkirM += KirParams_DM(&(*ac).Kir, VToBio(vm), nkirM); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(KirM),u32(di))] = nkirM; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(KirM))] = nkirM; var gktot = gmahp + gsahp + gak + gkir; if ((*ac).KNa.On == 1) { - var gknaMed = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GknaMed),u32(di))]; - var gknaSlow = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GknaSlow),u32(di))]; - KNaMedSlow_GcFromSpike(&(*ac).KNa, &gknaMed, &gknaSlow, Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Spike),u32(di))] > .5); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GknaMed),u32(di))] = gknaMed; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GknaSlow),u32(di))] = gknaSlow; + var gknaMed = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GknaMed))]; + var gknaSlow = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GknaSlow))]; + KNaMedSlow_GcFromSpike(&(*ac).KNa, &gknaMed, &gknaSlow, Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Spike))] > .5); + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GknaMed))] = gknaMed; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GknaSlow))] = gknaSlow; gktot += gknaMed + gknaSlow; } Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], - u32(ni),u32(Gk),u32(di))] = gktot; + u32(ni),u32(di),u32(Gk))] = gktot; } fn ActParams_GSkCaFromCa(ac: ptr, ctx: ptr, ni: u32,di: u32) { if ((*ac).SKCa.Gbar == 0) { return; } - var skcar = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(SKCaR),u32(di))]; - var skcain = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(SKCaIn),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(SKCaM),u32(di))] = SKCaParams_MFromCa(&(*ac).SKCa, skcar, Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(SKCaM),u32(di))]); - SKCaParams_CaInRFromSpike(&(*ac).SKCa, Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Spike),u32(di))], Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(CaSpkD),u32(di))], &skcain, &skcar); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(SKCaR),u32(di))] = skcar; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(SKCaIn),u32(di))] = skcain; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Gsk),u32(di))] = (*ac).SKCa.Gbar * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(SKCaM),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Gk),u32(di))] += Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Gsk),u32(di))]; + var skcar = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(SKCaR))]; + var skcain = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(SKCaIn))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(SKCaM))] = SKCaParams_MFromCa(&(*ac).SKCa, skcar, Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(SKCaM))]); + SKCaParams_CaInRFromSpike(&(*ac).SKCa, Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Spike))], Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(CaSpkD))], &skcain, &skcar); + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(SKCaR))] = skcar; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(SKCaIn))] = skcain; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Gsk))] = (*ac).SKCa.Gbar * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(SKCaM))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Gk))] += Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Gsk))]; } fn ActParams_GeFromSyn(ac: ptr, ctx: ptr, ni: u32,di: u32, geSyn: f32,geExt: f32) { - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeExt),u32(di))] = 0.0; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeExt))] = 0.0; var geS = geSyn; var geE = geExt; if ((*ac).Clamp.Add == 1 && NeuronHasFlag(NeuronHasExt, ni, di)) { - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeExt),u32(di))] = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Ext),u32(di))] * (*ac).Clamp.Ge; - geS += Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeExt),u32(di))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeExt))] = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Ext))] * (*ac).Clamp.Ge; + geS += Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeExt))]; } if ((*ac).Clamp.Add == 0 && NeuronHasFlag(NeuronHasExt, ni, di)) { - geS = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Ext),u32(di))] * (*ac).Clamp.Ge; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeExt),u32(di))] = geS; + geS = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Ext))] * (*ac).Clamp.Ge; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeExt))] = geS; geE = f32(0); // no extra in this case } - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Ge),u32(di))] = geS + geE; - if (Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Ge),u32(di))] < 0.0) { - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Ge),u32(di))] = 0.0; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Ge))] = geS + geE; + if (Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Ge))] < 0.0) { + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Ge))] = 0.0; } ActParams_AddGeNoise(ac, ctx, ni, di); } @@ -739,20 +739,20 @@ fn ActParams_AddGeNoise(ac: ptr, ctx: ptr, if ((*ac).Noise.On == 0 || (*ac).Noise.Ge == 0) { return; } - var p = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeNoiseP),u32(di))]; + var p = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeNoiseP))]; var ge = SpikeNoiseParams_PGe(&(*ac).Noise, ctx, &p, ni, di); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeNoiseP),u32(di))] = p; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeNoise),u32(di))] = DtParams_GeSynFromRaw(&(*ac).Dt, Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeNoise),u32(di))], ge); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Ge),u32(di))] += Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeNoise),u32(di))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeNoiseP))] = p; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeNoise))] = DtParams_GeSynFromRaw(&(*ac).Dt, Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeNoise))], ge); + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Ge))] += Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeNoise))]; } fn ActParams_AddGiNoise(ac: ptr, ctx: ptr, ni: u32,di: u32) { if ((*ac).Noise.On == 0 || (*ac).Noise.Gi == 0) { return; } - var p = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GiNoiseP),u32(di))]; + var p = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GiNoiseP))]; var gi = SpikeNoiseParams_PGi(&(*ac).Noise, ctx, &p, ni, di); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GiNoiseP),u32(di))] = p; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GiNoise),u32(di))] = DtParams_GiSynFromRaw(&(*ac).Dt, Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GiNoise),u32(di))], gi); + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GiNoiseP))] = p; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GiNoise))] = DtParams_GiSynFromRaw(&(*ac).Dt, Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GiNoise))], gi); } fn ActParams_GiFromSyn(ac: ptr, ctx: ptr, ni: u32,di: u32, giSyn: f32) -> f32 { ActParams_AddGiNoise(ac, ctx, ni, di); @@ -781,22 +781,22 @@ fn ActParams_VmInteg(ac: ptr, vm: f32,dt: f32,ge: f32,gl: f3 } fn ActParams_VmFromG(ac: ptr, ctx: ptr, ni: u32,di: u32) { var updtVm = true; - var isi = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(ISI),u32(di))]; + var isi = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(ISI))]; if ((*ac).Spikes.Tr > 0 && isi >= 0 && isi < f32((*ac).Spikes.Tr)) { updtVm = false; // don't update the spiking vm during refract } - var ge = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Ge),u32(di))] * (*ac).Gbar.E; - var gi = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Gi),u32(di))] * (*ac).Gbar.I; - var gk = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Gk),u32(di))] * (*ac).Gbar.K; + var ge = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Ge))] * (*ac).Gbar.E; + var gi = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Gi))] * (*ac).Gbar.I; + var gk = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Gk))] * (*ac).Gbar.K; var nvm: f32; var inet: f32; var expi: f32; if (updtVm) { - ActParams_VmInteg(ac, Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Vm),u32(di))], (*ac).Dt.VmDt, ge, f32(f32(1)), gi, gk, &nvm, &inet); + ActParams_VmInteg(ac, Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Vm))], (*ac).Dt.VmDt, ge, f32(f32(1)), gi, gk, &nvm, &inet); if (updtVm && (*ac).Spikes.Exp == 1) { // add spike current if relevant var exVm: f32; exVm = 0.5 * (nvm + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[ // midpoint for this - 2], u32(ni),u32(Vm),u32(di))]); + 2], u32(ni),u32(di),u32(Vm))]); expi = (*ac).Gbar.L * (*ac).Spikes.ExpSlope * FastExp((exVm-(*ac).Spikes.Thr)/(*ac).Spikes.ExpSlope); if (expi > (*ac).Dt.VmTau) { @@ -805,30 +805,30 @@ fn ActParams_VmFromG(ac: ptr, ctx: ptr, ni inet += expi; nvm = ActParams_VmFromInet(ac, nvm, (*ac).Dt.VmDt, expi); } - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Vm),u32(di))] = nvm; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Inet),u32(di))] = inet; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Vm))] = nvm; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Inet))] = inet; } else { // decay back to VmR var dvm: f32; if (i32(isi) == (*ac).Spikes.Tr-1) { - dvm = (*ac).Spikes.VmR - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Vm),u32(di))]; + dvm = (*ac).Spikes.VmR - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Vm))]; } else { - dvm = (*ac).Spikes.RDt * ((*ac).Spikes.VmR - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Vm),u32(di))]); + dvm = (*ac).Spikes.RDt * ((*ac).Spikes.VmR - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Vm))]); } - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Vm),u32(di))] += dvm; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Inet),u32(di))] = dvm * (*ac).Dt.VmTau; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Vm))] += dvm; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Inet))] = dvm * (*ac).Dt.VmTau; } var glEff = f32(1); if (!updtVm) { glEff += (*ac).Dend.GbarR; } var giEff: f32; - giEff = gi + (*ac).Gbar.I*Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(SSGiDend),u32(di))]; - ActParams_VmInteg(ac, Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(VmDend),u32(di))], (*ac).Dt.VmDendDt, ge, glEff, giEff, gk, &nvm, &inet); + giEff = gi + (*ac).Gbar.I*Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(SSGiDend))]; + ActParams_VmInteg(ac, Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(VmDend))], (*ac).Dt.VmDendDt, ge, glEff, giEff, gk, &nvm, &inet); if (updtVm) { nvm = ActParams_VmFromInet(ac, nvm, (*ac).Dt.VmDendDt, (*ac).Dend.GbarExp*expi); } Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], - u32(ni),u32(VmDend),u32(di))] = nvm; + u32(ni),u32(di),u32(VmDend))] = nvm; } fn ActParams_SpikeFromVmVars(ac: ptr, nrnISI: ptr,nrnISIAvg: ptr,nrnSpike: ptr,nrnSpiked: ptr,nrnAct: ptr, nrnVm: f32) { var thr: f32; @@ -872,18 +872,18 @@ fn ActParams_SpikeFromVmVars(ac: ptr, nrnISI: ptr, ctx: ptr, ni: u32,di: u32) { - var nrnISI = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(ISI),u32(di))]; - var nrnISIAvg = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(ISIAvg),u32(di))]; - var nrnSpike = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Spike),u32(di))]; - var nrnSpiked = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Spiked),u32(di))]; - var nrnAct = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Act),u32(di))]; - var nrnVm = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Vm),u32(di))]; + var nrnISI = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(ISI))]; + var nrnISIAvg = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(ISIAvg))]; + var nrnSpike = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Spike))]; + var nrnSpiked = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Spiked))]; + var nrnAct = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Act))]; + var nrnVm = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Vm))]; ActParams_SpikeFromVmVars(ac, &nrnISI, &nrnISIAvg, &nrnSpike, &nrnSpiked, &nrnAct, nrnVm); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(ISI),u32(di))] = nrnISI; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(ISIAvg),u32(di))] = nrnISIAvg; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Spike),u32(di))] = nrnSpike; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Spiked),u32(di))] = nrnSpiked; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Act),u32(di))] = nrnAct; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(ISI))] = nrnISI; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(ISIAvg))] = nrnISIAvg; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Spike))] = nrnSpike; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Spiked))] = nrnSpiked; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Act))] = nrnAct; } ///////////// import: "chans-ak.go" @@ -1581,17 +1581,17 @@ struct CaLrnParams { } fn CaLrnParams_VgccCaFromSpike(np: ptr, ctx: ptr, ni: u32,di: u32) { if ((*np).SpkVGCC == 1) { - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(VgccCa),u32(di))] = (*np).SpkVgccCa * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Spike),u32(di))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(VgccCa))] = (*np).SpkVgccCa * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Spike))]; } - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(VgccCaInt),u32(di))] += Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(VgccCa),u32(di))] - (*np).VgccDt*Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(VgccCaInt),u32(di))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(VgccCaInt))] += Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(VgccCa))] - (*np).VgccDt*Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(VgccCaInt))]; } fn CaLrnParams_CaLrns(np: ptr, ctx: ptr, ni: u32,di: u32) { CaLrnParams_VgccCaFromSpike(np, ctx, ni, di); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(CaLrn),u32(di))] = (*np).NormInv * (Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(NmdaCa),u32(di))] + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(VgccCaInt),u32(di))]); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(NrnCaM),u32(di))] += (*np).Dt.MDt * (Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(CaLrn),u32(di))] - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(NrnCaM),u32(di))]); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(NrnCaP),u32(di))] += (*np).Dt.PDt * (Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(NrnCaM),u32(di))] - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(NrnCaP),u32(di))]); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(NrnCaD),u32(di))] += (*np).Dt.DDt * (Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(NrnCaP),u32(di))] - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(NrnCaD),u32(di))]); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(CaDiff),u32(di))] = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(NrnCaP),u32(di))] - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(NrnCaD),u32(di))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(CaLrn))] = (*np).NormInv * (Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(NmdaCa))] + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(VgccCaInt))]); + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(NrnCaM))] += (*np).Dt.MDt * (Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(CaLrn))] - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(NrnCaM))]); + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(NrnCaP))] += (*np).Dt.PDt * (Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(NrnCaM))] - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(NrnCaP))]); + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(NrnCaD))] += (*np).Dt.DDt * (Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(NrnCaP))] - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(NrnCaD))]); + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(CaDiff))] = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(NrnCaP))] - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(NrnCaD))]; } struct TrgAvgActParams { GiBaseInit: f32, @@ -1624,20 +1624,20 @@ struct LearnNeurParams { } fn LearnNeurParams_LrnNMDAFromRaw(ln: ptr, ctx: ptr, ni: u32,di: u32, geTot: f32) { var geEff = max(geTot, 0.0); - var vmd = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(VmDend),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GnmdaLrn),u32(di))] = NMDAParams_NMDASyn(&(*ln).LrnNMDA, Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GnmdaLrn),u32(di))], geEff); - var gnmda = NMDAParams_Gnmda(&(*ln).LrnNMDA, Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GnmdaLrn),u32(di))], vmd); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(NmdaCa),u32(di))] = f32(gnmda * NMDAParams_CaFromV(&(*ln).LrnNMDA, vmd)); + var vmd = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(VmDend))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GnmdaLrn))] = NMDAParams_NMDASyn(&(*ln).LrnNMDA, Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GnmdaLrn))], geEff); + var gnmda = NMDAParams_Gnmda(&(*ln).LrnNMDA, Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GnmdaLrn))], vmd); + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(NmdaCa))] = f32(gnmda * NMDAParams_CaFromV(&(*ln).LrnNMDA, vmd)); } fn LearnNeurParams_CaFromSpike(ln: ptr, ctx: ptr, ni: u32,di: u32) { var caSyn: f32; - var caSpkM = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(CaSpkM),u32(di))]; - var caSpkP = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(CaSpkP),u32(di))]; - var caSpkD = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(CaSpkD),u32(di))]; - NeurCaParams_CaFromSpike(&(*ln).CaSpk, Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Spike),u32(di))], &caSyn, &caSpkM, &caSpkP, &caSpkD); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(CaSpkM),u32(di))] = caSpkM; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(CaSpkP),u32(di))] = caSpkP; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(CaSpkD),u32(di))] = caSpkD; + var caSpkM = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(CaSpkM))]; + var caSpkP = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(CaSpkP))]; + var caSpkD = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(CaSpkD))]; + NeurCaParams_CaFromSpike(&(*ln).CaSpk, Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Spike))], &caSyn, &caSpkM, &caSpkP, &caSpkD); + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(CaSpkM))] = caSpkM; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(CaSpkP))] = caSpkP; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(CaSpkD))] = caSpkD; CaLrnParams_CaLrns(&(*ln).CaLearn, ctx, ni, di); } struct SWtInitParams { diff --git a/axon/shaders/DWtSyn.wgsl b/axon/shaders/DWtSyn.wgsl index aebb808b..c20088d3 100644 --- a/axon/shaders/DWtSyn.wgsl +++ b/axon/shaders/DWtSyn.wgsl @@ -771,22 +771,22 @@ fn PathParams_DWtSyn(pt: ptr, ctx: ptr, r } } fn PathParams_SynCa(pt: ptr, ctx: ptr, si: u32,ri: u32,di: u32, syCaP: ptr,syCaD: ptr) { - var rb0 = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(SpkBin0),u32(di))]; - var sb0 = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(si),u32(SpkBin0),u32(di))]; - var rb1 = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(SpkBin1),u32(di))]; - var sb1 = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(si),u32(SpkBin1),u32(di))]; - var rb2 = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(SpkBin2),u32(di))]; - var sb2 = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(si),u32(SpkBin2),u32(di))]; - var rb3 = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(SpkBin3),u32(di))]; - var sb3 = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(si),u32(SpkBin3),u32(di))]; - var rb4 = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(SpkBin4),u32(di))]; - var sb4 = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(si),u32(SpkBin4),u32(di))]; - var rb5 = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(SpkBin5),u32(di))]; - var sb5 = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(si),u32(SpkBin5),u32(di))]; - var rb6 = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(SpkBin6),u32(di))]; - var sb6 = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(si),u32(SpkBin6),u32(di))]; - var rb7 = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(SpkBin7),u32(di))]; - var sb7 = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(si),u32(SpkBin7),u32(di))]; + var rb0 = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(di),u32(SpkBin0))]; + var sb0 = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(si),u32(di),u32(SpkBin0))]; + var rb1 = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(di),u32(SpkBin1))]; + var sb1 = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(si),u32(di),u32(SpkBin1))]; + var rb2 = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(di),u32(SpkBin2))]; + var sb2 = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(si),u32(di),u32(SpkBin2))]; + var rb3 = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(di),u32(SpkBin3))]; + var sb3 = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(si),u32(di),u32(SpkBin3))]; + var rb4 = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(di),u32(SpkBin4))]; + var sb4 = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(si),u32(di),u32(SpkBin4))]; + var rb5 = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(di),u32(SpkBin5))]; + var sb5 = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(si),u32(di),u32(SpkBin5))]; + var rb6 = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(di),u32(SpkBin6))]; + var sb6 = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(si),u32(di),u32(SpkBin6))]; + var rb7 = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(di),u32(SpkBin7))]; + var sb7 = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(si),u32(di),u32(SpkBin7))]; var b0 = 0.1 * (rb0 * sb0); var b1 = 0.1 * (rb1 * sb1); var b2 = 0.1 * (rb2 * sb2); @@ -804,7 +804,7 @@ fn PathParams_DWtSynCortex(pt: ptr, ctx: ptr, ctx: ptr, ctx: ptr, ctx: ptr, syni: u32,si: u32,ri: u32,lpi: u32,pi: u32,di: u32) { - var rNrnCaP = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(NrnCaP),u32(di))]; - var sNrnCap = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(si),u32(NrnCaP),u32(di))]; + var rNrnCaP = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(di),u32(NrnCaP))]; + var sNrnCap = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(si),u32(di),u32(NrnCaP))]; var lwt = Synapses[IndexF322D(Synapses[0], Synapses[ // linear weight 1], u32(syni),u32(LWt))]; var hebb = rNrnCaP * ((*pt).Learn.Hebb.Up*sNrnCap*(1-lwt) - (*pt).Learn.Hebb.Down*(1-sNrnCap)*lwt); @@ -857,8 +857,8 @@ fn PathParams_DWtSynHip(pt: ptr, ctx: ptr if (Synapses[IndexF322D(Synapses[0], Synapses[1], u32(syni),u32(Wt))] == 0) { return; } - var rNrnCaP = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(NrnCaP),u32(di))]; - var rNrnCaD = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(NrnCaD),u32(di))]; + var rNrnCaP = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(di),u32(NrnCaP))]; + var rNrnCaD = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(di),u32(NrnCaD))]; var err: f32; if (isTarget) { err = syCaP - syCaD; // for target layers, syn Ca drives error signal directly @@ -872,11 +872,11 @@ fn PathParams_DWtSynHip(pt: ptr, ctx: ptr } else { err *= lwt; } - var sNrnCap = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(si),u32(NrnCaP),u32(di))]; + var sNrnCap = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(si),u32(di),u32(NrnCaP))]; var savg = 0.5 + (*pt).Hip.SAvgCor*((*pt).Hip.SNominal-0.5); savg = 0.5 / max((*pt).Hip.SAvgThr, savg); // keep this Sending Average Correction term within bounds (SAvgThr) var hebb = rNrnCaP * (sNrnCap*(savg-lwt) - (1-sNrnCap)*lwt); - var dwt = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(RLRate),u32(di))] * (*pt).Learn.LRate.Eff * ((*pt).Hip.Hebb*hebb + (*pt).Hip.Err*err); + var dwt = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(di),u32(RLRate))] * (*pt).Learn.LRate.Eff * ((*pt).Hip.Hebb*hebb + (*pt).Hip.Err*err); SynapseTraces[IndexF323D(SynapseTraces[0], SynapseTraces[1], SynapseTraces[2], u32(syni),u32(DiDWt),u32(di))] = dwt; } @@ -885,21 +885,21 @@ fn PathParams_DWtSynBLA(pt: ptr, ctx: ptr var ach = GlobalScalars[IndexF322D(GlobalScalars[0], GlobalScalars[1], u32(GvACh),u32(di))]; if (GlobalScalars[IndexF322D(GlobalScalars[0], GlobalScalars[ // learn and reset 1], u32(GvHasRew),u32(di))] > 0) { - var ract = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(CaSpkD),u32(di))]; + var ract = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(di),u32(CaSpkD))]; if (ract < (*pt).Learn.Trace.LearnThr) { ract = f32(0); } var tr = SynapseTraces[IndexF323D(SynapseTraces[0], SynapseTraces[1], SynapseTraces[2], u32(syni),u32(Tr),u32(di))]; var ustr = (*pt).BLA.USTrace; - tr = ustr*Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(si),u32(Burst),u32(di))] + (1.0-ustr)*tr; - var delta = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(CaSpkP),u32(di))] - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(SpkPrv),u32(di))]; + tr = ustr*Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(si),u32(di),u32(Burst))] + (1.0-ustr)*tr; + var delta = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(di),u32(CaSpkP))] - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(di),u32(SpkPrv))]; if (delta < 0) { // neg delta learns slower in Acq, not Ext delta *= (*pt).BLA.NegDeltaLRate; } dwt = tr * delta * ract; SynapseTraces[IndexF323D(SynapseTraces[0], SynapseTraces[1], SynapseTraces[2], u32(syni),u32(Tr),u32(di))] = 0.0; } else if (ach > (*pt).BLA.AChThr) { - var dtr = ach * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(si),u32(Burst),u32(di))]; + var dtr = ach * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(si),u32(di),u32(Burst))]; SynapseTraces[IndexF323D(SynapseTraces[0], SynapseTraces[1], SynapseTraces[2], u32(syni),u32(DTr),u32(di))] = dtr; var tr = TraceParams_TrFromCa(&(*pt).Learn.Trace, SynapseTraces[IndexF323D(SynapseTraces[0], SynapseTraces[1], SynapseTraces[2], u32(syni),u32(Tr),u32(di))], dtr); SynapseTraces[IndexF323D(SynapseTraces[0], SynapseTraces[1], SynapseTraces[2], u32(syni),u32(Tr),u32(di))] = tr; @@ -912,7 +912,7 @@ fn PathParams_DWtSynBLA(pt: ptr, ctx: ptr } else { dwt *= lwt; } - SynapseTraces[IndexF323D(SynapseTraces[0], SynapseTraces[1], SynapseTraces[2], u32(syni),u32(DiDWt),u32(di))] = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(RLRate),u32(di))] * (*pt).Learn.LRate.Eff * dwt; + SynapseTraces[IndexF323D(SynapseTraces[0], SynapseTraces[1], SynapseTraces[2], u32(syni),u32(DiDWt),u32(di))] = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(di),u32(RLRate))] * (*pt).Learn.LRate.Eff * dwt; } fn PathParams_DWtSynRWPred(pt: ptr, ctx: ptr, syni: u32,si: u32,ri: u32,lpi: u32,pi: u32,di: u32) { var lda = GlobalScalars[IndexF322D(GlobalScalars[0], GlobalScalars[1], u32(GvDA),u32(di))]; @@ -920,10 +920,10 @@ fn PathParams_DWtSynRWPred(pt: ptr, ctx: ptr Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(Act),u32(di))] && da > 0) { // clipped at top, saturate up + if (Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(di),u32(Ge))] > Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(di),u32(Act))] && da > 0) { // clipped at top, saturate up da = f32(0); } - if (Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(Ge),u32(di))] < Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(Act),u32(di))] && da < 0) { // clipped at bottom, saturate down + if (Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(di),u32(Ge))] < Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(di),u32(Act))] && da < 0) { // clipped at bottom, saturate down da = f32(0); } if (da < 0) { @@ -931,10 +931,10 @@ fn PathParams_DWtSynRWPred(pt: ptr, ctx: ptr Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(Act),u32(di))] && da < 0) { // clipped at top, saturate up + if (Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(di),u32(Ge))] > Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(di),u32(Act))] && da < 0) { // clipped at top, saturate up da = f32(0); } - if (Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(Ge),u32(di))] < Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(Act),u32(di))] && da > 0) { // clipped at bottom, saturate down + if (Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(di),u32(Ge))] < Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(di),u32(Act))] && da > 0) { // clipped at bottom, saturate down da = f32(0); } if (da >= 0) { @@ -942,7 +942,7 @@ fn PathParams_DWtSynRWPred(pt: ptr, ctx: ptr, ctx: ptr, ctx: ptr (*pt).Learn.Trace.LearnThr) { // key: prevents learning if < threshold dtr += ach * ((*pt).Matrix.Credit * sact * rminus); @@ -998,7 +998,7 @@ fn PathParams_DWtSynVSMatrix(pt: ptr, ctx: ptr, ctx: ptr, syni: u32,si: u32,ri: u32,lpi: u32,pi: u32,di: u32) { - var rlr = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(RLRate),u32(di))]; + var rlr = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(di),u32(RLRate))]; if (GlobalScalars[IndexF322D(GlobalScalars[0], GlobalScalars[ // US time -- use DA and current recv activity 1], u32(GvHasRew),u32(di))] > 0) { var tr = SynapseTraces[IndexF323D(SynapseTraces[0], SynapseTraces[1], SynapseTraces[2], u32(syni),u32(Tr),u32(di))]; @@ -1007,10 +1007,10 @@ fn PathParams_DWtSynDSMatrix(pt: ptr, ctx: ptr (*pt).Learn.Trace.LearnThr) { // key: prevents learning if < threshold dtr += rlr * ((*pt).Matrix.Credit * pfmod * sact * rminus); @@ -1022,13 +1022,13 @@ fn PathParams_DWtSynDSMatrix(pt: ptr, ctx: ptr, ctx: ptr, syni: u32,si: u32,ri: u32,lpi: u32,pi: u32,di: u32) { var ract = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[ // t-1 - 2], u32(ri),u32(SpkPrv),u32(di))]; + 2], u32(ri),u32(di),u32(SpkPrv))]; if (ract < (*pt).Learn.Trace.LearnThr) { ract = f32(0); } var sact = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[ // t-1 - 2], u32(si),u32(SpkPrv),u32(di))]; - var dwt = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(RLRate),u32(di))] * (*pt).Learn.LRate.Eff * sact * ract; + 2], u32(si),u32(di),u32(SpkPrv))]; + var dwt = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ri),u32(di),u32(RLRate))] * (*pt).Learn.LRate.Eff * sact * ract; SynapseTraces[IndexF323D(SynapseTraces[0], SynapseTraces[1], SynapseTraces[2], u32(syni),u32(DiDWt),u32(di))] = dwt; } diff --git a/axon/shaders/GatherSpikes.wgsl b/axon/shaders/GatherSpikes.wgsl index 5ad9652a..3bd183a4 100644 --- a/axon/shaders/GatherSpikes.wgsl +++ b/axon/shaders/GatherSpikes.wgsl @@ -92,20 +92,20 @@ fn LayerParams_GatherSpikes(ly: ptr, ctx: ptr, ctx: ptr, ni: u32,di: u32) { - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeRaw),u32(di))] = 0.0; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GiRaw),u32(di))] = 0.0; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GModRaw),u32(di))] = 0.0; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GModSyn),u32(di))] = 0.0; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GMaintRaw),u32(di))] = 0.0; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(CtxtGeRaw),u32(di))] = 0.0; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeSyn),u32(di))] = NeuronAvgs[IndexF322D(NeuronAvgs[0], NeuronAvgs[1], u32(ni),u32(GeBase))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GiSyn),u32(di))] = NeuronAvgs[IndexF322D(NeuronAvgs[0], NeuronAvgs[1], u32(ni),u32(GiBase))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeRaw))] = 0.0; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GiRaw))] = 0.0; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GModRaw))] = 0.0; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GModSyn))] = 0.0; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GMaintRaw))] = 0.0; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(CtxtGeRaw))] = 0.0; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeSyn))] = NeuronAvgs[IndexF322D(NeuronAvgs[0], NeuronAvgs[1], u32(ni),u32(GeBase))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GiSyn))] = NeuronAvgs[IndexF322D(NeuronAvgs[0], NeuronAvgs[1], u32(ni),u32(GiBase))]; } fn LayerParams_GiFromSpikes(ly: ptr, ctx: ptr, ni: u32,di: u32) { var pi = LayerParams_PoolIndex(ly, NeuronIxs[IndexU322D(NeuronIxs[0], NeuronIxs[1], u32(ni),u32(NrnSubPool))]); - var spk = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Spike),u32(di))]; - var geRaw = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeRaw),u32(di))]; - var geExt = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeExt),u32(di))]; + var spk = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Spike))]; + var geRaw = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeRaw))]; + var geExt = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeExt))]; PoolInhibRawIncrInt(pi, di, spk, geRaw, geExt); PoolAvgMaxUpdate(pi, di, ni); if (PoolsInt[IndexI323D(PoolsInt[0], PoolsInt[1], PoolsInt[2], u32(pi),u32(PoolIsLayer),u32(di))] == 0) { // also update layer pool if I am a subpool @@ -173,25 +173,25 @@ fn PathParams_GatherSpikesGSyn(pt: ptr, ctx: ptr u32 { ///////////// import: "act-layer.go" fn LayerParams_MinusPhaseNeuron(ly: ptr, ctx: ptr, ni: u32,di: u32) { - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(ActM),u32(di))] = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(ActInt),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(CaSpkPM),u32(di))] = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(CaSpkP),u32(di))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(ActM))] = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(ActInt))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(CaSpkPM))] = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(CaSpkP))]; } ///////////// import: "act-net.go" diff --git a/axon/shaders/NewStateNeuron.wgsl b/axon/shaders/NewStateNeuron.wgsl index 717412fc..58d6b7f4 100644 --- a/axon/shaders/NewStateNeuron.wgsl +++ b/axon/shaders/NewStateNeuron.wgsl @@ -82,10 +82,10 @@ fn IndexI323D(s0: i32, s1: i32, s2: i32, i0: u32, i1: u32, i2: u32) -> u32 { ///////////// import: "act-layer.go" fn LayerParams_NewStateNeuron(ly: ptr, ctx: ptr, ni: u32,di: u32) { - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(BurstPrv),u32(di))] = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Burst),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(SpkPrv),u32(di))] = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(CaSpkD),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(SpkMax),u32(di))] = 0.0; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(SpkMaxCa),u32(di))] = 0.0; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(BurstPrv))] = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Burst))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(SpkPrv))] = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(CaSpkD))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(SpkMax))] = 0.0; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(SpkMaxCa))] = 0.0; ActParams_DecayState(&(*ly).Acts, ctx, ni, di, (*ly).Acts.Decay.Act, (*ly).Acts.Decay.Glong, (*ly).Acts.Decay.AHP); ActParams_KNaNewState(&(*ly).Acts, ctx, ni, di); } @@ -245,88 +245,88 @@ struct ActParams { PopCode: PopCodeParams, } fn ActParams_DecayLearnCa(ac: ptr, ctx: ptr, ni: u32,di: u32, decay: f32) { - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GnmdaLrn),u32(di))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GnmdaLrn),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(NmdaCa),u32(di))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(NmdaCa),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(VgccCa),u32(di))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(VgccCa),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(VgccCaInt),u32(di))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(VgccCaInt),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(CaLrn),u32(di))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(CaLrn),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(CaSpkM),u32(di))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(CaSpkM),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(CaSpkP),u32(di))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(CaSpkP),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(CaSpkD),u32(di))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(CaSpkD),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(NrnCaM),u32(di))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(NrnCaM),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(NrnCaP),u32(di))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(NrnCaP),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(NrnCaD),u32(di))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(NrnCaD),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(SKCaIn),u32(di))] += decay * (1.0 - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(SKCaIn),u32(di))]); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(SKCaR),u32(di))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(SKCaR),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(SKCaM),u32(di))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(SKCaM),u32(di))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GnmdaLrn))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GnmdaLrn))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(NmdaCa))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(NmdaCa))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(VgccCa))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(VgccCa))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(VgccCaInt))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(VgccCaInt))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(CaLrn))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(CaLrn))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(CaSpkM))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(CaSpkM))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(CaSpkP))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(CaSpkP))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(CaSpkD))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(CaSpkD))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(NrnCaM))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(NrnCaM))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(NrnCaP))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(NrnCaP))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(NrnCaD))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(NrnCaD))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(SKCaIn))] += decay * (1.0 - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(SKCaIn))]); + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(SKCaR))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(SKCaR))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(SKCaM))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(SKCaM))]; } fn ActParams_DecayAHP(ac: ptr, ctx: ptr, ni: u32,di: u32, decay: f32) { - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(MahpN),u32(di))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(MahpN),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Gmahp),u32(di))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Gmahp),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(SahpCa),u32(di))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(SahpCa),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(SahpN),u32(di))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(SahpN),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Gsahp),u32(di))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Gsahp),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GknaMed),u32(di))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GknaMed),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GknaSlow),u32(di))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GknaSlow),u32(di))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(MahpN))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(MahpN))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Gmahp))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Gmahp))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(SahpCa))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(SahpCa))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(SahpN))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(SahpN))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Gsahp))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Gsahp))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GknaMed))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GknaMed))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GknaSlow))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GknaSlow))]; var kirMrest = (*ac).Kir.Mrest; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(KirM),u32(di))] += decay * (kirMrest - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(KirM),u32(di))]); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Gkir),u32(di))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Gkir),u32(di))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(KirM))] += decay * (kirMrest - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(KirM))]); + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Gkir))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Gkir))]; } fn ActParams_DecayState(ac: ptr, ctx: ptr, ni: u32,di: u32, decay: f32,glong: f32,ahp: f32) { - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(ISIAvg),u32(di))] = -1.0; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(ActInt),u32(di))] = (*ac).Init.Act; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Spiked),u32(di))] = 0.0; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(ISIAvg))] = -1.0; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(ActInt))] = (*ac).Init.Act; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Spiked))] = 0.0; for (var i=0; i<8; i++) { - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(SpkBin0 + NeuronVars(i)),u32(di))] = 0.0; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(SpkBin0 + NeuronVars(i)))] = 0.0; } if (decay > 0) { // no-op for most, but not all.. - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Spike),u32(di))] = 0.0; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Act),u32(di))] -= decay * (Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Act),u32(di))] - (*ac).Init.Act); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(ActInt),u32(di))] -= decay * (Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(ActInt),u32(di))] - (*ac).Init.Act); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeSyn),u32(di))] -= decay * (Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeSyn),u32(di))] - NeuronAvgs[IndexF322D(NeuronAvgs[0], NeuronAvgs[1], u32(ni),u32(GeBase))]); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Ge),u32(di))] -= decay * (Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Ge),u32(di))] - NeuronAvgs[IndexF322D(NeuronAvgs[0], NeuronAvgs[1], u32(ni),u32(GeBase))]); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Gi),u32(di))] -= decay * (Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Gi),u32(di))] - NeuronAvgs[IndexF322D(NeuronAvgs[0], NeuronAvgs[1], u32(ni),u32(GiBase))]); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Gk),u32(di))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Gk),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Vm),u32(di))] -= decay * (Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Vm),u32(di))] - (*ac).Init.Vm); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeNoise),u32(di))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeNoise),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GiNoise),u32(di))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GiNoise),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GiSyn),u32(di))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GiSyn),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeInt),u32(di))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeInt),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GiInt),u32(di))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GiInt),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeIntNorm),u32(di))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeIntNorm),u32(di))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Spike))] = 0.0; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Act))] -= decay * (Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Act))] - (*ac).Init.Act); + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(ActInt))] -= decay * (Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(ActInt))] - (*ac).Init.Act); + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeSyn))] -= decay * (Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeSyn))] - NeuronAvgs[IndexF322D(NeuronAvgs[0], NeuronAvgs[1], u32(ni),u32(GeBase))]); + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Ge))] -= decay * (Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Ge))] - NeuronAvgs[IndexF322D(NeuronAvgs[0], NeuronAvgs[1], u32(ni),u32(GeBase))]); + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Gi))] -= decay * (Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Gi))] - NeuronAvgs[IndexF322D(NeuronAvgs[0], NeuronAvgs[1], u32(ni),u32(GiBase))]); + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Gk))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Gk))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Vm))] -= decay * (Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Vm))] - (*ac).Init.Vm); + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeNoise))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeNoise))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GiNoise))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GiNoise))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GiSyn))] -= decay * 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(GeInt))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeInt))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GiInt))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GiInt))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeIntNorm))] -= decay * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeIntNorm))]; } - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(VmDend),u32(di))] -= glong * (Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(VmDend),u32(di))] - (*ac).Init.Vm); + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(VmDend))] -= glong * (Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(VmDend))] - (*ac).Init.Vm); if (ahp > 0) { ActParams_DecayAHP(ac, ctx, ni, di, ahp); } - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GgabaB),u32(di))] -= glong * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GgabaB),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GABAB),u32(di))] -= glong * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GABAB),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GABABx),u32(di))] -= glong * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GABABx),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GnmdaSyn),u32(di))] -= glong * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GnmdaSyn),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Gnmda),u32(di))] -= glong * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Gnmda),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GMaintSyn),u32(di))] -= glong * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GMaintSyn),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GnmdaMaint),u32(di))] -= glong * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GnmdaMaint),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Gvgcc),u32(di))] -= glong * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Gvgcc),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(VgccM),u32(di))] -= glong * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(VgccM),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(VgccH),u32(di))] -= glong * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(VgccH),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Gak),u32(di))] -= glong * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Gak),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Gsk),u32(di))] -= glong * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Gsk),u32(di))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GgabaB))] -= glong * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GgabaB))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GABAB))] -= glong * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GABAB))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GABABx))] -= glong * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GABABx))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GnmdaSyn))] -= glong * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GnmdaSyn))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Gnmda))] -= glong * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Gnmda))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GMaintSyn))] -= glong * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GMaintSyn))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GnmdaMaint))] -= glong * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GnmdaMaint))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Gvgcc))] -= glong * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Gvgcc))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(VgccM))] -= glong * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(VgccM))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(VgccH))] -= glong * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(VgccH))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Gak))] -= glong * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Gak))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Gsk))] -= glong * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Gsk))]; if ((*ac).Decay.LearnCa > 0) { // learning-based Ca values -- not usual ActParams_DecayLearnCa(ac, ctx, ni, di, (*ac).Decay.LearnCa); } - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Inet),u32(di))] = 0.0; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeRaw),u32(di))] = 0.0; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GiRaw),u32(di))] = 0.0; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GModRaw),u32(di))] = 0.0; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GModSyn),u32(di))] = 0.0; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GMaintRaw),u32(di))] = 0.0; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(SSGiDend),u32(di))] = 0.0; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeExt),u32(di))] = 0.0; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(CtxtGeOrig),u32(di))] -= glong * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(CtxtGeOrig),u32(di))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Inet))] = 0.0; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeRaw))] = 0.0; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GiRaw))] = 0.0; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GModRaw))] = 0.0; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GModSyn))] = 0.0; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GMaintRaw))] = 0.0; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(SSGiDend))] = 0.0; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeExt))] = 0.0; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(CtxtGeOrig))] -= glong * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(CtxtGeOrig))]; } fn ActParams_KNaNewState(ac: ptr, ctx: ptr, ni: u32,di: u32) { if ((*ac).KNa.On == 1 && (*ac).KNa.TrialSlow == 1) { - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GknaSlow),u32(di))] += (*ac).KNa.Slow.Max * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(SpkPrv),u32(di))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GknaSlow))] += (*ac).KNa.Slow.Max * Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(SpkPrv))]; } } diff --git a/axon/shaders/PlusPhaseNeuron.wgsl b/axon/shaders/PlusPhaseNeuron.wgsl index 5d7344de..4ea575e4 100644 --- a/axon/shaders/PlusPhaseNeuron.wgsl +++ b/axon/shaders/PlusPhaseNeuron.wgsl @@ -84,9 +84,9 @@ fn IndexI323D(s0: i32, s1: i32, s2: i32, i0: u32, i1: u32, i2: u32) -> u32 { fn LayerParams_PlusPhaseNeuron(ly: ptr, ctx: ptr, ni: u32,di: u32) { var pi = LayerParams_PoolIndex(ly, NeuronIxs[IndexU322D(NeuronIxs[0], NeuronIxs[1], u32(ni),u32(NrnSubPool))]); var lpi = LayerParams_PoolIndex(ly, u32(u32(0))); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(ActP),u32(di))] = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(ActInt),u32(di))]; - var nrnCaSpkP = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(CaSpkP),u32(di))]; - var nrnCaSpkD = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(CaSpkD),u32(di))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(ActP))] = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(ActInt))]; + var nrnCaSpkP = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(CaSpkP))]; + var nrnCaSpkD = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(CaSpkD))]; var da = GlobalScalars[IndexF322D(GlobalScalars[0], GlobalScalars[1], u32(GvDA),u32(di))]; var ach = GlobalScalars[IndexF322D(GlobalScalars[0], GlobalScalars[1], u32(GvACh),u32(di))]; var mlr = RLRateParams_RLRateSigDeriv(&(*ly).Learn.RLRate, nrnCaSpkD, PoolAvgMax(AMCaSpkD, AMCycle, Max, lpi, di)); @@ -96,7 +96,7 @@ fn LayerParams_PlusPhaseNeuron(ly: ptr, ctx: ptr, ctx: ptr, ctx: ptr u32 { ///////////// import: "act-layer.go" fn LayerParams_PlusPhaseStartNeuron(ly: ptr, ctx: ptr, ni: u32,di: u32) { if (NeuronHasFlag(NeuronHasTarg, ni, di)) { // will be clamped in plus phase - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Ext),u32(di))] = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Target),u32(di))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Ext))] = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Target))]; NeuronSetFlag(NeuronHasExt, ni, di); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(ISI),u32(di))] = -1.0; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(ISI))] = -1.0; Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], - u32(ni),u32(ISIAvg),u32(di))] = -1.0; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(ActInt),u32(di))] = (*ly).Acts.Init.Act; + u32(ni),u32(di),u32(ISIAvg))] = -1.0; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(ActInt))] = (*ly).Acts.Init.Act; } } @@ -124,10 +124,10 @@ struct PathScaleParams { ///////////// import: "act.go" fn NeuronHasFlag(flag: NeuronFlags, ni: u32,di: u32) -> bool { - return (NeuronFlags(bitcast(Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(NeurFlags),u32(di))])) & flag) > 0; // weird: != 0 does NOT work on GPU + return (NeuronFlags(bitcast(Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(NeurFlags))])) & flag) > 0; // weird: != 0 does NOT work on GPU } fn NeuronSetFlag(flag: NeuronFlags, ni: u32,di: u32) { - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(NeurFlags),u32(di))] = bitcast(bitcast(Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(NeurFlags),u32(di))]) | u32(flag)); + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(NeurFlags))] = bitcast(bitcast(Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(NeurFlags))]) | u32(flag)); } struct SpikeParams { Thr: f32, diff --git a/axon/shaders/SendSpike.wgsl b/axon/shaders/SendSpike.wgsl index 817dd811..34fb66af 100644 --- a/axon/shaders/SendSpike.wgsl +++ b/axon/shaders/SendSpike.wgsl @@ -92,7 +92,7 @@ fn LayerParams_SendSpike(ly: ptr, ctx: ptr, ctx: ptr, lpi: u32,pi: u32,ni: u32,di: u32) { - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Burst),u32(di))] = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(CaSpkP),u32(di))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Burst))] = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(CaSpkP))]; var li = (*ly).Index; var pil = pi - (*ly).PoolSt; // 0-n pool index var pnn = u32(PoolNNeurons(pi)); @@ -104,19 +104,19 @@ fn LayerParams_PostSpikeSpecial(ly: ptr, ctx: ptr, ctx: ptr 0.1) { - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(CtxtGe),u32(di))] = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(CtxtGeRaw),u32(di))]; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(CtxtGeOrig),u32(di))] = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(CtxtGe),u32(di))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(CtxtGe))] = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(CtxtGeRaw))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(CtxtGeOrig))] = Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(CtxtGe))]; } } } case LHbLayer: { if (pni == 0) { - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Act),u32(di))] = GlobalScalars[IndexF322D(GlobalScalars[0], GlobalScalars[1], u32(GvLHbDip),u32(di))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Act))] = GlobalScalars[IndexF322D(GlobalScalars[0], GlobalScalars[1], u32(GvLHbDip),u32(di))]; } else { - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Act),u32(di))] = GlobalScalars[IndexF322D(GlobalScalars[0], GlobalScalars[1], u32(GvLHbBurst),u32(di))]; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Act))] = GlobalScalars[IndexF322D(GlobalScalars[0], GlobalScalars[1], u32(GvLHbBurst),u32(di))]; } - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeSyn),u32(di))] = DtParams_GeSynFromRawSteady(&(*ly).Acts.Dt, Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeRaw),u32(di))]); + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeSyn))] = DtParams_GeSynFromRawSteady(&(*ly).Acts.Dt, Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeRaw))]); } case DrivesLayer: { var dr = GlobalVectors[IndexF323D(GlobalVectors[0], GlobalVectors[1], GlobalVectors[2], u32(GvDrives),u32(pil - 1),u32(di))]; @@ -153,7 +153,7 @@ fn LayerParams_PostSpikeSpecial(ly: ptr, ctx: ptr 0) { act = PopCodeParams_EncodeValue(&(*ly).Acts.PopCode, pni, pnn, dr); } - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Act),u32(di))] = act; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Act))] = act; } case UrgencyLayer: { var ur = GlobalScalars[IndexF322D(GlobalScalars[0], GlobalScalars[1], u32(GvUrgency),u32(di))]; @@ -161,7 +161,7 @@ fn LayerParams_PostSpikeSpecial(ly: ptr, ctx: ptr 0) { act = PopCodeParams_EncodeValue(&(*ly).Acts.PopCode, pni, pnn, ur); } - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Act),u32(di))] = act; + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Act))] = act; } case USLayer: { var us = RubiconUSStimValue(di, pil-1, (*ly).Learn.NeuroMod.Valence); @@ -170,7 +170,7 @@ fn LayerParams_PostSpikeSpecial(ly: ptr, ctx: ptr, ctx: ptr, ctx: ptr, ctx: ptr, lpi: u32,pi: u32,ni: u32,di: u32) { LayerParams_PostSpikeSpecial(ly, ctx, lpi, pi, ni, di); var intdt = (*ly).Acts.Dt.IntDt; - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeInt),u32(di))] += intdt * (Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Ge),u32(di))] - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GeInt),u32(di))]); - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GiInt),u32(di))] += intdt * (Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GiSyn),u32(di))] - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(GiInt),u32(di))]); + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeInt))] += intdt * (Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Ge))] - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GeInt))]); + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(GiInt))] += intdt * (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(GiInt))]); if ((*ctx).PlusPhase == 1) { intdt *= f32(3.0); } - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(ActInt),u32(di))] += intdt * (Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Act),u32(di))] - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(ActInt),u32(di))]); + Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(ActInt))] += intdt * (Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Act))] - Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(ActInt))]); } ///////////// import: "act-net.go" @@ -282,9 +282,9 @@ fn PathParams_SendSpike(pt: ptr, ctx: ptr return; } sendVal *= Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[ // Burst is regular CaSpkP for all non-SuperLayer neurons - 2], u32(ni),u32(Burst),u32(di))]; + 2], u32(ni),u32(di),u32(Burst))]; } else { - if (Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(Spike),u32(di))] == 0) { + if (Neurons[IndexF323D(Neurons[0], Neurons[1], Neurons[2], u32(ni),u32(di),u32(Spike))] == 0) { return; } } diff --git a/axon/stats.go b/axon/stats.go index c281a511..17e3e565 100644 --- a/axon/stats.go +++ b/axon/stats.go @@ -35,15 +35,15 @@ func (ly *Layer) PctUnitErr(ctx *Context) []float64 { } trg := false if ly.Type == CompareLayer || ly.Type == TargetLayer { - if Neurons.Value(int(ni), int(Target), int(di)) > thr { + if Neurons.Value(int(ni), int(di), int(Target)) > thr { trg = true } } else { - if Neurons.Value(int(ni), int(ActP), int(di)) > thr { + if Neurons.Value(int(ni), int(di), int(ActP)) > thr { trg = true } } - if Neurons.Value(int(ni), int(ActM), int(di)) > thr { + if Neurons.Value(int(ni), int(di), int(ActM)) > thr { if !trg { wrong++ } @@ -79,8 +79,8 @@ func (ly *Layer) LocalistErr2D(ctx *Context) (err []bool, minusIndex, plusIndex for yi := 0; yi < ydim; yi++ { lni := uint32(yi*xdim + xi) ni := ly.NeurStIndex + lni - sumM += Neurons.Value(int(ni), int(ActM), int(di)) - sumP += Neurons.Value(int(ni), int(ActP), int(di)) + sumM += Neurons.Value(int(ni), int(di), int(ActM)) + sumP += Neurons.Value(int(ni), int(di), int(ActP)) } if sumM > maxM { mIndex = xi @@ -116,8 +116,8 @@ func (ly *Layer) LocalistErr4D(ctx *Context) (err []bool, minusIndex, plusIndex for yi := 0; yi < nun; yi++ { lni := uint32(xi*nun + yi) ni := ly.NeurStIndex + lni - sumM += Neurons.Value(int(ni), int(ActM), int(di)) - sumP += Neurons.Value(int(ni), int(ActP), int(di)) + sumM += Neurons.Value(int(ni), int(di), int(ActM)) + sumP += Neurons.Value(int(ni), int(di), int(ActP)) } if sumM > maxM { mIndex = xi @@ -181,8 +181,8 @@ func (ly *Layer) PhaseDiffFromActs(ctx *Context) { if NeuronIsOff(ni) { continue } - ap := Neurons.Value(int(ni), int(ActP), int(di)) - avgP // zero mean = correl - am := Neurons.Value(int(ni), int(ActM), int(di)) - avgM + ap := Neurons.Value(int(ni), int(di), int(ActP)) - avgP // zero mean = correl + am := Neurons.Value(int(ni), int(di), int(ActM)) - avgM cosv += ap * am ssm += am * am ssp += ap * ap diff --git a/axon/stats.goal b/axon/stats.goal index f4b0c103..a767a8e9 100644 --- a/axon/stats.goal +++ b/axon/stats.goal @@ -33,15 +33,15 @@ func (ly *Layer) PctUnitErr(ctx *Context) []float64 { } trg := false if ly.Type == CompareLayer || ly.Type == TargetLayer { - if Neurons[ni, Target, di] > thr { + if Neurons[ni, di, Target] > thr { trg = true } } else { - if Neurons[ni, ActP, di] > thr { + if Neurons[ni, di, ActP] > thr { trg = true } } - if Neurons[ni, ActM, di] > thr { + if Neurons[ni, di, ActM] > thr { if !trg { wrong++ } @@ -77,8 +77,8 @@ func (ly *Layer) LocalistErr2D(ctx *Context) (err []bool, minusIndex, plusIndex for yi := 0; yi < ydim; yi++ { lni := uint32(yi*xdim + xi) ni := ly.NeurStIndex + lni - sumM += Neurons[ni, ActM, di] - sumP += Neurons[ni, ActP, di] + sumM += Neurons[ni, di, ActM] + sumP += Neurons[ni, di, ActP] } if sumM > maxM { mIndex = xi @@ -114,8 +114,8 @@ func (ly *Layer) LocalistErr4D(ctx *Context) (err []bool, minusIndex, plusIndex for yi := 0; yi < nun; yi++ { lni := uint32(xi*nun + yi) ni := ly.NeurStIndex + lni - sumM += Neurons[ni, ActM, di] - sumP += Neurons[ni, ActP, di] + sumM += Neurons[ni, di, ActM] + sumP += Neurons[ni, di, ActP] } if sumM > maxM { mIndex = xi @@ -179,8 +179,8 @@ func (ly *Layer) PhaseDiffFromActs(ctx *Context) { if NeuronIsOff(ni) { continue } - ap := Neurons[ni, ActP, di] - avgP // zero mean = correl - am := Neurons[ni, ActM, di] - avgM + ap := Neurons[ni, di, ActP] - avgP // zero mean = correl + am := Neurons[ni, di, ActM] - avgM cosv += ap * am ssm += am * am ssp += ap * ap diff --git a/examples/deep_fsa/deep_fsa.go b/examples/deep_fsa/deep_fsa.go index d44f9024..cd25eef9 100644 --- a/examples/deep_fsa/deep_fsa.go +++ b/examples/deep_fsa/deep_fsa.go @@ -451,7 +451,7 @@ func (ss *Sim) TrialStats(di int) { ss.Stats.SetFloat("PhaseDiff", float64(inp.Values[di].PhaseDiff.Cor)) _, minusIndexes, _ := inp.LocalistErr4D(ctx) minusIndex := minusIndexes[di] - trgExt := axon.Neurons[axon.Ext, trg.NeurStIndex+uint32(minusIndex), di] + trgExt := axon.Neurons[trg.NeurStIndex+uint32(minusIndex), di, axon.Ext] err := true if trgExt > 0.5 { err = false diff --git a/examples/neuron/neuron.go b/examples/neuron/neuron.go index bfbdd53e..ce5fd24f 100644 --- a/examples/neuron/neuron.go +++ b/examples/neuron/neuron.go @@ -261,23 +261,23 @@ func (ss *Sim) NeuronUpdate(nt *axon.Network, inputOn bool) { // nrn.Gi = 0 if inputOn { if ss.Config.GeClamp { - axon.Neurons[axon.GeRaw, ni, di] = ss.Config.Ge + axon.Neurons[axon.GeRaw, di, ni] = ss.Config.Ge axon.SetNrnV(ctx, ni, di, axon.GeSyn, ac.Dt.GeSynFromRawSteady(axon.NrnV(ctx, ni, di, axon.GeRaw))) } else { nex.InISI += 1 if nex.InISI > 1000/ss.Config.SpikeHz { - axon.Neurons[axon.GeRaw, ni, di] = ss.Config.Ge + axon.Neurons[axon.GeRaw, di, ni] = ss.Config.Ge nex.InISI = 0 } else { - axon.Neurons[axon.GeRaw, ni, di] = 0 + axon.Neurons[axon.GeRaw, di, ni] = 0 } axon.SetNrnV(ctx, ni, di, axon.GeSyn, ac.Dt.GeSynFromRaw(axon.NrnV(ctx, ni, di, axon.GeSyn), axon.NrnV(ctx, ni, di, axon.GeRaw))) } } else { - axon.Neurons[axon.GeRaw, ni, di] = 0 - axon.Neurons[axon.GeSyn, ni, di] = 0 + axon.Neurons[axon.GeRaw, di, ni] = 0 + axon.Neurons[axon.GeSyn, di, ni] = 0 } - axon.Neurons[axon.GiRaw, ni, di] = ss.Config.Gi + axon.Neurons[axon.GiRaw, di, ni] = ss.Config.Gi axon.SetNrnV(ctx, ni, di, axon.GiSyn, ac.Dt.GiSynFromRawSteady(axon.NrnV(ctx, ni, di, axon.GiRaw))) if ss.Net.GPU.On {