Esempio n. 1
0
 def __init__(self):
     super(Vis, self).__init__()
     self.ClipToFit = True
     self.SetTags(
         "ClipToFit",
         'desc:"if true, and input image is larger than target image size, central region is clipped out as the input -- otherwise image is sized to target size"'
     )
     self.DoG = dog.Filter()
     self.SetTags("DoG", 'desc:"LGN DoG filter parameters"')
     self.Geom = vfilter.Geom()
     self.SetTags(
         "Geom",
         'inactive:"+" view:"inline" desc:"geometry of input, output"')
     self.ImgSize = image.Point()
     self.SetTags(
         "ImgSize",
         'desc:"target image size to use -- images will be rescaled to this size"'
     )
     self.DoGTsr = etensor.Float32()
     self.SetTags("DoGTsr", 'view:"no-inline" desc:"DoG filter tensor"')
     self.Img = image.Image()
     self.SetTags("Img", 'view:"-" desc:"current input image"')
     self.ImgTsr = etensor.Float32()
     self.SetTags("ImgTsr", 'view:"no-inline" desc:"input image as tensor"')
     self.OutTsr = etensor.Float32()
     self.SetTags("OutTsr",
                  'view:"no-inline" desc:"DoG filter output tensor"')
Esempio n. 2
0
 def __init__(self):
     super(ImgEnv, self).__init__()
     self.Nm = str()
     self.SetTags("Nm", 'desc:"name of this environment"')
     self.Dsc = str()
     self.SetTags("Dsc", 'desc:"description of this environment"')
     self.ImageFiles = []
     self.SetTags("ImageFiles", 'desc:"paths to images"')
     self.Images = []
     self.SetTags("Images", 'desc:"images (preload for speed)"')
     self.ImageIdx = env.CurPrvInt()
     self.SetTags("ImageIdx", 'desc:"current image index"')
     self.Vis = Vis()
     self.SetTags("Vis", 'desc:"visual processing params"')
     self.XFormRand = vxform.Rand()
     self.SetTags("XFormRand", 'desc:"random transform parameters"')
     self.XForm = vxform.XForm()
     self.SetTags("XForm", 'desc:"current -- prev transforms"')
     self.Run = env.Ctr()
     self.SetTags(
         "Run",
         'view:"inline" desc:"current run of model as provided during Init"'
     )
     self.Epoch = env.Ctr()
     self.SetTags(
         "Epoch",
         'view:"inline" desc:"number of times through Seq.Max number of sequences"'
     )
     self.Trial = env.Ctr()
     self.SetTags(
         "Trial",
         'view:"inline" desc:"trial is the step counter within epoch"')
     self.OrigImg = etensor.Float32()
     self.SetTags("OrigImg",
                  'desc:"original image prior to random transforms"')
Esempio n. 3
0
 def __init__(self):
     super(ProbeEnv, self).__init__()
     self.Nm = str()
     self.SetTags("Nm", 'desc:"name of this environment"')
     self.Dsc = str()
     self.SetTags("Dsc", 'desc:"description of this environment"')
     self.Words = go.Slice_string()
     self.SetTags(
         "Words",
         'desc:"list of words used for activating state units according to index"'
     )
     self.WordState = etensor.Float32()
     self.SetTags("WordState", 'desc:"current sentence activation state"')
     self.Run = env.Ctr()
     self.SetTags(
         "Run",
         'view:"inline" desc:"current run of model as provided during Init"'
     )
     self.Epoch = env.Ctr()
     self.SetTags(
         "Epoch",
         'view:"inline" desc:"number of times through Seq.Max number of sequences"'
     )
     self.Trial = env.Ctr()
     self.SetTags(
         "Trial",
         'view:"inline" desc:"trial is the step counter within sequence - how many steps taken within current sequence -- it resets to 0 at start of each sequence"'
     )
Esempio n. 4
0
 def __init__(self):
     super(LEDEnv, self).__init__()
     self.Nm = str()
     self.SetTags("Nm", 'desc:"name of this environment"')
     self.Dsc = str()
     self.SetTags("Dsc", 'desc:"description of this environment"')
     self.Draw = LEDraw()
     self.SetTags("Draw", 'desc:"draws LEDs onto image"')
     self.Vis = Vis()
     self.SetTags("Vis", 'desc:"visual processing params"')
     self.MinLED = int()
     self.SetTags(
         "MinLED",
         'min:"0" max:"19" desc:"minimum LED number to draw (0-19)"')
     self.MaxLED = int()
     self.SetTags(
         "MaxLED",
         'min:"0" max:"19" desc:"maximum LED number to draw (0-19)"')
     self.CurLED = int()
     self.SetTags("CurLED",
                  'inactive:"+" desc:"current LED number that was drawn"')
     self.PrvLED = int()
     self.SetTags("PrvLED",
                  'inactive:"+" desc:"previous LED number that was drawn"')
     self.XFormRand = vxform.Rand()
     self.SetTags("XFormRand", 'desc:"random transform parameters"')
     self.XForm = vxform.XForm()
     self.SetTags("XForm", 'desc:"current -- prev transforms"')
     self.Run = env.Ctr()
     self.SetTags(
         "Run",
         'view:"inline" desc:"current run of model as provided during Init"'
     )
     self.Epoch = env.Ctr()
     self.SetTags(
         "Epoch",
         'view:"inline" desc:"number of times through Seq.Max number of sequences"'
     )
     self.Trial = env.Ctr()
     self.SetTags(
         "Trial",
         'view:"inline" desc:"trial is the step counter within epoch"')
     self.OrigImg = etensor.Float32()
     self.SetTags("OrigImg",
                  'desc:"original image prior to random transforms"')
     self.Output = etensor.Float32()
     self.SetTags("Output", 'desc:"CurLED one-hot output tensor"')
Esempio n. 5
0
 def ValsTsr(ss, name):
     """
     ValsTsr gets value tensor of given name, creating if not yet made
     """
     if name in ss.ValsTsrs:
         return ss.ValsTsrs[name]
     tsr = etensor.Float32()
     ss.ValsTsrs[name] = tsr
     return tsr
Esempio n. 6
0
    def PrjnPlot(ss):
        ss.TestAll()

        rvec0 = ss.ValsTsr("rvec0")
        rvec1 = ss.ValsTsr("rvec1")
        rvec0.SetShape(go.Slice_int([256]), go.nil, go.nil)
        rvec1.SetShape(go.Slice_int([256]), go.nil, go.nil)
        for i in range(256):
            rvec0.Values[i] = .15 * (2*rand.Float32() - 1)
            rvec1.Values[i] = .15 * (2*rand.Float32() - 1)

        tst = ss.TstTrlLog
        nr = tst.Rows
        dt = ss.PrjnTable
        ss.ConfigPrjnTable(dt)

        for r in range(nr):
            emote = 0.5*tst.CellTensorFloat1D("Emotion", r, 0) + -0.5*tst.CellTensorFloat1D("Emotion", r, 1)
            emote += .1 * (2*rand.Float64() - 1)

            gend = 0.5*tst.CellTensorFloat1D("Gender", r, 0) + -0.5*tst.CellTensorFloat1D("Gender", r, 1)
            gend += .1 * (2*rand.Float64() - 1) # some jitter so labels are readable
            input = etensor.Float32(tst.CellTensor("Input", r))
            rprjn0 = metric.InnerProduct32(rvec0.Values, input.Values)
            rprjn1 = metric.InnerProduct32(rvec1.Values, input.Values)
            dt.SetCellFloat("Trial", r, tst.CellFloat("Trial", r))
            dt.SetCellString("TrialName", r, tst.CellString("TrialName", r))
            dt.SetCellFloat("GendPrjn", r, gend)
            dt.SetCellFloat("EmotePrjn", r, emote)
            dt.SetCellFloat("RndPrjn0", r, float(rprjn0))
            dt.SetCellFloat("RndPrjn1", r, float(rprjn1))

        plt = ss.PrjnRandom
        plt.InitName(plt, "PrjnRandom")
        plt.Params.Title = "Face Random Prjn Plot"
        plt.Params.XAxisCol = "RndPrjn0"
        plt.SetTable(dt)
        plt.Params.Lines = False
        plt.Params.Points = True
        # order of params: on, fixMin, min, fixMax, max
        plt.SetColParams("TrialName", eplot.On, eplot.FixMin, 0, eplot.FloatMax, 0)
        plt.SetColParams("RndPrjn0", eplot.Off, eplot.FixMin, -1, eplot.FixMax, 1)
        plt.SetColParams("RndPrjn1", eplot.On, eplot.FixMin, -1, eplot.FixMax, 1)

        plt = ss.PrjnEmoteGend
        plt.InitName(plt, "PrjnEmoteGend")
        plt.Params.Title = "Face Emotion / Gender Prjn Plot"
        plt.Params.XAxisCol = "GendPrjn"
        plt.SetTable(dt)
        plt.Params.Lines = False
        plt.Params.Points = True
        # order of params: on, fixMin, min, fixMax, max
        plt.SetColParams("TrialName", eplot.On, eplot.FixMin, 0, eplot.FloatMax, 0)
        plt.SetColParams("GendPrjn", eplot.Off, eplot.FixMin, -1, eplot.FixMax, 1)
        plt.SetColParams("EmotePrjn", eplot.On, eplot.FixMin, -1, eplot.FixMax, 1)
Esempio n. 7
0
 def MtxInput(ss, dt):
     col = etensor.Float32(dt)
     vals = col.Values
     inp = leabra.Layer(ss.Net.LayerByName("Input"))
     isz = inp.Shape().Len()
     hid = leabra.Layer(ss.Net.LayerByName("MatrixGo"))
     ysz = hid.Shape().Dim(2)
     xsz = hid.Shape().Dim(3)
     for y in range(ysz):
         for x in range(xsz):
             ui = (y * xsz + x)
             ust = ui * isz
             vls = vals[ust:ust + isz]
             inp.SendPrjnVals(vls, "Wt", hid, ui, "")
Esempio n. 8
0
 def __init__(self):
     super(SemEnv, self).__init__()
     self.Nm = str()
     self.SetTags("Nm", 'desc:"name of this environment"')
     self.Dsc = str()
     self.SetTags("Dsc", 'desc:"description of this environment"')
     self.Sequential = False
     self.SetTags(
         "Sequential",
         'desc:"if true, go sequentially through paragraphs -- else permuted"'
     )
     self.Order = go.Slice_int()
     self.SetTags(
         "Order",
         'desc:"permuted order of paras to present if not sequential -- updated every time through the list"'
     )
     self.TextFiles = []
     self.SetTags("TextFiles", 'desc:"paths to text files"')
     self.Words = go.Slice_string()
     self.SetTags("Words", 'desc:"list of words, in alpha order"')
     self.WordMap = {}
     self.SetTags("WordMap",
                  'view:"-" desc:"map of words onto index in Words list"')
     self.CurParaState = etensor.Float32()
     self.SetTags("CurParaState", 'desc:"current para activation state"')
     self.Paras = []
     self.SetTags("Paras", 'view:"-" desc:"paragraphs"')
     self.ParaLabels = []
     self.SetTags(
         "ParaLabels",
         'view:"-" desc:"special labels for each paragraph (provided in first word of para)"'
     )
     self.Run = env.Ctr()
     self.SetTags(
         "Run",
         'view:"inline" desc:"current run of model as provided during Init"'
     )
     self.Epoch = env.Ctr()
     self.SetTags(
         "Epoch",
         'view:"inline" desc:"number of times through Seq.Max number of sequences"'
     )
     self.Trial = env.Ctr()
     self.SetTags(
         "Trial",
         'view:"inline" desc:"trial is the step counter within epoch -- this is the index into Paras"'
     )
Esempio n. 9
0
    def Numpy(ss):
        """
        test conversions to / from numpy
        """
        dt = ss.Pats

        print("\n\n##############################")
        print("to / from numpy")
        etf = etensor.Float32(dt.Cols[1])
        npf = pyet.etensor_to_numpy(etf)
        print(npf)
        ctf = pyet.numpy_to_etensor(npf)
        print(ctf)
        
        etu32 = etensor.NewUint32(go.Slice_int([3,4,5]), go.nil, go.nil)
        sz = etf.Len()
        for i in range(sz):
            etu32.Values[i] = int(etf.Values[i])
        print(etu32)
        npu32 = pyet.etensor_to_numpy(etu32)
        print(npu32)
        ctu32 = pyet.numpy_to_etensor(npu32)
        print(ctu32)
        pyet.copy_etensor_to_numpy(npu32, etu32)
        pyet.copy_numpy_to_etensor(etu32, npu32)
        
        ets = etensor.String(dt.Cols[0])
        nps = pyet.etensor_to_numpy(ets)
        print(nps)
        cts = pyet.numpy_to_etensor(nps)
        print(cts)
        pyet.copy_etensor_to_numpy(nps, ets)
        pyet.copy_numpy_to_etensor(ets, nps)
        
        etb = etensor.NewBits(go.Slice_int([3,4,5]), go.nil, go.nil)
        sz = etb.Len()
        for i in range(sz):
            etb.Set1D(i, erand.BoolProb(.2, -1))
        print(etb)
        npb = pyet.etensor_to_numpy(etb)
        print(npb)
        ctb = pyet.numpy_to_etensor(npb)
        print(ctb)
        pyet.copy_etensor_to_numpy(npb, etb)
        pyet.copy_numpy_to_etensor(etb, npb)
Esempio n. 10
0
def etensor_to_numpy(et):
    """
    returns a numpy ndarray constructed from the given etensor.Tensor.
    data is copied into the numpy ndarray -- it is not a view.
    """
    nar = 0
    if et.DataType() == etensor.UINT8:
        nar = np.array(etensor.Uint8(et).Values, dtype=np.uint8)
    elif et.DataType() == etensor.INT8:
        nar = np.array(etensor.Int8(et).Values, dtype=np.int8)
    elif et.DataType() == etensor.UINT16:
        nar = np.array(etensor.Uint16(et).Values, dtype=np.uint16)
    elif et.DataType() == etensor.INT16:
        nar = np.array(etensor.Int16(et).Values, dtype=np.int16)
    elif et.DataType() == etensor.UINT32:
        nar = np.array(etensor.Uint32(et).Values, dtype=np.uint32)
    elif et.DataType() == etensor.INT32:
        nar = np.array(etensor.Int32(et).Values, dtype=np.int32)
    elif et.DataType() == etensor.UINT64:
        nar = np.array(etensor.Uint64(et).Values, dtype=np.uint64)
    elif et.DataType() == etensor.INT64:
        nar = np.array(etensor.Int64(et).Values, dtype=np.int64)
    elif et.DataType() == etensor.FLOAT32:
        nar = np.array(etensor.Float32(et).Values, dtype=np.float32)
    elif et.DataType() == etensor.FLOAT64:
        nar = np.array(etensor.Float64(et).Values, dtype=np.float64)
    elif et.DataType() == etensor.STRING:
        nar = np.array(etensor.String(et).Values)
    elif et.DataType() == etensor.INT:
        nar = np.array(etensor.Int(et).Values, dtype=np.intc)
    elif et.DataType() == etensor.BOOL:
        etb = etensor.Bits(et)
        sz = etb.Len()
        nar = np.zeros(sz, dtype=np.bool_)
        for i in range(sz):
            nar[i] = etb.Value1D(i)
    else:
        raise TypeError("tensor with type %s cannot be converted" %
                        (et.DataType().String()))
        return 0
    # there does not appear to be a way to set the shape at the same time as initializing
    return nar.reshape(et.Shapes())
Esempio n. 11
0
def copy_numpy_to_etensor(et, nar):
    """
    copies data from numpy ndarray (nar, source) to existing etensor.Tensor (et, dest) 
    """
    narf = np.reshape(nar, -1)
    etv = et
    if et.DataType() == etensor.UINT8:
        etv = etensor.Uint8(et).Values
    elif et.DataType() == etensor.INT8:
        etv = etensor.Int8(et).Values
    elif et.DataType() == etensor.UINT16:
        etv = etensor.Uint16(et).Values
    elif et.DataType() == etensor.INT16:
        etv = etensor.Int16(et).Values
    elif et.DataType() == etensor.UINT32:
        etv = etensor.Uint32(et).Values
    elif et.DataType() == etensor.INT32:
        etv = etensor.Int32(et).Values
    elif et.DataType() == etensor.UINT64:
        etv = etensor.Uint64(et).Values
    elif et.DataType() == etensor.INT64:
        etv = etensor.Int64(et).Values
    elif et.DataType() == etensor.FLOAT32:
        etv = etensor.Float32(et).Values
    elif et.DataType() == etensor.FLOAT64:
        etv = etensor.Float64(et).Values
    elif et.DataType() == etensor.STRING:
        etv = etensor.String(et).Values
    elif et.DataType() == etensor.INT:
        etv = etensor.Int(et).Values
    elif et.DataType() == etensor.BOOL:
        etb = etensor.Bits(et)
        sz = min(etb.Len(), len(narf))
        for i in range(sz):
            narf[i] = etb.Value1D(i)
        return
    else:
        raise TypeError("tensor with type %s cannot be copied" %
                        (et.DataType().String()))
        return 0
    etv.copy(narf)  # go slice copy, not python copy = clone
Esempio n. 12
0
    def __init__(self):
        super(Sim, self).__init__()
        self.ExcitLateralScale = float(0.2)
        self.SetTags(
            "ExcitLateralScale",
            'def:"0.2" desc:"excitatory lateral (recurrent) WtScale.Rel value"'
        )
        self.InhibLateralScale = float(0.2)
        self.SetTags(
            "InhibLateralScale",
            'def:"0.2" desc:"inhibitory lateral (recurrent) WtScale.Abs value"'
        )
        self.ExcitLateralLearn = True
        self.SetTags(
            "ExcitLateralLearn",
            'def:"true" desc:"do excitatory lateral (recurrent) connections learn?"'
        )
        self.Net = leabra.Network()
        self.SetTags(
            "Net",
            'view:"no-inline" desc:"the network -- click to view / edit parameters for layers, prjns, etc"'
        )
        self.Probes = etable.Table()
        self.SetTags("Probes", 'view:"no-inline" desc:"probe inputs"')
        self.TrnEpcLog = etable.Table()
        self.SetTags("TrnEpcLog",
                     'view:"no-inline" desc:"training epoch-level log data"')
        self.TstEpcLog = etable.Table()
        self.SetTags("TstEpcLog",
                     'view:"no-inline" desc:"testing epoch-level log data"')
        self.TstTrlLog = etable.Table()
        self.SetTags("TstTrlLog",
                     'view:"no-inline" desc:"testing trial-level log data"')
        self.RunLog = etable.Table()
        self.SetTags("RunLog",
                     'view:"no-inline" desc:"summary log of each run"')
        self.RunStats = etable.Table()
        self.SetTags("RunStats",
                     'view:"no-inline" desc:"aggregate stats on all runs"')
        self.Params = params.Sets()
        self.SetTags("Params",
                     'view:"no-inline" desc:"full collection of param sets"')
        self.ParamSet = str()
        self.SetTags(
            "ParamSet",
            'view:"-" desc:"which set of *additional* parameters to use -- always applies Base and optionaly this next if set -- can use multiple names separated by spaces (don\'t put spaces in ParamSet names!)"'
        )
        self.V1onWts = etensor.Float32()
        self.SetTags("V1onWts",
                     'view:"-" desc:"weights from input to V1 layer"')
        self.V1offWts = etensor.Float32()
        self.SetTags("V1offWts",
                     'view:"-" desc:"weights from input to V1 layer"')
        self.V1Wts = etensor.Float32()
        self.SetTags(
            "V1Wts",
            'view:"no-inline" desc:"net on - off weights from input to V1 layer"'
        )
        self.MaxRuns = int(1)
        self.SetTags("MaxRuns",
                     'desc:"maximum number of model runs to perform"')
        self.MaxEpcs = int(100)
        self.SetTags("MaxEpcs",
                     'desc:"maximum number of epochs to run per model run"')
        self.MaxTrls = int(100)
        self.SetTags("MaxTrls",
                     'desc:"maximum number of training trials per epoch"')
        self.NZeroStop = int(-1)
        self.SetTags(
            "NZeroStop",
            'desc:"if a positive number, training will stop after this many epochs with zero SSE"'
        )
        self.TrainEnv = ImgEnv()
        self.SetTags("TrainEnv",
                     'desc:"Training environment -- visual images"')
        self.TestEnv = env.FixedTable()
        self.SetTags(
            "TestEnv",
            'desc:"Testing environment -- manages iterating over testing"')
        self.Time = leabra.Time()
        self.SetTags("Time", 'desc:"leabra timing parameters and state"')
        self.ViewOn = True
        self.SetTags(
            "ViewOn",
            'desc:"whether to update the network view while running"')
        self.TrainUpdt = leabra.TimeScales.AlphaCycle
        self.SetTags(
            "TrainUpdt",
            'desc:"at what time scale to update the display during training?  Anything longer than Epoch updates at Epoch in this model"'
        )
        self.TestUpdt = leabra.TimeScales.Cycle
        self.SetTags(
            "TestUpdt",
            'desc:"at what time scale to update the display during testing?  Anything longer than Epoch updates at Epoch in this model"'
        )
        self.LayStatNms = go.Slice_string(["V1"])
        self.SetTags(
            "LayStatNms",
            'desc:"names of layers to collect more detailed stats on (avg act, etc)"'
        )

        # statistics: note use float64 as that is best for etable.Table
        self.Win = 0
        self.SetTags("Win", 'view:"-" desc:"main GUI window"')
        self.NetView = 0
        self.SetTags("NetView", 'view:"-" desc:"the network viewer"')
        self.ToolBar = 0
        self.SetTags("ToolBar", 'view:"-" desc:"the master toolbar"')
        self.CurImgGrid = 0
        self.SetTags("CurImgGrid",
                     'view:"-" desc:"the current image grid view"')
        self.WtsGrid = 0
        self.SetTags("WtsGrid", 'view:"-" desc:"the weights grid view"')
        self.TrnEpcPlot = 0
        self.SetTags("TrnEpcPlot", 'view:"-" desc:"the training epoch plot"')
        self.TstEpcPlot = 0
        self.SetTags("TstEpcPlot", 'view:"-" desc:"the testing epoch plot"')
        self.TstTrlPlot = 0
        self.SetTags("TstTrlPlot", 'view:"-" desc:"the test-trial plot"')
        self.RunPlot = 0
        self.SetTags("RunPlot", 'view:"-" desc:"the run plot"')
        self.TrnEpcFile = 0
        self.SetTags("TrnEpcFile", 'view:"-" desc:"log file"')
        self.RunFile = 0
        self.SetTags("RunFile", 'view:"-" desc:"log file"')
        self.ValsTsrs = {}
        self.SetTags("ValsTsrs", 'view:"-" desc:"for holding layer values"')
        self.IsRunning = False
        self.SetTags("IsRunning", 'view:"-" desc:"true if sim is running"')
        self.StopNow = False
        self.SetTags("StopNow", 'view:"-" desc:"flag to stop running"')
        self.NeedsNewRun = False
        self.SetTags(
            "NeedsNewRun",
            'view:"-" desc:"flag to initialize NewRun if last one finished"')
        self.RndSeed = int(1)
        self.SetTags("RndSeed", 'view:"-" desc:"the current random seed"')
        self.vp = 0
        self.SetTags("vp", 'view:"-" desc:"viewport"')
Esempio n. 13
0
    def __init__(self):
        super(Sim, self).__init__()
        self.BurstDaGain = float(1)
        self.SetTags(
            "BurstDaGain",
            'min:"0" step:"0.1" desc:"strength of dopamine bursts: 1 default -- reduce for PD OFF, increase for PD ON"'
        )
        self.DipDaGain = float(1)
        self.SetTags(
            "DipDaGain",
            'min:"0" step:"0.1" desc:"strength of dopamine dips: 1 default -- reduce to siulate D2 agonists"'
        )
        self.Net = pbwm.Network()
        self.SetTags(
            "Net",
            'view:"no-inline" desc:"the network -- click to view / edit parameters for layers, prjns, etc"'
        )
        self.TrnEpcLog = etable.Table()
        self.SetTags("TrnEpcLog",
                     'view:"no-inline" desc:"training epoch-level log data"')
        self.TstEpcLog = etable.Table()
        self.SetTags("TstEpcLog",
                     'view:"no-inline" desc:"testing epoch-level log data"')
        self.TstTrlLog = etable.Table()
        self.SetTags("TstTrlLog",
                     'view:"no-inline" desc:"testing trial-level log data"')
        self.MtxInputWts = etensor.Float32()
        self.SetTags(
            "MtxInputWts",
            'view:"no-inline" desc:"weights from input to hidden layer"')
        self.RunLog = etable.Table()
        self.SetTags("RunLog",
                     'view:"no-inline" desc:"summary log of each run"')
        self.RunStats = etable.Table()
        self.SetTags("RunStats",
                     'view:"no-inline" desc:"aggregate stats on all runs"')
        self.Params = params.Sets()
        self.SetTags("Params",
                     'view:"no-inline" desc:"full collection of param sets"')
        self.ParamSet = str()
        self.SetTags(
            "ParamSet",
            'view:"-" desc:"which set of *additional* parameters to use -- always applies Base and optionaly this next if set -- can use multiple names separated by spaces (don\'t put spaces in ParamSet names!)"'
        )
        self.MaxRuns = int(1)
        self.SetTags("MaxRuns",
                     'desc:"maximum number of model runs to perform"')
        self.MaxEpcs = int(30)
        self.SetTags("MaxEpcs",
                     'desc:"maximum number of epochs to run per model run"')
        self.MaxTrls = int(100)
        self.SetTags("MaxTrls",
                     'desc:"maximum number of training trials per epoch"')
        self.TrainEnv = BanditEnv()
        self.SetTags("TrainEnv",
                     'desc:"Training environment -- bandit environment"')
        self.Time = leabra.Time()
        self.SetTags("Time", 'desc:"leabra timing parameters and state"')
        self.ViewOn = True
        self.SetTags(
            "ViewOn",
            'desc:"whether to update the network view while running"')
        self.TrainUpdt = leabra.TimeScales.AlphaCycle
        self.SetTags(
            "TrainUpdt",
            'desc:"at what time scale to update the display during training?  Anything longer than Epoch updates at Epoch in this model"'
        )
        self.TestUpdt = leabra.TimeScales.AlphaCycle
        self.SetTags(
            "TestUpdt",
            'desc:"at what time scale to update the display during testing?  Anything longer than Epoch updates at Epoch in this model"'
        )
        self.TstRecLays = go.Slice_string(["MatrixGo", "MatrixNoGo"])
        self.SetTags(
            "TstRecLays",
            'desc:"names of layers to record activations etc of during testing"'
        )

        # internal state - view:"-"
        self.Win = 0
        self.SetTags("Win", 'view:"-" desc:"main GUI window"')
        self.NetView = 0
        self.SetTags("NetView", 'view:"-" desc:"the network viewer"')
        self.ToolBar = 0
        self.SetTags("ToolBar", 'view:"-" desc:"the master toolbar"')
        self.WtsGrid = 0
        self.SetTags("WtsGrid", 'view:"-" desc:"the weights grid view"')
        self.TrnEpcPlot = 0
        self.SetTags("TrnEpcPlot", 'view:"-" desc:"the training epoch plot"')
        self.TstEpcPlot = 0
        self.SetTags("TstEpcPlot", 'view:"-" desc:"the testing epoch plot"')
        self.TstTrlPlot = 0
        self.SetTags("TstTrlPlot", 'view:"-" desc:"the test-trial plot"')
        self.RunPlot = 0
        self.SetTags("RunPlot", 'view:"-" desc:"the run plot"')
        self.TrnEpcFile = 0
        self.SetTags("TrnEpcFile", 'view:"-" desc:"log file"')
        self.RunFile = 0
        self.SetTags("RunFile", 'view:"-" desc:"log file"')
        self.ValsTsrs = {}
        self.SetTags("ValsTsrs", 'view:"-" desc:"for holding layer values"')
        self.IsRunning = False
        self.SetTags("IsRunning", 'view:"-" desc:"true if sim is running"')
        self.StopNow = False
        self.SetTags("StopNow", 'view:"-" desc:"flag to stop running"')
        self.NeedsNewRun = False
        self.SetTags(
            "NeedsNewRun",
            'view:"-" desc:"flag to initialize NewRun if last one finished"')
        self.RndSeed = int(1)
        self.SetTags("RndSeed", 'view:"-" desc:"the current random seed"')
        self.vp = 0
        self.SetTags("vp", 'view:"-" desc:"viewport"')
Esempio n. 14
0
 def __init__(self):
     super(SentGenEnv, self).__init__()
     self.Nm = str()
     self.SetTags("Nm", 'desc:"name of this environment"')
     self.Dsc = str()
     self.SetTags("Dsc", 'desc:"description of this environment"')
     self.Rules = esg.Rules()
     self.SetTags(
         "Rules",
         'desc:"core sent-gen rules -- loaded from a grammar / rules file -- Gen() here generates one sentence"'
     )
     self.PPassive = float()
     self.SetTags(
         "PPassive",
         'desc:"probability of generating passive sentence forms"')
     self.WordTrans = {}
     self.SetTags(
         "WordTrans",
         'desc:"translate unambiguous words into ambiguous words"')
     self.Words = go.Slice_string()
     self.SetTags(
         "Words",
         'desc:"list of words used for activating state units according to index"'
     )
     self.WordMap = {}
     self.SetTags("WordMap", 'desc:"map of words onto index in Words list"')
     self.Roles = []
     self.SetTags(
         "Roles",
         'desc:"list of roles used for activating state units according to index"'
     )
     self.RoleMap = {}
     self.SetTags("RoleMap", 'desc:"map of roles onto index in Roles list"')
     self.Fillers = []
     self.SetTags(
         "Fillers",
         'desc:"list of filler concepts used for activating state units according to index"'
     )
     self.FillerMap = {}
     self.SetTags("FillerMap",
                  'desc:"map of roles onto index in Words list"')
     self.AmbigVerbs = []
     self.SetTags("AmbigVerbs", 'desc:"ambiguous verbs"')
     self.AmbigNouns = []
     self.SetTags("AmbigNouns", 'desc:"ambiguous nouns"')
     self.AmbigVerbsMap = {}
     self.SetTags("AmbigVerbsMap", 'desc:"map of ambiguous verbs"')
     self.AmbigNounsMap = {}
     self.SetTags("AmbigNounsMap", 'desc:"map of ambiguous nouns"')
     self.CurSentOrig = []
     self.SetTags(
         "CurSentOrig",
         'desc:"original current sentence as generated from Rules"')
     self.CurSent = []
     self.SetTags(
         "CurSent",
         'desc:"current sentence, potentially transformed to passive form"')
     self.NAmbigNouns = int()
     self.SetTags("NAmbigNouns", 'desc:"number of ambiguous nouns"')
     self.NAmbigVerbs = int()
     self.SetTags("NAmbigVerbs",
                  'desc:"number of ambiguous verbs (0 or 1)"')
     self.SentInputs = []
     self.SetTags(
         "SentInputs",
         'desc:"generated sequence of sentence inputs including role-filler queries"'
     )
     self.SentIdx = env.CurPrvInt()
     self.SetTags("SentIdx", 'desc:"current index within sentence inputs"')
     self.QType = str()
     self.SetTags(
         "QType",
         'desc:"current question type -- from 4th value of SentInputs"')
     self.WordState = etensor.Float32()
     self.SetTags("WordState", 'desc:"current sentence activation state"')
     self.RoleState = etensor.Float32()
     self.SetTags("RoleState", 'desc:"current role query activation state"')
     self.FillerState = etensor.Float32()
     self.SetTags("FillerState",
                  'desc:"current filler query activation state"')
     self.Run = env.Ctr()
     self.SetTags(
         "Run",
         'view:"inline" desc:"current run of model as provided during Init"'
     )
     self.Epoch = env.Ctr()
     self.SetTags(
         "Epoch",
         'view:"inline" desc:"number of times through Seq.Max number of sequences"'
     )
     self.Seq = env.Ctr()
     self.SetTags("Seq",
                  'view:"inline" desc:"sequence counter within epoch"')
     self.Tick = env.Ctr()
     self.SetTags("Tick",
                  'view:"inline" desc:"tick counter within sequence"')
     self.Trial = env.Ctr()
     self.SetTags(
         "Trial",
         'view:"inline" desc:"trial is the step counter within sequence - how many steps taken within current sequence -- it resets to 0 at start of each sequence"'
     )
Esempio n. 15
0
    def __init__(self):
        super(Sim, self).__init__()
        self.AvgLGain = float(2.5)
        self.SetTags("AvgLGain", 'min:"0.1" step:"0.5" def:"2.5" desc:"key BCM hebbian learning parameter, that determines how high the floating threshold goes -- higher = more homeostatic pressure against rich-get-richer feedback loops"')
        self.InputNoise = float(0)
        self.SetTags("InputNoise", 'min:"0" def:"0" desc:"variance on gaussian noise to add to inputs"')
        self.TrainGi = float(1.8)
        self.SetTags("TrainGi", 'min:"0" step:"0.1" def:"1.8" desc:"strength of inhibition during training with two lines present in input"')
        self.TestGi = float(2.5)
        self.SetTags("TestGi", 'min:"0" step:"0.1" def:"2.5" desc:"strength of inhibition during testing with one line present in input -- higher because fewer neurons should be active"')
        self.Net = leabra.Network()
        self.SetTags("Net", 'view:"no-inline" desc:"the network -- click to view / edit parameters for layers, prjns, etc"')
        self.Lines2 = etable.Table()
        self.SetTags("Lines2", 'view:"no-inline" desc:"easy training patterns -- can be learned with Hebbian"')
        self.Lines1 = etable.Table()
        self.SetTags("Lines1", 'view:"no-inline" desc:"hard training patterns -- require error-driven"')
        self.TrnEpcLog = etable.Table()
        self.SetTags("TrnEpcLog", 'view:"no-inline" desc:"training epoch-level log data"')
        self.TstEpcLog = etable.Table()
        self.SetTags("TstEpcLog", 'view:"no-inline" desc:"testing epoch-level log data"')
        self.TstTrlLog = etable.Table()
        self.SetTags("TstTrlLog", 'view:"no-inline" desc:"testing trial-level log data"')
        self.HidFmInputWts = etensor.Float32()
        self.SetTags("HidFmInputWts", 'view:"no-inline" desc:"weights from input to hidden layer"')
        self.RunLog = etable.Table()
        self.SetTags("RunLog", 'view:"no-inline" desc:"summary log of each run"')
        self.RunStats = etable.Table()
        self.SetTags("RunStats", 'view:"no-inline" desc:"aggregate stats on all runs"')
        self.SimMat = simat.SimMat()
        self.SetTags("SimMat", 'view:"no-inline" desc:"similarity matrix"')
        self.Params = params.Sets()
        self.SetTags("Params", 'view:"no-inline" desc:"full collection of param sets"')
        self.ParamSet = str()
        self.SetTags("ParamSet", 'view:"-" desc:"which set of *additional* parameters to use -- always applies Base and optionaly this next if set -- can use multiple names separated by spaces (don\'t put spaces in ParamSet names!)"')
        self.MaxRuns = int(8)
        self.SetTags("MaxRuns", 'desc:"maximum number of model runs to perform"')
        self.MaxEpcs = int(30)
        self.SetTags("MaxEpcs", 'desc:"maximum number of epochs to run per model run"')
        self.TrainEnv = env.FixedTable()
        self.SetTags("TrainEnv", 'desc:"Training environment -- contains everything about iterating over input / output patterns over training"')
        self.TestEnv = env.FixedTable()
        self.SetTags("TestEnv", 'desc:"Testing environment -- manages iterating over testing"')
        self.Time = leabra.Time()
        self.SetTags("Time", 'desc:"leabra timing parameters and state"')
        self.ViewOn = True
        self.SetTags("ViewOn", 'desc:"whether to update the network view while running"')
        self.TrainUpdt = leabra.TimeScales.AlphaCycle
        self.SetTags("TrainUpdt", 'desc:"at what time scale to update the display during training?  Anything longer than Epoch updates at Epoch in this model"')
        self.TestUpdt = leabra.TimeScales.Cycle
        self.SetTags("TestUpdt", 'desc:"at what time scale to update the display during testing?  Anything longer than Epoch updates at Epoch in this model"')
        self.TestInterval = int(1)
        self.SetTags("TestInterval", 'desc:"how often to run through all the test patterns, in terms of training epochs"')
        self.TstRecLays = go.Slice_string(["Input", "Hidden"])
        self.SetTags("TstRecLays", 'desc:"names of layers to record activations etc of during testing"')
        self.UniqPats = float(0)
        self.SetTags("UniqPats", 'inactive:"+" desc:"number of uniquely-coded line patterns, computed during testing -- maximum 10, higher is better"')

        # internal state - view:"-"
        self.Win = 0
        self.SetTags("Win", 'view:"-" desc:"main GUI window"')
        self.NetView = 0
        self.SetTags("NetView", 'view:"-" desc:"the network viewer"')
        self.ToolBar = 0
        self.SetTags("ToolBar", 'view:"-" desc:"the master toolbar"')
        self.WtsGrid = 0
        self.SetTags("WtsGrid", 'view:"-" desc:"the weights grid view"')
        self.TrnEpcPlot = 0
        self.SetTags("TrnEpcPlot", 'view:"-" desc:"the training epoch plot"')
        self.TstEpcPlot = 0
        self.SetTags("TstEpcPlot", 'view:"-" desc:"the testing epoch plot"')
        self.TstTrlPlot = 0
        self.SetTags("TstTrlPlot", 'view:"-" desc:"the test-trial plot"')
        self.RunPlot = 0
        self.SetTags("RunPlot", 'view:"-" desc:"the run plot"')
        self.TrnEpcFile = 0
        self.SetTags("TrnEpcFile", 'view:"-" desc:"log file"')
        self.RunFile = 0
        self.SetTags("RunFile", 'view:"-" desc:"log file"')
        self.ValsTsrs = {}
        self.SetTags("ValsTsrs", 'view:"-" desc:"for holding layer values"')
        self.IsRunning = False
        self.SetTags("IsRunning", 'view:"-" desc:"true if sim is running"')
        self.StopNow = False
        self.SetTags("StopNow", 'view:"-" desc:"flag to stop running"')
        self.NeedsNewRun = False
        self.SetTags("NeedsNewRun", 'view:"-" desc:"flag to initialize NewRun if last one finished"')
        self.RndSeed = int(1)
        self.SetTags("RndSeed", 'view:"-" desc:"the current random seed"')
        self.vp  = 0 
        self.SetTags("vp", 'view:"-" desc:"viewport"')
Esempio n. 16
0
 def __init__(self):
     super(Vis, self).__init__()
     self.V1sGabor = gabor.Filter()
     self.SetTags("V1sGabor", 'desc:"V1 simple gabor filter parameters"')
     self.V1sGeom = vfilter.Geom()
     self.SetTags(
         "V1sGeom",
         'inactive:"+" view:"inline" desc:"geometry of input, output for V1 simple-cell processing"'
     )
     self.V1sNeighInhib = kwta.NeighInhib()
     self.SetTags(
         "V1sNeighInhib",
         'desc:"neighborhood inhibition for V1s -- each unit gets inhibition from same feature in nearest orthogonal neighbors -- reduces redundancy of feature code"'
     )
     self.V1sKWTA = kwta.KWTA()
     self.SetTags("V1sKWTA", 'desc:"kwta parameters for V1s"')
     self.ImgSize = image.Point()
     self.SetTags(
         "ImgSize",
         'desc:"target image size to use -- images will be rescaled to this size"'
     )
     self.V1sGaborTsr = etensor.Float32()
     self.SetTags("V1sGaborTsr",
                  'view:"no-inline" desc:"V1 simple gabor filter tensor"')
     self.ImgTsr = etensor.Float32()
     self.SetTags("ImgTsr", 'view:"no-inline" desc:"input image as tensor"')
     self.Img = image.Image()
     self.SetTags("Img", 'view:"-" desc:"current input image"')
     self.V1sTsr = etensor.Float32()
     self.SetTags(
         "V1sTsr",
         'view:"no-inline" desc:"V1 simple gabor filter output tensor"')
     self.V1sExtGiTsr = etensor.Float32()
     self.SetTags(
         "V1sExtGiTsr",
         'view:"no-inline" desc:"V1 simple extra Gi from neighbor inhibition tensor"'
     )
     self.V1sKwtaTsr = etensor.Float32()
     self.SetTags(
         "V1sKwtaTsr",
         'view:"no-inline" desc:"V1 simple gabor filter output, kwta output tensor"'
     )
     self.V1sPoolTsr = etensor.Float32()
     self.SetTags(
         "V1sPoolTsr",
         'view:"no-inline" desc:"V1 simple gabor filter output, max-pooled 2x2 of V1sKwta tensor"'
     )
     self.V1sUnPoolTsr = etensor.Float32()
     self.SetTags(
         "V1sUnPoolTsr",
         'view:"no-inline" desc:"V1 simple gabor filter output, un-max-pooled 2x2 of V1sPool tensor"'
     )
     self.V1sAngOnlyTsr = etensor.Float32()
     self.SetTags(
         "V1sAngOnlyTsr",
         'view:"no-inline" desc:"V1 simple gabor filter output, angle-only features tensor"'
     )
     self.V1sAngPoolTsr = etensor.Float32()
     self.SetTags(
         "V1sAngPoolTsr",
         'view:"no-inline" desc:"V1 simple gabor filter output, max-pooled 2x2 of AngOnly tensor"'
     )
     self.V1cLenSumTsr = etensor.Float32()
     self.SetTags(
         "V1cLenSumTsr",
         'view:"no-inline" desc:"V1 complex length sum filter output tensor"'
     )
     self.V1cEndStopTsr = etensor.Float32()
     self.SetTags(
         "V1cEndStopTsr",
         'view:"no-inline" desc:"V1 complex end stop filter output tensor"')
     self.V1AllTsr = etensor.Float32()
     self.SetTags(
         "V1AllTsr",
         'view:"no-inline" desc:"Combined V1 output tensor with V1s simple as first two rows, then length sum, then end stops = 5 rows total"'
     )
     self.V1sInhibs = fffb.Inhibs()
     self.SetTags("V1sInhibs",
                  'view:"no-inline" desc:"inhibition values for V1s KWTA"')