diff --git a/axon/looper.go b/axon/looper.go index 69c06df4..0ce811f1 100644 --- a/axon/looper.go +++ b/axon/looper.go @@ -41,11 +41,10 @@ func LooperStdPhases(man *looper.Manager, ctx *Context, net *Network, plusStart, man.AddEventAllModes(etime.Cycle, minusPhase, beta1, beta2, plusPhase) for m, _ := range man.Stacks { - mode := m // For closures - stack := man.Stacks[mode] + stack := man.Stacks[m] stack.Loops[trl].OnStart.Add("NewState", func() { net.NewState(ctx) - ctx.NewState(mode) + ctx.NewState(m) }) stack.Loops[trl].OnEnd.Add("PlusPhase:End", func() { net.PlusPhase(ctx) @@ -92,10 +91,9 @@ func LooperSimCycleAndLearn(man *looper.Manager, net *Network, ctx *Context, vie // Set variables on ss that are referenced elsewhere, such as ApplyInputs. for m, loops := range man.Stacks { - curMode := m // For closures. for _, loop := range loops.Loops { loop.OnStart.Add("SetCtxMode", func() { - ctx.Mode = curMode + ctx.Mode = m }) } } @@ -107,7 +105,6 @@ func LooperSimCycleAndLearn(man *looper.Manager, net *Network, ctx *Context, vie // then Epoch does not reset the log below it func LooperResetLogBelow(man *looper.Manager, logs *elog.Logs, except ...etime.Times) { for m, stack := range man.Stacks { - curMode := m // For closures. for t, loop := range stack.Loops { curTime := t isExcept := false @@ -119,7 +116,7 @@ func LooperResetLogBelow(man *looper.Manager, logs *elog.Logs, except ...etime.T } if below := stack.TimeBelow(curTime); !isExcept && below != etime.NoTime { loop.OnStart.Add("ResetLog"+below.String(), func() { - logs.ResetLog(curMode, below) + logs.ResetLog(m, below) }) } } @@ -129,7 +126,6 @@ func LooperResetLogBelow(man *looper.Manager, logs *elog.Logs, except ...etime.T // LooperUpdateNetView adds netview update calls at each time level func LooperUpdateNetView(man *looper.Manager, viewupdt *netview.ViewUpdate, net *Network, ctrUpdateFunc func(tm etime.Times)) { for m, stack := range man.Stacks { - curMode := m // For closures. for t, loop := range stack.Loops { curTime := t if curTime != etime.Cycle { @@ -139,7 +135,7 @@ func LooperUpdateNetView(man *looper.Manager, viewupdt *netview.ViewUpdate, net }) } } - cycLoop := man.GetLoop(curMode, etime.Cycle) + cycLoop := man.GetLoop(m, etime.Cycle) cycLoop.OnEnd.Add("GUI:UpdateNetView", func() { cyc := cycLoop.Counter.Cur ctrUpdateFunc(etime.Cycle) @@ -151,18 +147,17 @@ func LooperUpdateNetView(man *looper.Manager, viewupdt *netview.ViewUpdate, net // LooperUpdatePlots adds plot update calls at each time level func LooperUpdatePlots(man *looper.Manager, gui *egui.GUI) { for m, stack := range man.Stacks { - curMode := m // For closures. for t, loop := range stack.Loops { curTime := t curLoop := loop if curTime == etime.Cycle { curLoop.OnEnd.Add("GUI:UpdatePlot", func() { cyc := curLoop.Counter.Cur - gui.GoUpdateCyclePlot(curMode, cyc) + gui.GoUpdateCyclePlot(m, cyc) }) } else { curLoop.OnEnd.Add("GUI:UpdatePlot", func() { - gui.GoUpdatePlot(curMode, curTime) + gui.GoUpdatePlot(m, curTime) }) } } diff --git a/examples/choose/choose.go b/examples/choose/choose.go index 52279ef9..51e28116 100644 --- a/examples/choose/choose.go +++ b/examples/choose/choose.go @@ -430,8 +430,7 @@ func (ss *Sim) ConfigLoops() { axon.LooperSimCycleAndLearn(man, ss.Net, &ss.Context, &ss.ViewUpdate) // std algo code for m := range man.Stacks { - mode := m // For closures - stack := man.Stacks[mode] + stack := man.Stacks[m] stack.Loops[etime.Trial].OnStart.Add("ApplyInputs", func() { ss.ApplyInputs() }) diff --git a/examples/deep_fsa/deep_fsa.go b/examples/deep_fsa/deep_fsa.go index 67d9268b..6007c504 100644 --- a/examples/deep_fsa/deep_fsa.go +++ b/examples/deep_fsa/deep_fsa.go @@ -257,8 +257,7 @@ func (ss *Sim) ConfigLoops() { axon.LooperSimCycleAndLearn(man, ss.Net, &ss.Context, &ss.ViewUpdate) // std algo code for m, _ := range man.Stacks { - mode := m // For closures - stack := man.Stacks[mode] + stack := man.Stacks[m] stack.Loops[etime.Trial].OnStart.Add("ApplyInputs", func() { ss.ApplyInputs() }) diff --git a/examples/deep_move/deep_move.go b/examples/deep_move/deep_move.go index 6786aa6d..357b5781 100644 --- a/examples/deep_move/deep_move.go +++ b/examples/deep_move/deep_move.go @@ -313,8 +313,7 @@ func (ss *Sim) ConfigLoops() { axon.LooperSimCycleAndLearn(man, ss.Net, &ss.Context, &ss.ViewUpdate) // std algo code for m, _ := range man.Stacks { - mode := m // For closures - stack := man.Stacks[mode] + stack := man.Stacks[m] stack.Loops[etime.Trial].OnStart.Add("ApplyInputs", func() { ss.ApplyInputs() }) diff --git a/examples/deep_music/deep_music.go b/examples/deep_music/deep_music.go index 25401989..bce6bf2a 100644 --- a/examples/deep_music/deep_music.go +++ b/examples/deep_music/deep_music.go @@ -294,8 +294,7 @@ func (ss *Sim) ConfigLoops() { axon.LooperSimCycleAndLearn(man, ss.Net, &ss.Context, &ss.ViewUpdate) // std algo code for m, _ := range man.Stacks { - mode := m // For closures - stack := man.Stacks[mode] + stack := man.Stacks[m] stack.Loops[etime.Trial].OnStart.Add("ApplyInputs", func() { ss.ApplyInputs() }) diff --git a/examples/dls/dls.go b/examples/dls/dls.go index 44298c76..8dc2cad0 100644 --- a/examples/dls/dls.go +++ b/examples/dls/dls.go @@ -391,8 +391,7 @@ func (ss *Sim) ConfigLoops() { axon.LooperSimCycleAndLearn(man, ss.Net, &ss.Context, &ss.ViewUpdate) // std algo code for m := range man.Stacks { - mode := m // For closures - stack := man.Stacks[mode] + stack := man.Stacks[m] stack.Loops[etime.Trial].OnStart.Add("ApplyInputs", func() { ss.ApplyInputs() }) diff --git a/examples/hip/hip.go b/examples/hip/hip.go index bc6bf181..bb9375b1 100644 --- a/examples/hip/hip.go +++ b/examples/hip/hip.go @@ -279,8 +279,7 @@ func (ss *Sim) ConfigLoops() { ss.Net.ConfigLoopsHip(&ss.Context, man, &ss.Config.Hip, &ss.PretrainMode) for m, _ := range man.Stacks { - mode := m // For closures - stack := man.Stacks[mode] + stack := man.Stacks[m] stack.Loops[etime.Trial].OnStart.Add("ApplyInputs", func() { ss.ApplyInputs() }) diff --git a/examples/inhib/inhib.go b/examples/inhib/inhib.go index f9ec59ac..7c0f1038 100644 --- a/examples/inhib/inhib.go +++ b/examples/inhib/inhib.go @@ -262,17 +262,15 @@ func (ss *Sim) ConfigLoops() { }) } for m, loops := range man.Stacks { - curMode := m // For closures. for _, loop := range loops.Loops { loop.OnStart.Add("SetTimeVal", func() { - time.Mode = curMode + time.Mode = m }) } } for m, _ := range man.Stacks { - mode := m // For closures - stack := man.Stacks[mode] + stack := man.Stacks[m] stack.Loops[etime.Trial].OnStart.Add("ApplyInputs", func() { ss.ApplyInputs() }) diff --git a/examples/mpi/ra25.go b/examples/mpi/ra25.go index 0530c7e0..9ff8a018 100644 --- a/examples/mpi/ra25.go +++ b/examples/mpi/ra25.go @@ -400,8 +400,7 @@ func (ss *Sim) ConfigLoops() { }) for m, _ := range man.Stacks { - mode := m // For closures - stack := man.Stacks[mode] + stack := man.Stacks[m] stack.Loops[etime.Trial].OnStart.Add("ApplyInputs", func() { ss.ApplyInputs() }) diff --git a/examples/objrec/objrec.go b/examples/objrec/objrec.go index 34b19e8a..80310b26 100644 --- a/examples/objrec/objrec.go +++ b/examples/objrec/objrec.go @@ -280,7 +280,6 @@ func (ss *Sim) ConfigLoops() { axon.LooperSimCycleAndLearn(man, ss.Net, &ss.Context, &ss.ViewUpdate) // std algo code for mode := range man.Stacks { - mode := mode // For closures stack := man.Stacks[mode] stack.Loops[etime.Trial].OnStart.Add("ApplyInputs", func() { ss.ApplyInputs() diff --git a/examples/pcore_ds/pcore_ds.go b/examples/pcore_ds/pcore_ds.go index 13a413c4..a261bbdd 100644 --- a/examples/pcore_ds/pcore_ds.go +++ b/examples/pcore_ds/pcore_ds.go @@ -370,12 +370,11 @@ func (ss *Sim) ConfigLoops() { axon.LooperSimCycleAndLearn(man, ss.Net, &ss.Context, &ss.ViewUpdate) // std algo code for m, _ := range man.Stacks { - mode := m // For closures - stack := man.Stacks[mode] + stack := man.Stacks[m] stack.Loops[etime.Trial].OnStart.Add("ApplyInputs", func() { - seq := man.Stacks[mode].Loops[etime.Sequence].Counter.Cur - trial := man.Stacks[mode].Loops[etime.Trial].Counter.Cur - ss.ApplyInputs(mode, seq, trial) + seq := man.Stacks[m].Loops[etime.Sequence].Counter.Cur + trial := man.Stacks[m].Loops[etime.Trial].Counter.Cur + ss.ApplyInputs(m, seq, trial) }) } // note: auto applies to all diff --git a/examples/pcore_vs/pcore_vs.go b/examples/pcore_vs/pcore_vs.go index a1cc57ca..b5dbad82 100644 --- a/examples/pcore_vs/pcore_vs.go +++ b/examples/pcore_vs/pcore_vs.go @@ -305,15 +305,14 @@ func (ss *Sim) ConfigLoops() { axon.LooperSimCycleAndLearn(man, ss.Net, &ss.Context, &ss.ViewUpdate) // std algo code for m, _ := range man.Stacks { - mode := m // For closures - stack := man.Stacks[mode] + stack := man.Stacks[m] stack.Loops[etime.Trial].OnStart.Add("ApplyInputs", func() { - seq := man.Stacks[mode].Loops[etime.Sequence].Counter.Cur - trial := man.Stacks[mode].Loops[etime.Trial].Counter.Cur - ss.ApplyInputs(mode, seq, trial) + seq := man.Stacks[m].Loops[etime.Sequence].Counter.Cur + trial := man.Stacks[m].Loops[etime.Trial].Counter.Cur + ss.ApplyInputs(m, seq, trial) }) stack.Loops[etime.Trial].OnEnd.Add("GatedAction", func() { - trial := man.Stacks[mode].Loops[etime.Trial].Counter.Cur + trial := man.Stacks[m].Loops[etime.Trial].Counter.Cur if trial == 1 { ss.GatedAction() } diff --git a/examples/pfcmaint/pfcmaint.go b/examples/pfcmaint/pfcmaint.go index cfcf7953..f08a3d72 100644 --- a/examples/pfcmaint/pfcmaint.go +++ b/examples/pfcmaint/pfcmaint.go @@ -266,12 +266,11 @@ func (ss *Sim) ConfigLoops() { axon.LooperSimCycleAndLearn(man, ss.Net, &ss.Context, &ss.ViewUpdate) // std algo code for m, _ := range man.Stacks { - mode := m // For closures - stack := man.Stacks[mode] + stack := man.Stacks[m] stack.Loops[etime.Trial].OnStart.Add("ApplyInputs", func() { - seq := man.Stacks[mode].Loops[etime.Sequence].Counter.Cur - trial := man.Stacks[mode].Loops[etime.Trial].Counter.Cur - ss.ApplyInputs(mode, seq, trial) + seq := man.Stacks[m].Loops[etime.Sequence].Counter.Cur + trial := man.Stacks[m].Loops[etime.Trial].Counter.Cur + ss.ApplyInputs(m, seq, trial) }) } diff --git a/examples/pvlv/pvlv.go b/examples/pvlv/pvlv.go index 51832e51..143941f8 100644 --- a/examples/pvlv/pvlv.go +++ b/examples/pvlv/pvlv.go @@ -307,8 +307,7 @@ func (ss *Sim) ConfigLoops() { axon.LooperSimCycleAndLearn(man, ss.Net, &ss.Context, &ss.ViewUpdate) // std algo code for m, _ := range man.Stacks { - mode := m // For closures - stack := man.Stacks[mode] + stack := man.Stacks[m] stack.Loops[etime.Trial].OnStart.Add("ApplyInputs", func() { ss.ApplyInputs() }) diff --git a/examples/ra25/ra25.go b/examples/ra25/ra25.go index fa98bb77..dc019c91 100644 --- a/examples/ra25/ra25.go +++ b/examples/ra25/ra25.go @@ -365,8 +365,7 @@ func (ss *Sim) ConfigLoops() { axon.LooperSimCycleAndLearn(man, ss.Net, &ss.Context, &ss.ViewUpdate) // std algo code for m, _ := range man.Stacks { - mode := m // For closures - stack := man.Stacks[mode] + stack := man.Stacks[m] stack.Loops[etime.Trial].OnStart.Add("ApplyInputs", func() { ss.ApplyInputs() }) diff --git a/examples/ra25x/ra25x.go b/examples/ra25x/ra25x.go index d00cdf1d..b3e382f2 100644 --- a/examples/ra25x/ra25x.go +++ b/examples/ra25x/ra25x.go @@ -252,8 +252,7 @@ func (ss *Sim) ConfigLoops() { axon.LooperSimCycleAndLearn(man, ss.Net, &ss.Context, &ss.ViewUpdate) // std algo code for m, _ := range man.Stacks { - mode := m // For closures - stack := man.Stacks[mode] + stack := man.Stacks[m] stack.Loops[etime.Trial].OnStart.Add("ApplyInputs", func() { ss.ApplyInputs() }) diff --git a/examples/rl/rl.go b/examples/rl/rl.go index d694ec92..4f806cfb 100644 --- a/examples/rl/rl.go +++ b/examples/rl/rl.go @@ -223,8 +223,7 @@ func (ss *Sim) ConfigLoops() { axon.LooperSimCycleAndLearn(man, ss.Net, &ss.Context, &ss.ViewUpdate) // std algo code for m, _ := range man.Stacks { - mode := m // For closures - stack := man.Stacks[mode] + stack := man.Stacks[m] stack.Loops[etime.Trial].OnStart.Add("ApplyInputs", func() { ss.ApplyInputs() }) diff --git a/examples/vspatch/vspatch.go b/examples/vspatch/vspatch.go index a6f24950..49ac8d43 100644 --- a/examples/vspatch/vspatch.go +++ b/examples/vspatch/vspatch.go @@ -267,12 +267,11 @@ func (ss *Sim) ConfigLoops() { axon.LooperSimCycleAndLearn(man, ss.Net, &ss.Context, &ss.ViewUpdate) // std algo code for m, _ := range man.Stacks { - mode := m // For closures - stack := man.Stacks[mode] + stack := man.Stacks[m] stack.Loops[etime.Trial].OnStart.Add("ApplyInputs", func() { - seq := man.Stacks[mode].Loops[etime.Sequence].Counter.Cur - trial := man.Stacks[mode].Loops[etime.Trial].Counter.Cur - ss.ApplyInputs(mode, seq, trial) + seq := man.Stacks[m].Loops[etime.Sequence].Counter.Cur + trial := man.Stacks[m].Loops[etime.Trial].Counter.Cur + ss.ApplyInputs(m, seq, trial) }) }