Skip to content

Commit

Permalink
IMPORTANT: includes API change to etable WriteCSVRow -- drop last boo…
Browse files Browse the repository at this point in the history
…l arg (usu true). full TableView gui ops in place: DND, copy/paste, duplicate, etc.
  • Loading branch information
Randall C. O'Reilly committed Dec 29, 2019
1 parent f66f958 commit e47d098
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 83 deletions.
2 changes: 1 addition & 1 deletion examples/bench/bench.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,5 +244,5 @@ func main() {

TrainNet(Net, Pats, EpcLog, epochs)

EpcLog.SaveCSV("bench_epc.dat", ',', true)
EpcLog.SaveCSV("bench_epc.dat", ',', etable.Headers)
}
4 changes: 2 additions & 2 deletions examples/deep_fsa/deep_fsa.go
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ func (ss *Sim) LogTrnEpc(dt *etable.Table) {
if ss.TrainEnv.Run.Cur == 0 && epc == 0 {
dt.WriteCSVHeaders(ss.TrnEpcFile, etable.Tab)
}
dt.WriteCSVRow(ss.TrnEpcFile, row, etable.Tab, true)
dt.WriteCSVRow(ss.TrnEpcFile, row, etable.Tab)
}
}

Expand Down Expand Up @@ -1150,7 +1150,7 @@ func (ss *Sim) LogRun(dt *etable.Table) {
if row == 0 {
dt.WriteCSVHeaders(ss.RunFile, etable.Tab)
}
dt.WriteCSVRow(ss.RunFile, row, etable.Tab, true)
dt.WriteCSVRow(ss.RunFile, row, etable.Tab)
}
}

Expand Down
30 changes: 19 additions & 11 deletions examples/hip/hip.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,9 @@ func (ss *Sim) NewRndSeed() {
// and add a few tabs at the end to allow for expansion..
func (ss *Sim) Counters(train bool) string {
if train {
return fmt.Sprintf("Run:\t%d\tEpoch:\t%d\tTrial:\t%d\tCycle:\t%d\tName:\t%v\t\t\t", ss.TrainEnv.Run.Cur, ss.TrainEnv.Epoch.Cur, ss.TrainEnv.Trial.Cur, ss.Time.Cycle, ss.TrainEnv.TrialName)
return fmt.Sprintf("Run:\t%d\tEpoch:\t%d\tTrial:\t%d\tCycle:\t%d\tName:\t%v\t\t\t", ss.TrainEnv.Run.Cur, ss.TrainEnv.Epoch.Cur, ss.TrainEnv.Trial.Cur, ss.Time.Cycle, ss.TrainEnv.TrialName.Cur)
} else {
return fmt.Sprintf("Run:\t%d\tEpoch:\t%d\tTrial:\t%d\tCycle:\t%d\tName:\t%v\t\t\t", ss.TrainEnv.Run.Cur, ss.TrainEnv.Epoch.Cur, ss.TestEnv.Trial.Cur, ss.Time.Cycle, ss.TestEnv.TrialName)
return fmt.Sprintf("Run:\t%d\tEpoch:\t%d\tTrial:\t%d\tCycle:\t%d\tName:\t%v\t\t\t", ss.TrainEnv.Run.Cur, ss.TrainEnv.Epoch.Cur, ss.TestEnv.Trial.Cur, ss.Time.Cycle, ss.TestEnv.TrialName.Cur)
}
}

Expand Down Expand Up @@ -1122,7 +1122,7 @@ func (ss *Sim) LogTrnEpc(dt *etable.Table) {
if ss.TrainEnv.Run.Cur == 0 && epc == 0 {
dt.WriteCSVHeaders(ss.TrnEpcFile, etable.Tab)
}
dt.WriteCSVRow(ss.TrnEpcFile, row, etable.Tab, true)
dt.WriteCSVRow(ss.TrnEpcFile, row, etable.Tab)
}
}

Expand Down Expand Up @@ -1168,7 +1168,7 @@ func (ss *Sim) ConfigTrnEpcPlot(plt *eplot.Plot2D, dt *etable.Table) *eplot.Plot
plt.SetColParams("TrgOffWasOn", eplot.On, eplot.FixMin, 0, eplot.FixMax, 1) // default plot

for _, lnm := range ss.LayStatNms {
plt.SetColParams(lnm+" ActAvg", eplot.Off, eplot.FixMin, 0, eplot.FixMax, .5)
plt.SetColParams(lnm+" ActAvg", eplot.Off, eplot.FixMin, 0, eplot.FixMax, 0.5)
}
return plt
}
Expand Down Expand Up @@ -1246,8 +1246,11 @@ func (ss *Sim) ConfigTstTrlLog(dt *etable.Table) {

func (ss *Sim) ConfigTstTrlPlot(plt *eplot.Plot2D, dt *etable.Table) *eplot.Plot2D {
plt.Params.Title = "Hippocampus Test Trial Plot"
plt.Params.XAxisCol = "Trial"
plt.SetTable(dt)
plt.Params.XAxisCol = "TrialName"
plt.Params.Type = eplot.Bar
plt.SetTable(dt) // this sets defaults so set params after
plt.Params.BarWidth = 5
plt.Params.XAxisRot = 45
// order of params: on, fixMin, min, fixMax, max
plt.SetColParams("Run", eplot.Off, eplot.FixMin, 0, eplot.FloatMax, 0)
plt.SetColParams("Epoch", eplot.Off, eplot.FixMin, 0, eplot.FloatMax, 0)
Expand All @@ -1263,7 +1266,7 @@ func (ss *Sim) ConfigTstTrlPlot(plt *eplot.Plot2D, dt *etable.Table) *eplot.Plot
plt.SetColParams("TrgOffWasOn", eplot.On, eplot.FixMin, 0, eplot.FixMax, 1)

for _, lnm := range ss.LayStatNms {
plt.SetColParams(lnm+" ActM.Avg", eplot.Off, eplot.FixMin, 0, eplot.FixMax, .5)
plt.SetColParams(lnm+" ActM.Avg", eplot.Off, eplot.FixMin, 0, eplot.FixMax, 0.5)
}

// plt.SetColParams("InAct", eplot.Off, eplot.FixMin, 0, eplot.FixMax, 1)
Expand Down Expand Up @@ -1358,7 +1361,7 @@ func (ss *Sim) ConfigTstEpcLog(dt *etable.Table) {
func (ss *Sim) ConfigTstEpcPlot(plt *eplot.Plot2D, dt *etable.Table) *eplot.Plot2D {
plt.Params.Title = "Hippocampus Testing Epoch Plot"
plt.Params.XAxisCol = "Epoch"
plt.SetTable(dt)
plt.SetTable(dt) // this sets defaults so set params after
// order of params: on, fixMin, min, fixMax, max
plt.SetColParams("Run", eplot.Off, eplot.FixMin, 0, eplot.FloatMax, 0)
plt.SetColParams("Epoch", eplot.Off, eplot.FixMin, 0, eplot.FloatMax, 0)
Expand Down Expand Up @@ -1476,15 +1479,15 @@ func (ss *Sim) LogRun(dt *etable.Table) {
split.Desc(spl, nm)
}
split.Desc(spl, "FirstZero")
ss.RunStats = spl.AggsToTable(false)
ss.RunStats = spl.AggsToTable(etable.AddAggName)

// note: essential to use Go version of update when called from another goroutine
ss.RunPlot.GoUpdate()
if ss.RunFile != nil {
if row == 0 {
dt.WriteCSVHeaders(ss.RunFile, etable.Tab)
}
dt.WriteCSVRow(ss.RunFile, row, etable.Tab, true)
dt.WriteCSVRow(ss.RunFile, row, etable.Tab)
}
}

Expand Down Expand Up @@ -1596,7 +1599,7 @@ func (ss *Sim) ConfigGui() *gi.Window {
plt = tv.AddNewTab(eplot.KiT_Plot2D, "RunPlot").(*eplot.Plot2D)
ss.RunPlot = ss.ConfigRunPlot(plt, ss.RunLog)

split.SetSplits(.3, .7)
split.SetSplits(.2, .8)

tbar.AddAction(gi.ActOpts{Label: "Init", Icon: "update", Tooltip: "Initialize everything including network weights, and start over. Also applies current params.", UpdateFunc: func(act *gi.Action) {
act.SetActiveStateUpdt(!ss.IsRunning)
Expand Down Expand Up @@ -1826,8 +1829,10 @@ func (ss *Sim) CmdArgs() {
var nogui bool
var saveEpcLog bool
var saveRunLog bool
var note string
flag.StringVar(&ss.ParamSet, "params", "", "ParamSet name to use -- must be valid name as listed in compiled-in params or loaded params")
flag.StringVar(&ss.Tag, "tag", "", "extra tag to add to file names saved from this run")
flag.StringVar(&note, "note", "", "user note -- describe the run params etc")
flag.IntVar(&ss.MaxRuns, "runs", 10, "number of runs to do (note that MaxEpcs is in paramset)")
flag.BoolVar(&ss.LogSetParams, "setparams", false, "if true, print a record of each parameter that is set")
flag.BoolVar(&ss.SaveWts, "wts", false, "if true, save final weights after each run")
Expand All @@ -1837,6 +1842,9 @@ func (ss *Sim) CmdArgs() {
flag.Parse()
ss.Init()

if note != "" {
fmt.Printf("note: %s\n", note)
}
if ss.ParamSet != "" {
fmt.Printf("Using ParamSet: %s\n", ss.ParamSet)
}
Expand Down
6 changes: 3 additions & 3 deletions examples/ra25/ra25.go
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ func (ss *Sim) ConfigPats() {

patgen.PermutedBinaryRows(dt.Cols[1], 6, 1, 0)
patgen.PermutedBinaryRows(dt.Cols[2], 6, 1, 0)
dt.SaveCSV("random_5x5_25_gen.csv", etable.Comma, true)
dt.SaveCSV("random_5x5_25_gen.csv", etable.Comma, etable.Headers)
}

func (ss *Sim) OpenPats() {
Expand Down Expand Up @@ -834,7 +834,7 @@ func (ss *Sim) LogTrnEpc(dt *etable.Table) {
if ss.TrainEnv.Run.Cur == 0 && epc == 0 {
dt.WriteCSVHeaders(ss.TrnEpcFile, etable.Tab)
}
dt.WriteCSVRow(ss.TrnEpcFile, row, etable.Tab, true)
dt.WriteCSVRow(ss.TrnEpcFile, row, etable.Tab)
}
}

Expand Down Expand Up @@ -1144,7 +1144,7 @@ func (ss *Sim) LogRun(dt *etable.Table) {
if row == 0 {
dt.WriteCSVHeaders(ss.RunFile, etable.Tab)
}
dt.WriteCSVRow(ss.RunFile, row, etable.Tab, true)
dt.WriteCSVRow(ss.RunFile, row, etable.Tab)
}
}

Expand Down
Loading

0 comments on commit e47d098

Please sign in to comment.