Skip to content

Commit

Permalink
mostly building on gpu now for basic act funcs -- still need atomics
Browse files Browse the repository at this point in the history
  • Loading branch information
rcoreilly committed Oct 14, 2024
1 parent c69d76e commit 296da6d
Show file tree
Hide file tree
Showing 9 changed files with 137 additions and 125 deletions.
22 changes: 11 additions & 11 deletions axon/act.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions axon/act.goal
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,15 @@ func (sk *SpikeParams) ActFromISI(isi, timeInc, integ float32) float32 {

// AvgFromISI returns updated spiking ISI from current isi interval value
func (sk *SpikeParams) AvgFromISI(avg float32, isi float32) float32 {
if avg <= 0 {
avg = isi
} else if isi < 0.8*avg {
avg = isi // if significantly less than we take that
av := avg
if av <= 0 {
av = isi
} else if isi < 0.8*av {
av = isi // if significantly less than we take that
} else { // integrate on slower
avg += sk.ISIDt * (isi - avg) // running avg updt
av += sk.ISIDt * (isi - av) // running avg updt
}
return avg
return av
}

//////// DendParams
Expand Down Expand Up @@ -580,8 +581,7 @@ func (sm *SMaintParams) ExpInt(isi float32) float32 {
if isi <= 0 {
return 0
}
isi = max(isi, sm.ISI.Min)
return math32.FastExp(-isi / sm.NNeurons)
return math32.FastExp(-max(isi, sm.ISI.Min) / sm.NNeurons)
}

//////// PopCodeParams
Expand Down Expand Up @@ -1218,7 +1218,7 @@ func (ac *ActParams) AddGiNoise(ctx *Context, ni, di uint32) {
func (ac *ActParams) GiFromSyn(ctx *Context, ni, di uint32, giSyn float32) float32 {
ac.AddGiNoise(ctx, ni, di)
if giSyn < 0 { // negative inhib G doesn't make any sense
giSyn = 0
return 0
}
return giSyn
}
Expand All @@ -1242,11 +1242,11 @@ func (ac *ActParams) VmFromInet(vm, dt, inet float32) float32 {
// VmInteg integrates Vm over VmSteps to obtain a more stable value
// Returns the new Vm and inet values.
func (ac *ActParams) VmInteg(vm, dt, ge, gl, gi, gk float32, nvm, inet *float32) {
dt *= ac.Dt.DtStep
dtEff := dt * ac.Dt.DtStep
*nvm = vm
for i := int32(0); i < ac.Dt.VmSteps; i++ {
*inet = ac.InetFromG(*nvm, ge, gl, gi, gk)
*nvm = ac.VmFromInet(*nvm, dt, *inet)
*nvm = ac.VmFromInet(*nvm, dtEff, *inet)
}
}

Expand Down
170 changes: 85 additions & 85 deletions axon/enumgen.go

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions axon/layerparams.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions axon/layerparams.goal
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ func SetNeuronExtPosNeg(ctx *Context, ni, di uint32, val float32) {
if val >= 0 {
Neurons[Ext, ni, di] = val
} else {
Neurons[Ext, ni, di] = 0
Neurons[Ext, ni, di] = float32(0)
}
} else {
if val >= 0 {
Neurons[Ext, ni, di] = 0
Neurons[Ext, ni, di] = float32(0)
} else {
Neurons[Ext, ni, di] = -val
}
Expand Down Expand Up @@ -593,7 +593,7 @@ func (ly *LayerParams) SpecialPreGs(ctx *Context, ni, di uint32, pl *Pool, drvGe

case BLALayer:
if ly.Learn.NeuroMod.IsBLAExt() {
md := max(-GlobalScalars[GvDA, di], 0) // ext is modulated by negative da
md := max(-GlobalScalars[GvDA, di], float32(0)) // ext is modulated by negative da
geCtxt := md * ly.CT.GeGain * Neurons[CtxtGeOrig, ni, di]
Neurons[GeRaw, ni, di] += geCtxt
ctxExt := ly.Acts.Dt.GeSynFromRawSteady(geCtxt)
Expand Down Expand Up @@ -671,6 +671,7 @@ func (ly *LayerParams) SpecialPreGs(ctx *Context, ni, di uint32, pl *Pool, drvGe
case TDIntegLayer:
NrnSetFlag(ni, di, NeuronHasExt)
SetNeuronExtPosNeg(ctx, ni, di, GlobalScalars[GvRewPred, di])
default:
}
return saveVal
}
Expand All @@ -688,6 +689,7 @@ func (ly *LayerParams) SpecialPostGs(ctx *Context, ni, di uint32, saveVal float3
if orig < 0.05 {
Neurons[Ge, ni, di] = 0
}
default:
}
}

Expand Down Expand Up @@ -959,6 +961,7 @@ func (ly *LayerParams) PostSpikeSpecial(ctx *Context, ni, di uint32, pl *Pool, l
case TDDaLayer:
// I set this in CyclePost
Neurons[Act, ni, di] = GlobalScalars[GvDA, di]
default:
}
}

Expand Down Expand Up @@ -1013,6 +1016,7 @@ func (ly *LayerParams) CyclePost(ctx *Context, di uint32) {
ly.CyclePostTDIntegLayer(ctx, di)
case TDDaLayer:
ly.CyclePostTDDaLayer(ctx, di)
default:
}
}

Expand Down
8 changes: 3 additions & 5 deletions axon/learn.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions axon/learn.goal
Original file line number Diff line number Diff line change
Expand Up @@ -326,13 +326,11 @@ func (ln *LearnNeurParams) InitNeurCa(ctx *Context, ni, di uint32) {
// that drive learning -- can be the same as activation but also can be different
// for testing learning Ca effects independent of activation effects.
func (ln *LearnNeurParams) LrnNMDAFromRaw(ctx *Context, ni, di uint32, geTot float32) {
if geTot < 0 {
geTot = 0
}
geEff := max(geTot, 0)
vmd := Neurons[VmDend, ni, di]
Neurons[GnmdaLrn, ni, di] = ln.LrnNMDA.NMDASyn(Neurons[GnmdaLrn, ni, di], geTot)
Neurons[GnmdaLrn, ni, di] = ln.LrnNMDA.NMDASyn(Neurons[GnmdaLrn, ni, di], geEff)
gnmda := ln.LrnNMDA.Gnmda(Neurons[GnmdaLrn, ni, di], vmd)
Neurons[NmdaCa, ni, di] = gnmda * ln.LrnNMDA.CaFromV(vmd)
Neurons[NmdaCa, ni, di] = float32(gnmda * ln.LrnNMDA.CaFromV(vmd))
}

// CaFromSpike updates all spike-driven calcium variables, including CaLrn and CaSpk.
Expand Down
6 changes: 5 additions & 1 deletion axon/rubicon.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion axon/rubicon.goal
Original file line number Diff line number Diff line change
Expand Up @@ -1195,7 +1195,9 @@ func GlobalSetRew(ctx *Context, di uint32, rew float32, hasRew bool) {
}
}

// RubiconUSStimVal returns stimulus value for US at given index
//gosl:start

// RubiconUSStimValue returns stimulus value for US at given index
// and valence (includes Cost). If US > 0.01, a full 1 US activation is returned.
func RubiconUSStimValue(ctx *Context, di uint32, usIndex uint32, valence ValenceTypes) float32 {
nix := GetNetworkIxs(0)
Expand All @@ -1218,3 +1220,5 @@ func RubiconUSStimValue(ctx *Context, di uint32, usIndex uint32, valence Valence
return us
}

//gosl:end

0 comments on commit 296da6d

Please sign in to comment.