Skip to content

Commit

Permalink
hip looper fixed: need to prepend the plus phase
Browse files Browse the repository at this point in the history
  • Loading branch information
rcoreilly committed Nov 5, 2024
1 parent 0b1015d commit 2aff30e
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 20 deletions.
20 changes: 16 additions & 4 deletions examples/hip/hip.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,18 @@ func (ss *Sim) ConfigNet(net *leabra.Network) {
ca3.PlaceAbove(dg)
ca1.PlaceRightOf(ca3, 2)

in.Doc = "Input represents cortical processing areas for different sensory modalities, semantic categories, etc, organized into pools. It is pre-compressed in this model, to simplify and allow one-to-one projections into the EC."

ecin.Doc = "Entorhinal Cortex (EC) input layer is the superficial layer 2 that receives from the cortex and projects into the hippocampus. It has compressed representations of cortical inputs."

ecout.Doc = "Entorhinal Cortex (EC) output layer is the deep layers that are bidirectionally connected to the CA1, and communicate hippocampal recall back out to the cortex, while also training the CA1 to accurately represent the EC inputs"

ca1.Doc = "CA (Cornu Ammonis = Ammon's horn) area 1, receives from CA3 and drives recalled memory output to ECout"

ca3.Doc = "CA (Cornu Ammonis = Ammon's horn) area 3, receives inputs from ECin and DG, and is the primary site of memory encoding. Recurrent self-connections drive pattern completion of full memory representations from partial cues, along with connections to CA1 that drive memory output."

dg.Doc = "Dentate Gyruns, which receives broad inputs from ECin and has highly sparse, pattern separated representations, which drive more separated representations in CA3"

net.Build()
net.Defaults()
ss.ApplyParams()
Expand Down Expand Up @@ -427,9 +439,8 @@ func (ss *Sim) ConfigLoops() {
ls.Stacks[etime.Train].OnInit.Add("Init", func() { ss.Init() })
ls.Stacks[etime.Test].OnInit.Add("Init", func() { ss.TestInit() })

for m, _ := range ls.Stacks {
stack := ls.Stacks[m]
stack.Loops[etime.Trial].OnStart.Add("ApplyInputs", func() {
for _, st := range ls.Stacks {
st.Loops[etime.Trial].OnStart.Add("ApplyInputs", func() {
ss.ApplyInputs()
})
}
Expand Down Expand Up @@ -492,7 +503,7 @@ func (ss *Sim) ConfigLoops() {
ls.Stacks[etime.Test].OnInit.Add("GUI-Init", func() { ss.GUI.UpdateWindow() })

ss.Loops = ls
// mpi.Println(man.DocString())
fmt.Println(ls.DocString())
}

// ApplyInputs applies input patterns from given environment.
Expand Down Expand Up @@ -922,6 +933,7 @@ func (ss *Sim) ConfigGUI() {
ss.GUI.CycleUpdateInterval = 10

nv := ss.GUI.AddNetView("Network")
nv.Options.Raster.Max = 100
nv.Options.MaxRecs = 300
nv.SetNet(ss.Net)
ss.ViewUpdate.Config(nv, etime.Phase, etime.Phase)
Expand Down
4 changes: 1 addition & 3 deletions examples/ra25/ra25.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,7 @@ func (ss *Sim) ConfigLoops() {
leabra.LooperStdPhases(ls, &ss.Context, ss.Net, 75, 99) // plus phase timing
leabra.LooperSimCycleAndLearn(ls, ss.Net, &ss.Context, &ss.ViewUpdate) // std algo code

ls.Stacks[etime.Train].OnInit.Add("Init", func() {
ss.Init()
})
ls.Stacks[etime.Train].OnInit.Add("Init", func() { ss.Init() })

for m, _ := range ls.Stacks {
st := ls.Stacks[m]
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.22

require (
cogentcore.org/core v0.3.5
github.com/emer/emergent/v2 v2.0.0-dev0.1.4
github.com/emer/emergent/v2 v2.0.0-dev0.1.6
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI=
github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
github.com/emer/emergent/v2 v2.0.0-dev0.1.4 h1:HCBBq6s/t3n6xlLPS9TzOL5BO9+U4BYIboJdBrFeliA=
github.com/emer/emergent/v2 v2.0.0-dev0.1.4/go.mod h1:9QhWnj/IHq/TrVzcXsC96GlC1Gg/pK0pwMI5sZr+/yU=
github.com/emer/emergent/v2 v2.0.0-dev0.1.6 h1:0Bu141YCDOgA44k3eBctMghg0ZXPsd5zcLKEHIZVlYQ=
github.com/emer/emergent/v2 v2.0.0-dev0.1.6/go.mod h1:9QhWnj/IHq/TrVzcXsC96GlC1Gg/pK0pwMI5sZr+/yU=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
Expand Down
24 changes: 14 additions & 10 deletions leabra/hip.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,18 @@ func (net *Network) ConfigLoopsHip(ctx *Context, ls *looper.Stacks) {
net.GScaleFromAvgAct()
net.InitGInc()
})
ls.AddEventAllModes(etime.Cycle, "HipPlusPhase:Start", 75, func() {
ca1FromECin.WtScale.Abs = 1
ca1FromCa3.WtScale.Abs = 0
if ctx.Mode == etime.Train {
ecin.UnitValues(&tmpValues, "Act", 0)
ecout.ApplyExt1D32(tmpValues)
}
net.GScaleFromAvgAct()
net.InitGInc()
})
for _, st := range ls.Stacks {
ev := st.Loops[etime.Cycle].EventByCounter(75)
ev.OnEvent.Prepend("HipPlusPhase:Start", func() bool {
ca1FromECin.WtScale.Abs = 1
ca1FromCa3.WtScale.Abs = 0
if ctx.Mode == etime.Train {
ecin.UnitValues(&tmpValues, "Act", 0)
ecout.ApplyExt1D32(tmpValues)
}
net.GScaleFromAvgAct()
net.InitGInc()
return true
})
}
}

0 comments on commit 2aff30e

Please sign in to comment.