From 435276bcd53f5ebab52f5f799e4ce39909bbb3f1 Mon Sep 17 00:00:00 2001 From: "Randall C. O'Reilly" Date: Thu, 13 Jun 2024 03:09:02 -0700 Subject: [PATCH] kinaseq is just for testing learned regress eqs; cleanup a few things. --- examples/deep_fsa/params.go | 2 +- examples/kinaseq/config.go | 23 ---- examples/kinaseq/kinaseq.go | 60 ++-------- examples/kinaseq/neuron.go | 215 ------------------------------------ examples/kinaseq/sim.go | 183 ++++-------------------------- kinase/params.go | 20 ---- 6 files changed, 30 insertions(+), 473 deletions(-) delete mode 100644 examples/kinaseq/neuron.go diff --git a/examples/deep_fsa/params.go b/examples/deep_fsa/params.go index 48f058daf..266803668 100644 --- a/examples/deep_fsa/params.go +++ b/examples/deep_fsa/params.go @@ -88,7 +88,7 @@ var ParamSets = netparams.Sets{ "Path.SWts.Adapt.LRate": "0.01", // 0.01 or 0.0001 music "Path.SWts.Init.SPct": "1.0", // 1 works fine here -- .5 also ok "Path.Com.PFail": "0.0", - "Path.Learn.Trace.Tau": "2", // 2 > 1 still 1.7.19 + "Path.Learn.Trace.Tau": "1", // 1 >> 2 v0.0.9 }}, {Sel: ".BackPath", Desc: "top-down back-pathways MUST have lower relative weight scale, otherwise network hallucinates", Params: params.Params{ diff --git a/examples/kinaseq/config.go b/examples/kinaseq/config.go index ac49f8ec0..4c5ba9205 100644 --- a/examples/kinaseq/config.go +++ b/examples/kinaseq/config.go @@ -6,22 +6,6 @@ package main // ParamConfig has config parameters related to sim params type ParamConfig struct { - - // gain multiplier on spike for computing CaSpk: increasing this directly affects the magnitude of the trace values, learning rate in Target layers, and other factors that depend on CaSpk values: RLRate, UpdateThr. Path.KinaseCa.SpikeG provides an additional gain factor specific to the synapse-level trace factors, without affecting neuron-level CaSpk values. Larger networks require higher gain factors at the neuron level -- 12, vs 8 for smaller. - SpikeG float32 `default:"8"` - - // time constant for integrating spike-driven calcium trace at sender and recv neurons, CaSyn, which then drives synapse-level integration of the joint pre * post synapse-level activity, in cycles (msec). Note: if this param is changed, then there will be a change in effective learning rate that can be compensated for by multiplying PathParams.Learn.KinaseCa.SpikeG by sqrt(30 / sqrt(SynTau) - SynTau float32 `default:"30" min:"1"` - - // rate = 1 / tau - SynDt float32 `view:"-" json:"-" xml:"-" edit:"-"` - - // learning rate for decoder - LRate float32 `default:"0.001"` - - // network parameters - Network map[string]any - // Extra Param Sheet name(s) to use (space separated if multiple) -- must be valid name as listed in compiled-in params or loaded params Sheet string @@ -41,15 +25,8 @@ type ParamConfig struct { Good bool `nest:"+"` } -func (pc *ParamConfig) Update() { - pc.SynDt = 1.0 / pc.SynTau -} - // RunConfig has config parameters related to running the sim type RunConfig struct { - // Neuron runs the standard Neuron update equations, vs. Kinase experimental equations - Neuron bool `default:"false"` - // use the GPU for computation -- only for testing in this model -- not faster GPU bool `default:"false"` diff --git a/examples/kinaseq/kinaseq.go b/examples/kinaseq/kinaseq.go index f55956b8a..b79ea8297 100644 --- a/examples/kinaseq/kinaseq.go +++ b/examples/kinaseq/kinaseq.go @@ -54,7 +54,7 @@ func (kn *KinaseNeuron) StartTrial() { // Cycle does one cycle of neuron updating, with given exponential spike interval // based on target spiking firing rate. -func (kn *KinaseNeuron) Cycle(expInt float32, params *ParamConfig, cyc int) { +func (ss *Sim) Cycle(kn *KinaseNeuron, expInt float32, cyc int) { kn.Spike = 0 bin := cyc / 50 if expInt > 0 { @@ -66,7 +66,7 @@ func (kn *KinaseNeuron) Cycle(expInt float32, params *ParamConfig, cyc int) { kn.SpikeBins[bin] += 1 } } - kn.CaSyn += params.SynDt * (params.SpikeG*kn.Spike - kn.CaSyn) + kn.CaSyn += ss.NeurCa.SynDt * (ss.NeurCa.SpikeG*kn.Spike - kn.CaSyn) } func (kn *KinaseNeuron) SetInput(inputs []float32, off int) { @@ -102,9 +102,6 @@ func (ks *KinaseSynapse) Init() { // KinaseState is basic Kinase equation state type KinaseState struct { - // if true, training decoder - Train bool - // SSE for decoder SSE float32 @@ -159,7 +156,6 @@ func (ss *Sim) ConfigKinase() { // Sweep runs a sweep through minus-plus ranges func (ss *Sim) Sweep() { - ss.Kinase.Train = false // hz := []float32{25, 50, 100} // nhz := len(hz) @@ -196,7 +192,6 @@ func (ss *Sim) Run() { // RunImpl runs NTrials, recording to RunLog and TrialLog func (ss *Sim) RunImpl(minusHz, plusHz float32, ntrials int) { - ss.Kinase.Train = false ss.Kinase.Init() for trl := 0; trl < ntrials; trl++ { ss.Kinase.Trial = trl @@ -248,14 +243,12 @@ func (ss *Sim) TrialImpl(minusHz, plusHz float32) { Sint = math32.Exp(-1000.0 / float32(shz)) } for t := 0; t < maxcyc; t++ { - ks.Send.Cycle(Sint, &cfg.Params, ks.Cycle) - ks.Recv.Cycle(Rint, &cfg.Params, ks.Cycle) + ss.Cycle(&ks.Send, Sint, ks.Cycle) + ss.Cycle(&ks.Recv, Rint, ks.Cycle) ca := ks.Send.CaSyn * ks.Recv.CaSyn - ss.CaParams.FromCa(ca, &ks.StdSyn.CaM, &ks.StdSyn.CaP, &ks.StdSyn.CaD) - if !ks.Train { - ss.Logs.LogRow(etime.Test, etime.Cycle, ks.Cycle) - } + ss.SynCa.FromCa(ca, &ks.StdSyn.CaM, &ks.StdSyn.CaP, &ks.StdSyn.CaD) + ss.Logs.LogRow(etime.Test, etime.Cycle, ks.Cycle) ks.Cycle++ } } @@ -265,36 +258,12 @@ func (ss *Sim) TrialImpl(minusHz, plusHz float32) { ks.SpikeBins[i] = 0.1 * (ks.Recv.SpikeBins[i] * ks.Send.SpikeBins[i]) } - ss.CaParams.FinalCa(ks.SpikeBins[0], ks.SpikeBins[1], ks.SpikeBins[2], ks.SpikeBins[3], &ks.LinearSyn.CaM, &ks.LinearSyn.CaP, &ks.LinearSyn.CaD) + ss.LinearSynCa.FinalCa(ks.SpikeBins[0], ks.SpikeBins[1], ks.SpikeBins[2], ks.SpikeBins[3], &ks.LinearSyn.CaP, &ks.LinearSyn.CaD) ks.LinearSyn.DWt = ks.LinearSyn.CaP - ks.LinearSyn.CaD - if ks.Train { - ss.Logs.LogRow(etime.Train, etime.Cycle, 0) - ss.GUI.UpdatePlot(etime.Train, etime.Cycle) - ss.Logs.LogRow(etime.Train, etime.Trial, ks.Trial) - ss.GUI.UpdatePlot(etime.Train, etime.Trial) - } else { - ss.GUI.UpdatePlot(etime.Test, etime.Cycle) - ss.Logs.LogRow(etime.Test, etime.Trial, ks.Trial) - ss.GUI.UpdatePlot(etime.Test, etime.Trial) - } -} - -// Train trains the linear decoder -func (ss *Sim) Train() { - ss.Kinase.Train = true - ss.Kinase.Init() - for epc := 0; epc < ss.Config.Run.NEpochs; epc++ { - ss.Kinase.Condition = epc - for trl := 0; trl < ss.Config.Run.NTrials; trl++ { - ss.Kinase.Trial = trl - minusHz := 100 * rand.Float32() - plusHz := 100 * rand.Float32() - ss.TrialImpl(minusHz, plusHz) - } - ss.Logs.LogRow(etime.Train, etime.Condition, ss.Kinase.Condition) - ss.GUI.UpdatePlot(etime.Train, etime.Condition) - } + ss.GUI.UpdatePlot(etime.Test, etime.Cycle) + ss.Logs.LogRow(etime.Test, etime.Trial, ks.Trial) + ss.GUI.UpdatePlot(etime.Test, etime.Trial) } func (ss *Sim) ConfigKinaseLogItems() { @@ -346,15 +315,6 @@ func (ss *Sim) ConfigKinaseLogItems() { ctx.SetAgg(ctx.Mode, times[ti+1], stats.Mean) } } else { - itm.Write[etime.Scope(etime.Train, times[ti])] = func(ctx *elog.Context) { - fany := value.Interface() - switch fkind { - case reflect.Int: - ctx.SetFloat32(float32(fany.(int))) - case reflect.String: - ctx.SetString(fany.(string)) - } - } itm.Write[etime.Scope(etime.Test, times[ti])] = func(ctx *elog.Context) { fany := value.Interface() switch fkind { diff --git a/examples/kinaseq/neuron.go b/examples/kinaseq/neuron.go deleted file mode 100644 index 0e90c30b2..000000000 --- a/examples/kinaseq/neuron.go +++ /dev/null @@ -1,215 +0,0 @@ -// Copyright (c) 2019, The Emergent Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package main - -import ( - "fmt" - "log" - - "github.com/emer/axon/v2/axon" - "github.com/emer/emergent/v2/etime" - "github.com/emer/emergent/v2/netparams" - "github.com/emer/emergent/v2/params" - "github.com/emer/emergent/v2/paths" -) - -// ParamSets is the default set of parameters -- Base is always applied, and others can be optionally -// selected to apply on top of that -var ParamSets = netparams.Sets{ - "Base": { - {Sel: "Path", Desc: "no learning", - Params: params.Params{ - "Path.Learn.Learn": "false", - }}, - {Sel: "Layer", Desc: "generic params for all layers: lower gain, slower, soft clamp", - Params: params.Params{ - "Layer.Inhib.Layer.On": "false", - "Layer.Acts.Init.Vm": "0.3", - }}, - }, - "Testing": { - {Sel: "Layer", Desc: "", - Params: params.Params{ - "Layer.Acts.NMDA.Gbar": "0.0", - "Layer.Acts.GabaB.Gbar": "0.0", - }}, - }, -} - -// Extra state for neuron -type NeuronEx struct { - - // input ISI countdown for spiking mode -- counts up - InISI float32 -} - -func (nrn *NeuronEx) Init() { - nrn.InISI = 0 -} - -func (ss *Sim) ConfigNet(net *axon.Network) { - ctx := &ss.Context - - net.InitName(net, "Neuron") - in := net.AddLayer2D("Input", 1, 1, axon.InputLayer) - hid := net.AddLayer2D("Neuron", 1, 1, axon.SuperLayer) - - net.ConnectLayers(in, hid, paths.NewFull(), axon.ForwardPath) - - err := net.Build(ctx) - if err != nil { - log.Println(err) - return - } - net.Defaults() - ss.SetParams("Network", false) // only set Network params - ss.InitWts(net) -} - -// InitWts loads the saved weights -func (ss *Sim) InitWts(net *axon.Network) { - net.InitWts(&ss.Context) -} - -//////////////////////////////////////////////////////////////////////////////// -// Init, utils - -// Counters returns a string of the current counter state -// use tabs to achieve a reasonable formatting overall -// and add a few tabs at the end to allow for expansion.. -func (ss *Sim) Counters() string { - return fmt.Sprintf("Cycle:\t%d\t\t\t", ss.Context.Cycle) -} - -func (ss *Sim) UpdateView() { - ss.GUI.UpdatePlot(etime.Test, etime.Cycle) - ss.GUI.ViewUpdate.Text = ss.Counters() - ss.GUI.ViewUpdate.UpdateCycle(int(ss.Context.Cycle)) -} - -//////////////////////////////////////////////////////////////////////////////// -// Running the Network, starting bottom-up.. - -// RunCycles updates neurons over specified number of cycles -func (ss *Sim) RunCycles() { - ctx := &ss.Context - ss.Init() - ss.GUI.StopNow = false - ss.Net.InitActs(ctx) - ctx.NewState(etime.Train) - ss.SetParams("", false) - // ly := ss.Net.AxonLayerByName("Neuron") - // nrn := &(ly.Neurons[0]) - inputOn := false - for cyc := 0; cyc < ss.Config.NCycles; cyc++ { - switch cyc { - case ss.Config.OnCycle: - inputOn = true - case ss.Config.OffCycle: - inputOn = false - } - ss.NeuronUpdate(ss.Net, inputOn) - ctx.Cycle = int32(cyc) - ss.Logs.LogRow(etime.Test, etime.Cycle, cyc) - ss.RecordValues(cyc) - if cyc%ss.Config.UpdateInterval == 0 { - ss.UpdateView() - } - ss.Context.CycleInc() - if ss.GUI.StopNow { - break - } - } - ss.UpdateView() -} - -func (ss *Sim) RecordValues(cyc int) { - var vals []float32 - ly := ss.Net.AxonLayerByName("Neuron") - key := fmt.Sprintf("cyc: %03d", cyc) - for _, vnm := range axon.NeuronVarNames { - ly.UnitValues(&vals, vnm, 0) - vkey := key + fmt.Sprintf("\t%s", vnm) - ss.ValMap[vkey] = vals[0] - } -} - -// NeuronUpdate updates the neuron -// this just calls the relevant code directly, bypassing most other stuff. -func (ss *Sim) NeuronUpdate(nt *axon.Network, inputOn bool) { - ctx := &ss.Context - ly := ss.Net.AxonLayerByName("Neuron") - ni := ly.NeurStIndex - di := uint32(0) - ac := &ly.Params.Acts - nex := &ss.NeuronEx - // nrn.Noise = float32(ly.Params.Act.Noise.Gen(-1)) - // nrn.Ge += nrn.Noise // GeNoise - // nrn.Gi = 0 - if inputOn { - if ss.Config.GeClamp { - axon.SetNrnV(ctx, ni, di, axon.GeRaw, 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.SetNrnV(ctx, ni, di, axon.GeRaw, ss.Config.Ge) - nex.InISI = 0 - } else { - axon.SetNrnV(ctx, ni, di, axon.GeRaw, 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.SetNrnV(ctx, ni, di, axon.GeRaw, 0) - axon.SetNrnV(ctx, ni, di, axon.GeSyn, 0) - } - axon.SetNrnV(ctx, ni, di, axon.GiRaw, 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 { - ss.Net.GPU.SyncStateToGPU() - ss.Net.GPU.RunPipelineWait("Cycle", 2) - ss.Net.GPU.SyncStateFromGPU() - ctx.CycleInc() // why is this not working!? - } else { - lpl := ly.Pool(0, di) - ly.GInteg(ctx, ni, di, lpl, ly.LayerValues(0)) - ly.SpikeFromG(ctx, ni, di, lpl) - } - - sly := ss.Net.AxonLayerByName("Input") - sly.Params.Learn.CaFromSpike(ctx, 0, di) - - updtThr := float32(0) - si := uint32(0) - ri := uint32(1) - syni := uint32(0) - pj := ly.RcvPaths[0] - - snCaSyn := pj.Params.Learn.KinaseCa.CaScale * axon.NrnV(ctx, ni, di, axon.CaSyn) - pj.Params.SynCaSyn(ctx, syni, ri, di, snCaSyn, updtThr) - - rnCaSyn := pj.Params.Learn.KinaseCa.CaScale * axon.NrnV(ctx, ri, di, axon.CaSyn) - if axon.NrnV(ctx, si, di, axon.Spike) <= 0 { // NOT already handled in send version - pj.Params.SynCaSyn(ctx, syni, si, di, rnCaSyn, updtThr) - } -} - -// Stop tells the sim to stop running -func (ss *Sim) Stop() { - ss.GUI.StopNow = true -} - -///////////////////////////////////////////////////////////////////////// -// Params setting - -// SetParams sets the params for "Base" and then current ParamSet. -// If sheet is empty, then it applies all avail sheets (e.g., Network, Sim) -// otherwise just the named sheet -// if setMsg = true then we output a message for each param that was set. -func (ss *Sim) SetParams(sheet string, setMsg bool) { - ss.Params.SetAll() -} diff --git a/examples/kinaseq/sim.go b/examples/kinaseq/sim.go index b5b0f2d14..b3ec3495b 100644 --- a/examples/kinaseq/sim.go +++ b/examples/kinaseq/sim.go @@ -12,24 +12,18 @@ package main import ( "os" - "reflect" "cogentcore.org/core/base/mpi" "cogentcore.org/core/core" "cogentcore.org/core/icons" - "cogentcore.org/core/math32/minmax" "cogentcore.org/core/tensor" - "cogentcore.org/core/tensor/table" "github.com/emer/axon/v2/axon" "github.com/emer/axon/v2/kinase" - "github.com/emer/emergent/v2/ecmd" "github.com/emer/emergent/v2/econfig" "github.com/emer/emergent/v2/egui" "github.com/emer/emergent/v2/elog" - "github.com/emer/emergent/v2/emer" "github.com/emer/emergent/v2/estats" "github.com/emer/emergent/v2/etime" - "github.com/emer/emergent/v2/netview" ) func main() { @@ -55,8 +49,14 @@ type Sim struct { // simulation configuration parameters -- set by .toml config file and / or args Config Config + // Kinase NeurCa params + NeurCa kinase.NeurCaParams + // Kinase SynCa params - CaParams kinase.SynCaParams + SynCa kinase.SynCaParams + + // Kinase LinearSynCa params + LinearSynCa kinase.SynCaLinear // Kinase state Kinase KinaseState @@ -64,12 +64,6 @@ type Sim struct { // Training data for least squares solver TrainData tensor.Float64 - // the network -- click to view / edit parameters for layers, paths, etc - Net *axon.Network `view:"no-inline"` - - // extra neuron state for additional channels: VGCC, AK - NeuronEx NeuronEx `view:"no-inline"` - // axon timing parameters and state Context axon.Context @@ -79,15 +73,6 @@ type Sim struct { // logging Logs elog.Logs `view:"no-inline"` - // all parameter management - Params emer.NetParams `view:"inline"` - - // current cycle of updating - Cycle int `edit:"-"` - - // netview update parameters - ViewUpdate netview.ViewUpdate `view:"inline"` - // manages all the gui elements GUI egui.GUI `view:"-"` @@ -97,17 +82,15 @@ type Sim struct { // New creates new blank elements and initializes defaults func (ss *Sim) New() { - ss.Net = &axon.Network{} econfig.Config(&ss.Config, "config.toml") - ss.Config.Params.Update() - ss.Params.Config(ParamSets, ss.Config.Params.Sheet, ss.Config.Params.Tag, ss.Net) - ss.CaParams.Defaults() + ss.SynCa.Defaults() + ss.NeurCa.Defaults() + ss.LinearSynCa.Defaults() ss.Stats.Init() ss.ValMap = make(map[string]float32) } func (ss *Sim) Defaults() { - ss.Params.Config(ParamSets, ss.Config.Params.Sheet, ss.Config.Params.Tag, ss.Net) } //////////////////////////////////////////////////////////////////////////////////////////// @@ -115,12 +98,10 @@ func (ss *Sim) Defaults() { // ConfigAll configures all the elements using the standard functions func (ss *Sim) ConfigAll() { - ss.ConfigNet(ss.Net) ss.ConfigKinase() ss.ConfigLogs() if ss.Config.Params.SaveAll { ss.Config.Params.SaveAll = false - ss.Net.SaveParamsSnapshot(&ss.Params.Params, &ss.Config, ss.Config.Params.Good) os.Exit(0) } } @@ -129,89 +110,28 @@ func (ss *Sim) ConfigAll() { // and resets the epoch log table func (ss *Sim) Init() { ss.Context.Reset() - ss.InitWts(ss.Net) ss.Kinase.Init() ss.ConfigKinase() - ss.NeuronEx.Init() ss.GUI.StopNow = false - ss.SetParams("", false) // all sheets } func (ss *Sim) ConfigLogs() { - if ss.Config.Run.Neuron { - ss.ConfigNeuronLogItems() - } else { - ss.ConfigKinaseLogItems() - } + ss.ConfigKinaseLogItems() ss.Logs.CreateTables() - if ss.Config.Run.Neuron { - ss.Logs.PlotItems("Vm", "Spike") - } else { - ss.Logs.PlotItems("Send.Spike", "Recv.Spike") - } + ss.Logs.PlotItems("Send.Spike", "Recv.Spike") - ss.Logs.SetContext(&ss.Stats, ss.Net) + ss.Logs.SetContext(&ss.Stats, nil) ss.Logs.ResetLog(etime.Test, etime.Cycle) } -func (ss *Sim) ConfigNeuronLogItems() { - ly := ss.Net.AxonLayerByName("Neuron") - // nex := &ss.NeuronEx - lg := &ss.Logs - - lg.AddItem(&elog.Item{ - Name: "Cycle", - Type: reflect.Int, - FixMax: false, - Range: minmax.F32{Max: 1}, - Write: elog.WriteMap{ - etime.Scope(etime.Test, etime.Cycle): func(ctx *elog.Context) { - ctx.SetInt(int(ss.Context.Cycle)) - }}}) - - vars := []string{"GeSyn", "Ge", "Gi", "Inet", "Vm", "Act", "Spike", "Gk", "ISI", "ISIAvg", "VmDend", "GnmdaSyn", "Gnmda", "GABAB", "GgabaB", "Gvgcc", "VgccM", "VgccH", "Gak", "MahpN", "GknaMed", "GknaSlow", "GiSyn", "CaSyn"} - - for _, vnm := range vars { - lg.AddItem(&elog.Item{ - Name: vnm, - Type: reflect.Float64, - FixMax: false, - Range: minmax.F32{Max: 1}, - Write: elog.WriteMap{ - etime.Scope(etime.Test, etime.Cycle): func(ctx *elog.Context) { - vl := ly.UnitValue(vnm, []int{0, 0}, 0) - ctx.SetFloat32(vl) - }}}) - } - - pj := ly.RcvPaths[0] - pvars := []string{"CaM", "CaP", "CaD", "CaUpT"} - for _, vnm := range pvars { - lg.AddItem(&elog.Item{ - Name: "Syn." + vnm, - Type: reflect.Float64, - FixMax: false, - Range: minmax.F32{Max: 1}, - Write: elog.WriteMap{ - etime.Scope(etime.Test, etime.Cycle): func(ctx *elog.Context) { - vl := pj.SynValue(vnm, 0, 0) - ctx.SetFloat32(vl) - }}}) - } -} - func (ss *Sim) ResetTstCycPlot() { ss.Logs.ResetLog(etime.Test, etime.Cycle) ss.GUI.UpdatePlot(etime.Test, etime.Cycle) } //////////////////////////////////////////////////////////////////////////////////////////// -// Gui - -func (ss *Sim) ConfigNetView(nv *netview.NetView) { - nv.ViewDefaults() -} +// GUI // ConfigGUI configures the Cogent Core GUI interface for this simulation. func (ss *Sim) ConfigGUI() { @@ -219,13 +139,6 @@ func (ss *Sim) ConfigGUI() { ss.GUI.MakeBody(ss, "kinaseq", title, `kinaseq: Explores calcium-based synaptic learning rules, specifically at the synaptic level. See README.md on GitHub.

`) ss.GUI.CycleUpdateInterval = 10 - nv := ss.GUI.AddNetView("NetView") - nv.Var = "Act" - nv.SetNet(ss.Net) - ss.ConfigNetView(nv) // add labels etc - ss.ViewUpdate.Config(nv, etime.AlphaCycle, etime.AlphaCycle) - ss.GUI.ViewUpdate = &ss.ViewUpdate - ss.GUI.AddPlots(title, &ss.Logs) // key := etime.Scope(etime.Test, etime.Cycle) // plt := ss.GUI.NewPlot(key, ss.GUI.Tabs.NewTab("TstCycPlot")) @@ -246,7 +159,7 @@ func (ss *Sim) ConfigGUI() { Tooltip: "Stops running.", Active: egui.ActiveRunning, Func: func() { - ss.Stop() + // ss.Stop() ss.GUI.UpdateWindow() }, }) @@ -292,34 +205,6 @@ func (ss *Sim) ConfigGUI() { } }, }) - ss.GUI.AddToolbarItem(tb, egui.ToolbarItem{Label: "Train", Icon: icons.PlayArrow, - Tooltip: "Train the Kinase approximation models.", - Active: egui.ActiveStopped, - Func: func() { - if !ss.GUI.IsRunning { - go func() { - ss.GUI.IsRunning = true - ss.Train() - ss.GUI.IsRunning = false - ss.GUI.UpdateWindow() - }() - } - }, - }) - ss.GUI.AddToolbarItem(tb, egui.ToolbarItem{Label: "Run Neuron", Icon: icons.PlayArrow, - Tooltip: "Runs neuron updating over NCycles.", - Active: egui.ActiveStopped, - Func: func() { - if !ss.GUI.IsRunning { - go func() { - ss.GUI.IsRunning = true - ss.RunCycles() - ss.GUI.IsRunning = false - ss.GUI.UpdateWindow() - }() - } - }, - }) core.NewSeparator(tb) ss.GUI.AddToolbarItem(tb, egui.ToolbarItem{Label: "Reset Plot", Icon: icons.Update, Tooltip: "Reset TstCycPlot.", @@ -349,13 +234,6 @@ func (ss *Sim) ConfigGUI() { }) }) ss.GUI.FinalizeGUI(false) - - if ss.Config.Run.GPU { - ss.Net.ConfigGPUwithGUI(&ss.Context) - core.TheApp.AddQuitCleanFunc(func() { - ss.Net.GPU.Destroy() - }) - } } func (ss *Sim) RunGUI() { @@ -371,34 +249,11 @@ func (ss *Sim) RunNoGUI() { if ss.Config.Log.SaveWts { mpi.Printf("Saving final weights per run\n") } - runName := ss.Params.RunName(ss.Config.Run.Run) - ss.Stats.SetString("RunName", runName) // used for naming logs, stats, etc - netName := ss.Net.Name() - - // netdata := ss.Config.Log.NetData - // if netdata { - // mpi.Printf("Saving NetView data from testing\n") - // ss.GUI.InitNetData(ss.Net, 200) - // } ss.Init() - - if ss.Config.Run.GPU { - ss.Net.ConfigGPUnoGUI(&ss.Context) - } - mpi.Printf("Set NThreads to: %d\n", ss.Net.NThreads) - - ss.RunCycles() - - if ss.Config.Log.Cycle { - dt := ss.Logs.Table(etime.Test, etime.Cycle) - fnm := ecmd.LogFilename("cyc", netName, runName) - dt.SaveCSV(core.Filename(fnm), table.Tab, table.Headers) - } - - // if netdata { - // ss.GUI.SaveNetData(ss.Stats.String("RunName")) + // if ss.Config.Log.Cycle { + // dt := ss.Logs.Table(etime.Test, etime.Cycle) + // // fnm := ecmd.LogFilename("cyc", netName, runName) + // dt.SaveCSV(core.Filename(fnm), table.Tab, table.Headers) // } - - ss.Net.GPU.Destroy() // safe even if no GPU } diff --git a/kinase/params.go b/kinase/params.go index 10290b416..4256e5ac2 100644 --- a/kinase/params.go +++ b/kinase/params.go @@ -132,26 +132,12 @@ type SynCaParams struct { //types:add // time constants for integrating at M, P, and D cascading levels Dt CaDtParams `view:"inline"` - - // Linear coefficients - CaP0, CaP1, CaP2, CaP3 float32 - CaD0, CaD1, CaD2, CaD3 float32 } func (kp *SynCaParams) Defaults() { kp.CaScale = 12 kp.Dt.Defaults() kp.Update() - - kp.CaP0 = 0.07 - kp.CaP1 = 0.3 - kp.CaP2 = 0.5 - kp.CaP3 = 0.6 - - kp.CaD0 = 0.25 - kp.CaD1 = 0.5 - kp.CaD2 = 0.5 - kp.CaD3 = 0.3 } func (kp *SynCaParams) Update() { @@ -165,12 +151,6 @@ func (kp *SynCaParams) FromCa(ca float32, caM, caP, caD *float32) { kp.Dt.FromCa(kp.CaScale*ca, caM, caP, caD) } -// FinalCa uses a linear regression to compute the final Ca values -func (kp *SynCaParams) FinalCa(bin0, bin1, bin2, bin3 float32, caP, caD *float32) { - *caP = kp.CaP0*bin0 + kp.CaP1*bin1 + kp.CaP2*bin2 + kp.CaP3*bin3 - *caD = kp.CaD0*bin0 + kp.CaD1*bin1 + kp.CaD2*bin2 + kp.CaD3*bin3 -} - // BinWeights are coefficients for computing Ca based on binned // spike counts, for linear regression computation. type BinWeights struct { //types:add