def LogRun(ss, dt): """ LogRun adds data from current run to the RunLog table. """ run = ss.TrainEnv.Run.Cur # this is NOT triggered by increment yet -- use Cur row = dt.Rows dt.SetNumRows(row + 1) epclog = ss.TrnEpcLog epcix = etable.NewIdxView(epclog) # compute mean over last N epochs for run level nlast = 1 if nlast > epcix.Len()-1: nlast = epcix.Len() - 1 epcix.Idxs = epcix.Idxs[epcix.Len()-nlast-1:] params = "Std" if ss.AvgLGain != 2.5: params += "_AvgLGain=%s" % (ss.AvgLGain) if ss.InputNoise != 0: params += "_InVar=%s" % (ss.InputNoise) dt.SetCellFloat("Run", row, float(run)) dt.SetCellString("Params", row, params) dt.SetCellFloat("UniqPats", row, agg.Mean(epcix, "UniqPats")[0]) runix = etable.NewIdxView(dt) spl = split.GroupBy(runix, go.Slice_string(["Params"])) split.Desc(spl, "UniqPats") ss.RunStats = spl.AggsToTable(etable.AddAggName) # note: essential to use Go version of update when called from another goroutine ss.RunPlot.GoUpdate()
def LogRun(ss, dt): """ LogRun adds data from current run to the RunLog table. """ run = ss.TrainEnv.Run.Cur # this is NOT triggered by increment yet -- use Cur row = dt.Rows dt.SetNumRows(row + 1) epclog = ss.TstEpcLog epcix = etable.NewIdxView(epclog) # compute mean over last N epochs for run level nlast = 5 if nlast > epcix.Len()-1: nlast = epcix.Len() - 1 epcix.Idxs = go.Slice_int(epcix.Idxs[epcix.Len()-nlast:]) params = ss.Learn.name + "_" + ss.Pats.name dt.SetCellFloat("Run", row, float(run)) dt.SetCellString("Params", row, params) dt.SetCellFloat("FirstZero", row, float(ss.FirstZero)) dt.SetCellFloat("SSE", row, agg.Mean(epcix, "SSE")[0]) dt.SetCellFloat("AvgSSE", row, agg.Mean(epcix, "AvgSSE")[0]) dt.SetCellFloat("PctErr", row, agg.Mean(epcix, "PctErr")[0]) dt.SetCellFloat("PctCor", row, agg.Mean(epcix, "PctCor")[0]) dt.SetCellFloat("CosDiff", row, agg.Mean(epcix, "CosDiff")[0]) runix = etable.NewIdxView(dt) spl = split.GroupBy(runix, go.Slice_string(["Params"])) split.Desc(spl, "FirstZero") split.Desc(spl, "PctCor") split.Desc(spl, "SSE") ss.RunStats = spl.AggsToTable(etable.AddAggName) # note: essential to use Go version of update when called from another goroutine if ss.RunPlot != 0: ss.RunPlot.GoUpdate() if ss.RunFile != 0: if row == 0: dt.WriteCSVHeaders(ss.RunFile, etable.Tab) dt.WriteCSVRow(ss.RunFile, row, etable.Tab)
def LogTstEpc(ss, dt): row = dt.Rows dt.SetNumRows(row + 1) trl = ss.TstTrlLog tix = etable.NewIdxView(trl) epc = ss.TrainEnv.Epoch.Prv # ? # note: this shows how to use agg methods to compute summary data from another # data table, instead of incrementing on the Sim dt.SetCellFloat("Run", row, float(ss.TrainEnv.Run.Cur)) dt.SetCellFloat("Epoch", row, float(epc)) dt.SetCellFloat("SSE", row, agg.Sum(tix, "SSE")[0]) dt.SetCellFloat("AvgSSE", row, agg.Mean(tix, "AvgSSE")[0]) dt.SetCellFloat("PctErr", row, agg.Mean(tix, "Err")[0]) dt.SetCellFloat("PctCor", row, 1 - agg.Mean(tix, "Err")[0]) dt.SetCellFloat("CosDiff", row, agg.Mean(tix, "CosDiff")[0]) # note: essential to use Go version of update when called from another goroutine if ss.TstEpcPlot != 0: ss.TstEpcPlot.GoUpdate()