Example #1
0
    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()
Example #2
0
 def UpdateEnv(ss):
     if ss.Test == TestType.MultiObjs:
         ss.TestEnv.Table = etable.NewIdxView(ss.MultiObjs)
     if ss.Test == TestType.StdPosner:
         ss.TestEnv.Table = etable.NewIdxView(ss.StdPosner)
     if ss.Test == TestType.ClosePosner:
         ss.TestEnv.Table = etable.NewIdxView(ss.ClosePosner)
     if ss.Test == TestType.ReversePosner:
         ss.TestEnv.Table = etable.NewIdxView(ss.ReversePosner)
     if ss.Test == TestType.ObjAttn:
         ss.TestEnv.Table = etable.NewIdxView(ss.ObjAttn)
Example #3
0
 def SetPats(ss, partial):
     """
     SetPats selects which patterns to present: full or partial faces
     """
     if partial:
         ss.TestEnv.Table = etable.NewIdxView(ss.PartPats)
         ss.TestEnv.Validate()
         ss.TestEnv.Init(0)
     else:
         ss.TestEnv.Table = etable.NewIdxView(ss.Pats)
         ss.TestEnv.Validate()
         ss.TestEnv.Init(0)
Example #4
0
 def ConfigEnv(ss):
     ss.TestEnv.Nm = "TestEnv"
     ss.TestEnv.Dsc = "testing params and state"
     ss.TestEnv.Table = etable.NewIdxView(ss.Pats)
     ss.TestEnv.Sequential = True
     ss.TestEnv.Validate()
     ss.TestEnv.Init(0)
Example #5
0
    def LogRun(ss, dt):
        """
        LogRun adds data from current run to the RunLog table.
        """
        run = ss.TrainEnv.Run.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 = 10
        if nlast > epcix.Len() - 1:
            nlast = epcix.Len() - 1
        epcix.Idxs = epcix.Idxs[epcix.Len() - nlast - 1:]

        # params := ss.Params.Name
        params = "params"

        dt.SetCellFloat("Run", row, float(run))
        dt.SetCellString("Params", row, params)

        # runix := etable.NewIdxView(dt)
        # spl := split.GroupBy(runix, []string{"Params"})
        # split.Desc(spl, "FirstZero")
        # split.Desc(spl, "PctCor")
        # 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 != 0:
            if row == 0:
                dt.WriteCSVHeaders(ss.RunFile, etable.Tab)
            dt.WriteCSVRow(ss.RunFile, row, etable.Tab)
Example #6
0
    def ConfigEnv(ss):
        if ss.MaxRuns == 0:
            ss.MaxRuns = 1
        if ss.MaxEpcs == 0:  # allow user override
            ss.MaxEpcs = 100
            ss.NZeroStop = -1
        if ss.MaxTrls == 0:  # allow user override
            ss.MaxTrls = 100

        ss.TrainEnv.Nm = "TrainEnv"
        ss.TrainEnv.Dsc = "training params and state"
        ss.TrainEnv.Defaults()
        ss.TrainEnv.ImageFiles = [
            "v1rf_img1.jpg", "v1rf_img2.jpg", "v1rf_img3.jpg", "v1rf_img4.jpg"
        ]
        ss.TrainEnv.OpenImages()
        ss.TrainEnv.Validate()
        ss.TrainEnv.Run.Max = ss.MaxRuns  # note: we are not setting epoch max -- do that manually
        ss.TrainEnv.Trial.Max = ss.MaxTrls

        ss.TestEnv.Nm = "TestEnv"
        ss.TestEnv.Dsc = "testing (probe) params and state"
        ss.TestEnv.Table = etable.NewIdxView(ss.Probes)
        ss.TestEnv.Sequential = True
        ss.TestEnv.Validate()

        ss.TrainEnv.Init(0)
        ss.TestEnv.Init(0)
Example #7
0
    def LogRun(ss, dt):
        """
        LogRun adds data from current run to the RunLog table.
        """
        run = ss.TrainEnv.Run.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:]

        params = "Std"
        # if ss.AvgLGain != 2.5 {
        #     params += "_AvgLGain=%s" % (ss.AvgLGain)
        # }
        # if ss.InputNoise != 0 {
        #     params += "_InVar=%v" % (ss.InputNoise)
        # }

        dt.SetCellFloat("Run", row, float(run))
        dt.SetCellString("Params", row, params)

        # runix := etable.NewIdxView(dt)
        # spl := split.GroupBy(runix, []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()
Example #8
0
    def ConfigEnv(ss):
        if ss.MaxRuns == 0:  # allow user override
            ss.MaxRuns = 1
        if ss.MaxEpcs == 0:  # allow user override
            ss.MaxEpcs = 1

        ss.TrainEnv.Nm = "TrainEnv"
        ss.TrainEnv.Dsc = "training params and state"
        if ss.Delay == Delays.Delay3:
            ss.TrainEnv.Table = etable.NewIdxView(ss.Delay3Pats)
        if ss.Delay == Delays.Delay5:
            ss.TrainEnv.Table = etable.NewIdxView(ss.Delay5Pats)
        if ss.Delay == Delays.Delay1:
            ss.TrainEnv.Table = etable.NewIdxView(ss.Delay1Pats)
        ss.TrainEnv.Sequential = True
        ss.TrainEnv.Validate()
        ss.TrainEnv.Run.Max = ss.MaxRuns  # note: we are not setting epoch max -- do that manually

        ss.TrainEnv.Init(0)
Example #9
0
    def ConfigEnv(ss):
        if ss.MaxRuns == 0:
            ss.MaxRuns = 8
        if ss.MaxEpcs == 0: # allow user override
            ss.MaxEpcs = 30

        ss.TrainEnv.Nm = "TrainEnv"
        ss.TrainEnv.Dsc = "training params and state"
        ss.TrainEnv.Table = etable.NewIdxView(ss.Lines2)
        ss.TrainEnv.Validate()
        ss.TrainEnv.Run.Max = ss.MaxRuns # note: we are not setting epoch max -- do that manually

        ss.TestEnv.Nm = "TestEnv"
        ss.TestEnv.Dsc = "testing params and state"
        ss.TestEnv.Table = etable.NewIdxView(ss.Lines1)
        ss.TestEnv.Sequential = True
        ss.TestEnv.Validate()

        ss.TrainEnv.Init(0)
        ss.TestEnv.Init(0)
Example #10
0
    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)
Example #11
0
 def UpdateEnv(ss):
     if ss.Pats == PatsType.Easy:
         ss.TrainEnv.Table = etable.NewIdxView(ss.Easy)
         ss.TestEnv.Table = etable.NewIdxView(ss.Easy)
     elif ss.Pats == PatsType.Hard:
         ss.TrainEnv.Table = etable.NewIdxView(ss.Hard)
         ss.TestEnv.Table = etable.NewIdxView(ss.Hard)
     elif ss.Pats == PatsType.Impossible:
         ss.TrainEnv.Table = etable.NewIdxView(ss.Impossible)
         ss.TestEnv.Table = etable.NewIdxView(ss.Impossible)
Example #12
0
    def ClustPlot(ss, plt, dt, colNm):
        """
        ClustPlot does one cluster plot on given table column
        """
        ix = etable.NewIdxView(dt)
        smat = simat.SimMat()
        smat.TableColStd(ix, colNm, "Name", False, metric.Euclidean)
        pt = etable.Table()
        clust.Plot(pt, clust.GlomStd(smat, clust.Min), smat)
        plt.InitName(plt, colNm)
        plt.Params.Title = "Cluster Plot of Faces " + colNm
        plt.Params.XAxisCol = "X"
        plt.SetTable(pt)

        plt.SetColParams("X", eplot.Off, eplot.FixMin, 0, eplot.FloatMax, 0)
        plt.SetColParams("Y", eplot.On, eplot.FixMin, 0, eplot.FloatMax, 0)
        plt.SetColParams("Label", eplot.On, eplot.FixMin, 0, eplot.FloatMax, 0)
Example #13
0
 def UpdateEnv(ss):
     if ss.Pats == PatsType.Easy:
         ss.TrainEnv.Table = etable.NewIdxView(ss.Easy)
         ss.TestEnv.Table = etable.NewIdxView(ss.Easy)
     elif ss.Pats == PatsType.Hard:
         ss.TrainEnv.Table = etable.NewIdxView(ss.Hard)
         ss.TestEnv.Table = etable.NewIdxView(ss.Hard)
     elif ss.Pats == PatsType.Impossible:
         ss.TrainEnv.Table = etable.NewIdxView(ss.Impossible)
         ss.TestEnv.Table = etable.NewIdxView(ss.Impossible)
     elif ss.Pats == PatsType.Lines2:
         all = etable.NewIdxView(ss.Lines2)
         splits = split.Permuted(all, go.Slice_float64([.9, .1]), go.Slice_string(["Train", "Test"]))
         ss.TrainEnv.Table = splits.Splits[0]
         ss.TestEnv.Table = splits.Splits[1]
Example #14
0
    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()
Example #15
0
 def UniquePatStat(ss, dt):
     """
     UniquePatStat analyzes the hidden activity patterns for the single-line test inputs
     to determine how many such lines have a distinct hidden pattern, as computed
     from the similarity matrix across patterns
     """
     hc = etensor.Float64(dt.ColByName("Hidden"))
     norm.Binarize64(hc.Values, .5, 1, 0)
     ix = etable.NewIdxView(dt)
     ss.SimMat.TableColStd(ix, "Hidden", "TrialName", False, metric.SumSquares)
     dm = ss.SimMat.Mat
     nrow = dm.Dim(0)
     uniq = 0
     for row in range(nrow):
         tsr = etensor.Float64(dm.SubSpace(go.Slice_int([row])))
         nzero = 0
         for vl in tsr.Values:
             if vl == 0:
                 nzero += 1
         if nzero == 1:
             uniq += 1
     return float(uniq)
Example #16
0
 def TestStats(ss):
     dt = ss.TstTrlLog
     runix = etable.NewIdxView(dt)
     spl = split.GroupBy(runix, go.Slice_string(["TrialName"]))
     split.Desc(spl, "Cycle")
     ss.TstStats = spl.AggsToTable(etable.AddAggName)