Beispiel #1
0
    def ConfigNet(ss, net):
        net.InitName(net, "CatsAndDogs")
        name = net.AddLayer2D("Name", 1, 10, emer.Input)
        iden = net.AddLayer2D("Identity", 1, 10, emer.Input)
        color = net.AddLayer2D("Color", 1, 4, emer.Input)
        food = net.AddLayer2D("FavoriteFood", 1, 4, emer.Input)
        size = net.AddLayer2D("Size", 1, 3, emer.Input)
        spec = net.AddLayer2D("Species", 1, 2, emer.Input)
        toy = net.AddLayer2D("FavoriteToy", 1, 4, emer.Input)

        name.SetClass("Id")
        iden.SetClass("Id")

        one2one = prjn.NewOneToOne()
        full = prjn.NewFull()

        net.BidirConnectLayersPy(name, iden, one2one)
        net.BidirConnectLayersPy(color, iden, full)
        net.BidirConnectLayersPy(food, iden, full)
        net.BidirConnectLayersPy(size, iden, full)
        net.BidirConnectLayersPy(spec, iden, full)
        net.BidirConnectLayersPy(toy, iden, full)

        iden.SetRelPos(relpos.Rel(Rel= relpos.Above, Other= "Name", YAlign= relpos.Front, XAlign= relpos.Left, YOffset= 1))
        color.SetRelPos(relpos.Rel(Rel= relpos.Above, Other= "Identity", YAlign= relpos.Front, XAlign= relpos.Left, YOffset= 1))
        food.SetRelPos(relpos.Rel(Rel= relpos.Above, Other= "Identity", YAlign= relpos.Front, XAlign= relpos.Right, YOffset= 1))
        size.SetRelPos(relpos.Rel(Rel= relpos.Above, Other= "Color", YAlign= relpos.Front, XAlign= relpos.Left))
        spec.SetRelPos(relpos.Rel(Rel= relpos.Above, Other= "Color", YAlign= relpos.Front, XAlign= relpos.Right, XOffset= 2))
        toy.SetRelPos(relpos.Rel(Rel= relpos.Above, Other= "FavoriteFood", YAlign= relpos.Front, XAlign= relpos.Right, XOffset= 1))

        net.Defaults()
        ss.SetParams("Network", False)
        net.Build()
        ss.InitWts(net)
Beispiel #2
0
    def ConfigNet(ss, net):
        net.InitName(net, "BG")
        snc = rl.AddClampDaLayer(net.AsLeabra(), "SNc")
        inp = net.AddLayer2D("Input", 1, 6, emer.Input)
        inp.SetRelPos(relpos.Rel(Rel= relpos.Above, Other= "SNc", YAlign= relpos.Front, XAlign= relpos.Left))

        # args: nY, nMaint, nOut, nNeurBgY, nNeurBgX, nNeurPfcY, nNeurPfcX
        lays = pbwm.AddPBWMPy(net.AsLeabra(), "", 1, 0, 1, 1, 6, 1, 6) 
        # lays = mtxGo, mtxNoGo, gpe, gpi, cini, pfcMnt, pfcMntD, pfcOut, pfcOutD
        mtxGo = lays[0]
        mtxNoGo = lays[1]
        pfcOut = lays[7]

        onetoone = prjn.NewOneToOne()
        pj = net.ConnectLayersPrjn(inp, mtxGo, onetoone, emer.Forward, pbwm.DaHebbPrjn())
        pj.SetClass("MatrixPrjn")
        pj = net.ConnectLayersPrjn(inp, mtxNoGo, onetoone, emer.Forward, pbwm.DaHebbPrjn())
        pj.SetClass("MatrixPrjn")
        pj = net.ConnectLayers(inp, pfcOut, onetoone, emer.Forward)
        pj.SetClass("PFCFixed")

        mtxGo.SetRelPos(relpos.Rel(Rel= relpos.RightOf, Other= "SNc", YAlign= relpos.Front, Space= 2))

        snc.SendDA.AddAllBut(net, go.nil) # send dopamine to all layers..

        net.Defaults()
        ss.SetParams("Network", False) # only set Network params
        net.Build()
        net.InitWts()
Beispiel #3
0
    def ConfigNet(ss, net):
        net.InitName(net, "AnotB")
        loc = net.AddLayer2D("Location", 1, 3, emer.Input)
        cvr = net.AddLayer2D("Cover", 1, 2, emer.Input)
        toy = net.AddLayer2D("Toy", 1, 2, emer.Input)
        hid = net.AddLayer2D("Hidden", 1, 3, emer.Hidden)
        gze = net.AddLayer2D("GazeExpect", 1, 3, emer.Compare)
        rch = net.AddLayer2D("Reach", 1, 3, emer.Compare)

        full = prjn.NewFull()
        self = prjn.NewOneToOne()
        net.ConnectLayers(loc, hid, full, emer.Forward)
        net.ConnectLayers(cvr, hid, full, emer.Forward)
        net.ConnectLayers(toy, hid, full, emer.Forward)
        net.ConnectLayers(hid, hid, self, emer.Lateral)
        net.ConnectLayers(hid, gze, full, emer.Forward)
        net.ConnectLayers(hid, rch, full, emer.Forward)
        net.ConnectLayers(gze, gze, self, emer.Lateral)

        cvr.SetRelPos(relpos.Rel(Rel= relpos.RightOf, Other= "Location", YAlign= relpos.Front, Space= 1))
        toy.SetRelPos(relpos.Rel(Rel= relpos.RightOf, Other= "Cover", YAlign= relpos.Front, Space= 1))
        hid.SetRelPos(relpos.Rel(Rel= relpos.Above, Other= "Cover", YAlign= relpos.Front, XAlign= relpos.Left, YOffset= 1, XOffset= -1))
        gze.SetRelPos(relpos.Rel(Rel= relpos.Above, Other= "Hidden", YAlign= relpos.Front, XAlign= relpos.Left, XOffset= -4))
        rch.SetRelPos(relpos.Rel(Rel= relpos.RightOf, Other= "GazeExpect", YAlign= relpos.Front, Space= 4))

        net.Defaults()
        ss.SetParams("Network", False) # only set Network params
        net.Build()
        ss.InitWts(ss.Net)
Beispiel #4
0
    def ConfigNet(ss, net):
        net.InitName(net, "AttnNet")
        inp = net.AddLayer4D("Input", 1, 7, 2, 1, emer.Input)
        v1 = net.AddLayer4D("V1", 1, 7, 2, 1, emer.Hidden)
        sp1 = net.AddLayer4D("Spat1", 1, 5, 2, 1, emer.Hidden)
        sp2 = net.AddLayer4D("Spat2", 1, 3, 2, 1, emer.Hidden)
        ob1 = net.AddLayer4D("Obj1", 1, 5, 2, 1, emer.Hidden)
        out = net.AddLayer2D("Output", 2, 1, emer.Compare)
        ob2 = net.AddLayer4D("Obj2", 1, 3, 2, 1, emer.Hidden)

        ob1.SetClass("Object")
        ob2.SetClass("Object")
        sp1.SetClass("Spatial")
        sp2.SetClass("Spatial")

        full = prjn.NewFull()
        net.ConnectLayers(inp, v1, prjn.NewOneToOne(), emer.Forward)

        rec3sp = prjn.NewRect()
        rec3sp.Size.Set(3, 2)
        rec3sp.Scale.Set(1, 0)
        rec3sp.Start.Set(0, 0)

        rec3sptd = prjn.NewRect()
        rec3sptd.Size.Set(3, 2)
        rec3sptd.Scale.Set(1, 0)
        rec3sptd.Start.Set(-2, 0)
        rec3sptd.Wrap = False

        net.BidirConnectLayersPy(v1, sp1, full)
        v1sp1 = v1.SendPrjns().RecvName(sp1.Name())
        sp1v1 = v1.RecvPrjns().SendName(sp1.Name())
        v1sp1.SetPattern(rec3sp)
        sp1v1.SetPattern(rec3sptd)

        net.BidirConnectLayersPy(sp1, sp2, full)
        sp1sp2 = sp1.SendPrjns().RecvName(sp2.Name())
        sp2sp1 = sp1.RecvPrjns().SendName(sp2.Name())
        sp1sp2.SetPattern(rec3sp)
        sp2sp1.SetPattern(rec3sptd)

        rec3ob = prjn.NewRect()
        rec3ob.Size.Set(3, 1)
        rec3ob.Scale.Set(1, 1)
        rec3ob.Start.Set(0, 0)

        rec3obtd = prjn.NewRect()
        rec3obtd.Size.Set(3, 1)
        rec3obtd.Scale.Set(1, 1)
        rec3obtd.Start.Set(-2, 0)
        rec3obtd.Wrap = False

        net.BidirConnectLayersPy(v1, ob1, full)
        v1ob1 = v1.SendPrjns().RecvName(ob1.Name())
        ob1v1 = v1.RecvPrjns().SendName(ob1.Name())
        v1ob1.SetPattern(rec3ob)
        ob1v1.SetPattern(rec3obtd)

        net.BidirConnectLayersPy(ob1, ob2, full)
        ob1ob2 = ob1.SendPrjns().RecvName(ob2.Name())
        ob2ob1 = ob1.RecvPrjns().SendName(ob2.Name())
        ob1ob2.SetPattern(rec3ob)
        ob2ob1.SetPattern(rec3obtd)

        recout = prjn.NewRect()
        recout.Size.Set(1, 1)
        recout.Scale.Set(0, 1)
        recout.Start.Set(0, 0)

        net.BidirConnectLayersPy(ob2, out, full)
        ob2out = ob2.SendPrjns().RecvName(out.Name())
        outob2 = ob2.RecvPrjns().SendName(out.Name())
        ob2out.SetPattern(rec3ob)
        outob2.SetPattern(recout)

        p1to1 = prjn.NewPoolOneToOne()
        net.BidirConnectLayersPy(sp1, ob1, p1to1)
        spob1 = sp1.SendPrjns().RecvName(ob1.Name())
        obsp1 = sp1.RecvPrjns().SendName(ob1.Name())
        net.BidirConnectLayersPy(sp2, ob2, p1to1)
        spob2 = sp2.SendPrjns().RecvName(ob2.Name())
        obsp2 = sp2.RecvPrjns().SendName(ob2.Name())

        spob1.SetClass("SpatToObj")
        spob2.SetClass("SpatToObj")
        obsp1.SetClass("ObjToSpat")
        obsp2.SetClass("ObjToSpat")

        rec1slf = prjn.NewRect()
        rec1slf.Size.Set(1, 2)
        rec1slf.Scale.Set(1, 0)
        rec1slf.Start.Set(0, 0)
        rec1slf.SelfCon = False
        net.ConnectLayers(sp1, sp1, rec1slf, emer.Lateral)
        net.ConnectLayers(sp2, sp2, rec1slf, emer.Lateral)

        sp1.SetRelPos(relpos.Rel(Rel= relpos.Above, Other= "V1", YAlign= relpos.Front, XAlign= relpos.Left, YOffset= 1))
        sp2.SetRelPos(relpos.Rel(Rel= relpos.Above, Other= "Spat1", YAlign= relpos.Front, XAlign= relpos.Left, Space= 1))
        ob1.SetRelPos(relpos.Rel(Rel= relpos.RightOf, Other= "Spat1", YAlign= relpos.Front, Space= 1))
        out.SetRelPos(relpos.Rel(Rel= relpos.RightOf, Other= "Spat2", YAlign= relpos.Front, Space= 1))
        ob2.SetRelPos(relpos.Rel(Rel= relpos.RightOf, Other= "Output", YAlign= relpos.Front, Space= 1))

        net.Defaults()
        ss.SetParams("Network", False) # only set Network params
        net.Build()
        ss.InitWts(net)