Skip to content

Commit

Permalink
deep first-pass working
Browse files Browse the repository at this point in the history
  • Loading branch information
rcoreilly committed Oct 20, 2024
1 parent 3b46a51 commit ffadcb7
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 31 deletions.
5 changes: 2 additions & 3 deletions examples/deep_fsa/deep_fsa.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"cogentcore.org/core/base/randx"
"cogentcore.org/core/core"
"cogentcore.org/core/icons"
"cogentcore.org/core/math32"
"cogentcore.org/core/math32/vecint"
"cogentcore.org/core/tensor/table"
"cogentcore.org/core/tree"
Expand Down Expand Up @@ -707,8 +706,8 @@ func (ss *Sim) ConfigGUI() {
ss.ViewUpdate.Config(nv, etime.AlphaCycle, etime.AlphaCycle)
ss.GUI.ViewUpdate = &ss.ViewUpdate

nv.SceneXYZ().Camera.Pose.Pos.Set(0, 1, 2.75) // more "head on" than default which is more "top down"
nv.SceneXYZ().Camera.LookAt(math32.Vec3(0, 0, 0), math32.Vec3(0, 1, 0))
// nv.SceneXYZ().Camera.Pose.Pos.Set(0, 1, 2.75) // more "head on" than default which is more "top down"
// nv.SceneXYZ().Camera.LookAt(math32.Vec3(0, 0, 0), math32.Vec3(0, 1, 0))

ss.GUI.AddPlots(title, &ss.Logs)

Expand Down
14 changes: 11 additions & 3 deletions leabra/deep_layers.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,13 @@ type PulvinarParams struct {
Binarize bool

// Threshold for binarizing in terms of sending Burst activation
BinThr float32 `viewif:"Binarize"`
BinThr float32

// Resulting driver Ge value for units above threshold -- lower value around 0.3 or so seems best (DriveScale is NOT applied -- generally same range as that).
BinOn float32 `default:"0.3" viewif:"Binarize"`
BinOn float32 `default:"0.3"`

// Resulting driver Ge value for units below threshold -- typically 0.
BinOff float32 `default:"0" viewif:"Binarize"`
BinOff float32 `default:"0"`
}

func (tp *PulvinarParams) Update() {
Expand All @@ -224,6 +224,14 @@ func (tp *PulvinarParams) Defaults() {
tp.BinOff = 0
}

func (tp *PulvinarParams) ShouldDisplay(field string) bool {
switch field {
case "BinThr", "BinOn", "BinOff":
return tp.Binarize
}
return true
}

// DriveGe returns effective excitatory conductance to use for given driver
// input Burst activation
func (tp *PulvinarParams) DriveGe(act float32) float32 {
Expand Down
40 changes: 18 additions & 22 deletions leabra/layer.go
Original file line number Diff line number Diff line change
Expand Up @@ -674,22 +674,10 @@ func (ly *Layer) QuarterFinal(ctx *Context) {
switch ctx.Quarter {
case 2:
ly.MinusPhase(ctx)
return
case 3:
ly.PlusPhase(ctx)
return
}
for ni := range ly.Neurons {
nrn := &ly.Neurons[ni]
if nrn.IsOff() {
continue
}
switch ctx.Quarter {
case 0:
nrn.ActQ1 = nrn.Act
case 1:
nrn.ActQ2 = nrn.Act
}
default:
ly.SaveQuarterState(ctx)
}
switch ly.Type {
case SuperLayer:
Expand All @@ -706,6 +694,22 @@ func (ly *Layer) QuarterFinal(ctx *Context) {
}
}

// SaveQuarterState saves Q1, Q2 quarter states.
func (ly *Layer) SaveQuarterState(ctx *Context) {
for ni := range ly.Neurons {
nrn := &ly.Neurons[ni]
if nrn.IsOff() {
continue
}
switch ctx.Quarter {
case 0:
nrn.ActQ1 = nrn.Act
case 1:
nrn.ActQ2 = nrn.Act
}
}
}

// MinusPhase is called at the end of the minus phase (quarter 3), to record state.
func (ly *Layer) MinusPhase(ctx *Context) {
for pi := range ly.Pools {
Expand All @@ -723,10 +727,6 @@ func (ly *Layer) MinusPhase(ctx *Context) {
nrn.SetFlag(true, NeurHasExt)
}
}
if ly.Type == PFCDeepLayer {
ly.UpdateGateCnt(ctx)
ly.DeepMaint(ctx)
}
}

// PlusPhase is called at the end of the plus phase (quarter 4), to record state.
Expand All @@ -745,10 +745,6 @@ func (ly *Layer) PlusPhase(ctx *Context) {
nrn.ActAvg += ly.Act.Dt.AvgDt * (nrn.Act - nrn.ActAvg)
}
ly.CosDiffFromActs()
if ly.Type == PFCDeepLayer {
ly.UpdateGateCnt(ctx)
ly.DeepMaint(ctx)
}
}

// CosDiffFromActs computes the cosine difference in activation state between minus and plus phases.
Expand Down
4 changes: 2 additions & 2 deletions leabra/looper.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func LooperStdPhases(man *looper.Manager, ctx *Context, net *Network, plusStart,
})
plusPhase := &looper.Event{Name: "PlusPhase", AtCounter: plusStart}
plusPhase.OnEvent.Add("MinusPhase:End", func() {
net.MinusPhase(ctx)
net.QuarterFinal(ctx)
ctx.QuarterInc()
})
plusPhase.OnEvent.Add("PlusPhase:Start", func() {
Expand All @@ -53,7 +53,7 @@ func LooperStdPhases(man *looper.Manager, ctx *Context, net *Network, plusStart,
ctx.AlphaCycStart()
})
stack.Loops[trl].OnEnd.Add("PlusPhase:End", func() {
net.PlusPhase(ctx)
net.QuarterFinal(ctx)
})
}
}
Expand Down
3 changes: 2 additions & 1 deletion leabra/neuron.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ var NeuronVars = []string{
"Act", "Ge", "Gi", "Gk", "Inet", "Vm", "Noise", "Spike", "Targ", "Ext",
"AvgSS", "AvgS", "AvgM", "AvgL", "AvgLLrn", "AvgSLrn", "ActLrn",
"ActM", "ActP", "ActDif", "ActDel", "ActQ0", "ActQ1", "ActQ2", "ActAvg", "Burst", "BurstPrv",
"GiSyn", "GiSelf", "ActSent", "GeRaw", "GiRaw", "GknaFast", "GknaMed", "GknaSlow", "ISI", "ISIAvg",
"GiSyn", "GiSelf", "ActSent", "GeRaw", "GiRaw", "GknaFast", "GknaMed", "GknaSlow", "ISI", "ISIAvg", "CtxtGe",
"ActG", "DALrn", "Shunt", "Maint", "MaintGe", "DA", "ACh", "SE", "GateAct", "GateNow", "GateCnt"}

var NeuronVarsMap map[string]int
Expand Down Expand Up @@ -238,6 +238,7 @@ var NeuronVarProps = map[string]string{
"GknaSlow": `cat:"Gmisc"`,
"ISI": `cat:"Gmisc"`,
"ISIAvg": `cat:"Gmisc"`,
"CtxtGe": `cat:"Gmisc"`,

"ActG": `cat:"PBWM"`,
"DALrn": `cat:"PBWM"`,
Expand Down

0 comments on commit ffadcb7

Please sign in to comment.