Esempio n. 1
0
    def ConfigGui(ss):
        """
        ConfigGui configures the GoGi gui interface for this simulation,
        """
        width = 1600
        height = 1200

        gi.SetAppName("pyet")
        gi.SetAppAbout('testing of converting etable data between Go and Python. See <a href="https://github.com/emer/etable/blob/master/examples/pyet/README.md">README.md on GitHub</a>.</p>')

        win = gi.NewMainWindow("pyet", "PyEt Testing", width, height)
        ss.Win = win

        vp = win.WinViewport2D()
        ss.vp = vp
        updt = vp.UpdateStart()

        mfr = win.SetMainFrame()

        tbar = gi.AddNewToolBar(mfr, "tbar")
        tbar.SetStretchMaxWidth()
        ss.ToolBar = tbar

        split = gi.AddNewSplitView(mfr, "split")
        split.Dim = mat32.X
        split.SetStretchMax()

        cv = ss.NewClassView("sv")
        cv.AddFrame(split)
        cv.Config()

        tv = gi.AddNewTabView(split, "tv")

        tabv = etview.TableView()
        tv.AddTab(tabv, "Pats")
        tabv.SetTable(ss.Pats, go.nil)
        ss.PatsTable = tabv

        split.SetSplitsList(go.Slice_float32([.2, .8]))
        recv = win.This()

        tbar.AddAction(gi.ActOpts(Label="Test", Icon="update", Tooltip="run the test."), recv, TestCB)

        # main menu
        appnm = gi.AppName()
        mmen = win.MainMenu
        mmen.ConfigMenus(go.Slice_string([appnm, "File", "Edit", "Window"]))

        amen = gi.Action(win.MainMenu.ChildByName(appnm, 0))
        amen.Menu.AddAppMenu(win)

        emen = gi.Action(win.MainMenu.ChildByName("Edit", 1))
        emen.Menu.AddCopyCutPaste(win)

        win.MainMenuUpdated()
        vp.UpdateEndNoSig(updt)
        win.GoStartEventLoop()
Esempio n. 2
0
def EditObjCB(recv, send, sig, data):
    vw = gi.Action(handle=send)
    nm = vw.Name()
    nms = nm.split(':')
    cv = classviews[nms[0]]
    flds = cv.Class.__dict__
    fld = getattr(cv.Class, nms[1])
    print("editing object: todo: need a ClassViewDialog")
Esempio n. 3
0
def EditObjCB(recv, send, sig, data):
    vw = gi.Action(handle=send)
    nm = vw.Name()
    nms = nm.split(':')
    cv = classviews[nms[0]]
    fld = getattr(cv.Class, nms[1])
    tags = cv.FieldTags(nms[1])
    nnm = nm.replace(":", "_")
    return fld.OpenViewDialog(vw.Viewport, nnm, tags)
Esempio n. 4
0
def EditGoObjCB(recv, send, sig, data):
    vw = gi.Action(handle=send)
    nm = vw.Name()
    nms = nm.split(':')
    cv = classviews[nms[0]]
    flds = cv.Class.__dict__
    fld = getattr(cv.Class, nms[1])
    title = nms[1]
    if isinstance(fld, etable.Table):
        dlg = etview.TableViewDialog(vw.Viewport, fld,
                                     giv.DlgOpts(Title=title), go.nil, go.nil)
    elif isinstance(fld, params.Sets):
        dlg = giv.SliceViewDialogNoStyle(vw.Viewport, fld,
                                         giv.DlgOpts(Title=title), go.nil,
                                         go.nil)
    else:
        dlg = giv.StructViewDialog(vw.Viewport, fld, giv.DlgOpts(Title=title),
                                   go.nil, go.nil)
Esempio n. 5
0
    def ConfigGui(ss):
        """
        ConfigGui configures the GoGi gui interface for this simulation,
        """
        width = 1600
        height = 1200

        gi.SetAppName("pat_assoc")
        gi.SetAppAbout(
            'illustrates how error-driven and hebbian learning can operate within a simple task-driven learning context, with no hidden layers. See <a href="https://github.com/CompCogNeuro/sims/blob/master/ch4/pat_assoc/README.md">README.md on GitHub</a>.</p>'
        )

        win = gi.NewMainWindow("pat_assoc", "Pattern Associator", width,
                               height)
        ss.Win = win

        vp = win.WinViewport2D()
        ss.vp = vp
        updt = vp.UpdateStart()

        mfr = win.SetMainFrame()

        tbar = gi.AddNewToolBar(mfr, "tbar")
        tbar.SetStretchMaxWidth()
        ss.ToolBar = tbar

        split = gi.AddNewSplitView(mfr, "split")
        split.Dim = mat32.X
        split.SetStretchMax()

        cv = ss.NewClassView("sv")
        cv.AddFrame(split)
        cv.Config()

        tv = gi.AddNewTabView(split, "tv")

        nv = netview.NetView()
        tv.AddTab(nv, "NetView")
        nv.Var = "Act"
        nv.SetNet(ss.Net)
        ss.NetView = nv
        ss.ConfigNetView(nv)

        plt = eplot.Plot2D()
        tv.AddTab(plt, "TrnEpcPlot")
        ss.TrnEpcPlot = ss.ConfigTrnEpcPlot(plt, ss.TrnEpcLog)

        plt = eplot.Plot2D()
        tv.AddTab(plt, "TstTrlPlot")
        ss.TstTrlPlot = ss.ConfigTstTrlPlot(plt, ss.TstTrlLog)

        plt = eplot.Plot2D()
        tv.AddTab(plt, "TstEpcPlot")
        ss.TstEpcPlot = ss.ConfigTstEpcPlot(plt, ss.TstEpcLog)

        plt = eplot.Plot2D()
        tv.AddTab(plt, "RunPlot")
        ss.RunPlot = ss.ConfigRunPlot(plt, ss.RunLog)

        split.SetSplitsList(go.Slice_float32([.2, .8]))

        recv = win.This()

        tbar.AddAction(
            gi.ActOpts(
                Label="Init",
                Icon="update",
                Tooltip=
                "Initialize everything including network weights, and start over.  Also applies current params.",
                UpdateFunc=UpdtFuncNotRunning), recv, InitCB)

        tbar.AddAction(
            gi.ActOpts(
                Label="Train",
                Icon="run",
                Tooltip=
                "Starts the network training, picking up from wherever it may have left off.  If not stopped, training will complete the specified number of Runs through the full number of Epochs of training, with testing automatically occuring at the specified interval.",
                UpdateFunc=UpdtFuncNotRunning), recv, TrainCB)

        tbar.AddAction(
            gi.ActOpts(
                Label="Stop",
                Icon="stop",
                Tooltip=
                "Interrupts running.  Hitting Train again will pick back up where it left off.",
                UpdateFunc=UpdtFuncRunning), recv, StopCB)

        tbar.AddAction(
            gi.ActOpts(Label="Step Trial",
                       Icon="step-fwd",
                       Tooltip="Advances one training trial at a time.",
                       UpdateFunc=UpdtFuncNotRunning), recv, StepTrialCB)

        tbar.AddAction(
            gi.ActOpts(
                Label="Step Epoch",
                Icon="fast-fwd",
                Tooltip=
                "Advances one epoch (complete set of training patterns) at a time.",
                UpdateFunc=UpdtFuncNotRunning), recv, StepEpochCB)

        tbar.AddAction(
            gi.ActOpts(Label="Step Run",
                       Icon="fast-fwd",
                       Tooltip="Advances one full training Run at a time.",
                       UpdateFunc=UpdtFuncNotRunning), recv, StepRunCB)

        tbar.AddSeparator("test")

        tbar.AddAction(
            gi.ActOpts(Label="Test Trial",
                       Icon="step-fwd",
                       Tooltip="Runs the next testing trial.",
                       UpdateFunc=UpdtFuncNotRunning), recv, TestTrialCB)

        tbar.AddAction(
            gi.ActOpts(
                Label="Test Item",
                Icon="step-fwd",
                Tooltip=
                "Prompts for a specific input pattern name to run, and runs it in testing mode.",
                UpdateFunc=UpdtFuncNotRunning), recv, TestItemCB)

        tbar.AddAction(
            gi.ActOpts(Label="Test All",
                       Icon="fast-fwd",
                       Tooltip="Tests all of the testing trials.",
                       UpdateFunc=UpdtFuncNotRunning), recv, TestAllCB)

        tbar.AddSeparator("log")

        tbar.AddAction(
            gi.ActOpts(
                Label="Reset RunLog",
                Icon="reset",
                Tooltip=
                "Resets the accumulated log of all Runs, which are tagged with the ParamSet used"
            ), recv, ResetRunLogCB)

        tbar.AddSeparator("misc")

        tbar.AddAction(
            gi.ActOpts(
                Label="New Seed",
                Icon="new",
                Tooltip=
                "Generate a new initial random seed to get different results.  By default, Init re-establishes the same initial seed every time."
            ), recv, NewRndSeedCB)

        tbar.AddAction(
            gi.ActOpts(
                Label="README",
                Icon="file-markdown",
                Tooltip=
                "Opens your browser on the README file that contains instructions for how to run this model."
            ), recv, ReadmeCB)

        # main menu
        appnm = gi.AppName()
        mmen = win.MainMenu
        mmen.ConfigMenus(go.Slice_string([appnm, "File", "Edit", "Window"]))

        amen = gi.Action(win.MainMenu.ChildByName(appnm, 0))
        amen.Menu.AddAppMenu(win)

        emen = gi.Action(win.MainMenu.ChildByName("Edit", 1))
        emen.Menu.AddCopyCutPaste(win)

        win.MainMenuUpdated()
        vp.UpdateEndNoSig(updt)
        win.GoStartEventLoop()
Esempio n. 6
0
    def ConfigGui(ss):
        """
        ConfigGui configures the GoGi gui interface for this simulation,
        """
        width = 1600
        height = 1200

        gi.SetAppName("necker_cube")
        gi.SetAppAbout(
            'This simulation explores the use of constraint satisfaction in processing ambiguous stimuli. The example we will use is the *Necker cube*, which and can be viewed as a cube in one of two orientations, where people flip back and forth.  See <a href="https://github.com/CompCogNeuro/sims/blob/master/ch3/necker_cube/README.md">README.md on GitHub</a>.</p>'
        )

        win = gi.NewMainWindow("necker_cube", "Necker Cube", width, height)
        ss.Win = win

        vp = win.WinViewport2D()
        ss.vp = vp
        updt = vp.UpdateStart()

        mfr = win.SetMainFrame()

        tbar = gi.AddNewToolBar(mfr, "tbar")
        tbar.SetStretchMaxWidth()
        ss.ToolBar = tbar

        split = gi.AddNewSplitView(mfr, "split")
        split.Dim = mat32.X
        split.SetStretchMax()

        cv = ss.NewClassView("sv")
        cv.AddFrame(split)
        cv.Config()

        tv = gi.AddNewTabView(split, "tv")

        nv = netview.NetView()
        tv.AddTab(nv, "NetView")
        nv.Var = "Act"
        nv.Params.MaxRecs = 1000
        nv.SetNet(ss.Net)
        ss.NetView = nv
        ss.ConfigNetView(nv)

        plt = eplot.Plot2D()
        tv.AddTab(plt, "TstCycPlot")
        ss.TstCycPlot = ss.ConfigTstCycPlot(plt, ss.TstCycLog)

        split.SetSplitsList(go.Slice_float32([.2, .8]))

        recv = win.This()

        tbar.AddAction(
            gi.ActOpts(
                Label="Init",
                Icon="update",
                Tooltip=
                "Initialize everything including network weights, and start over.  Also applies current params.",
                UpdateFunc=UpdtFuncNotRunning), recv, InitCB)

        tbar.AddAction(
            gi.ActOpts(
                Label="Stop",
                Icon="stop",
                Tooltip=
                "Interrupts running.  Hitting Train again will pick back up where it left off.",
                UpdateFunc=UpdtFuncRunning), recv, StopCB)

        tbar.AddAction(
            gi.ActOpts(Label="Test Trial",
                       Icon="step-fwd",
                       Tooltip="Runs the next testing trial.",
                       UpdateFunc=UpdtFuncNotRunning), recv, TestTrialCB)

        tbar.AddSeparator("log")

        tbar.AddAction(
            gi.ActOpts(Label="Defaults",
                       Icon="update",
                       Tooltip="Restore initial default parameters.",
                       UpdateFunc=UpdtFuncNotRunning), recv, DefaultsCB)

        tbar.AddAction(
            gi.ActOpts(
                Label="README",
                Icon="file-markdown",
                Tooltip=
                "Opens your browser on the README file that contains instructions for how to run this model."
            ), recv, ReadmeCB)

        # main menu
        appnm = gi.AppName()
        mmen = win.MainMenu
        mmen.ConfigMenus(go.Slice_string([appnm, "File", "Edit", "Window"]))

        amen = gi.Action(win.MainMenu.ChildByName(appnm, 0))
        amen.Menu.AddAppMenu(win)

        emen = gi.Action(win.MainMenu.ChildByName("Edit", 1))
        emen.Menu.AddCopyCutPaste(win)

        win.MainMenuUpdated()
        vp.UpdateEndNoSig(updt)
        win.GoStartEventLoop()
Esempio n. 7
0
    def ConfigGui(ss):
        """
        ConfigGui configures the GoGi gui interface for this simulation,
        """
        width = 1600
        height = 1200

        gi.SetAppName("bg")
        gi.SetAppAbout(
            'is a simplified basal ganglia (BG) network showing how dopamine bursts can reinforce *Go* (direct pathway) firing for actions that lead to reward, and dopamine dips reinforce *NoGo* (indirect pathway) firing for actions that do not lead to positive outcomes, producing Thorndikes classic *Law of Effect* for instrumental conditioning, and also providing a mechanism to learn and select among actions with different reward probabilities over multiple experiences. See <a href="https://github.com/CompCogNeuro/sims/blob/master/ch7/bg/README.md">README.md on GitHub</a>.</p>'
        )

        win = gi.NewMainWindow("bg", "Basal Ganglia", width, height)
        ss.Win = win

        vp = win.WinViewport2D()
        ss.vp = vp
        updt = vp.UpdateStart()

        mfr = win.SetMainFrame()

        tbar = gi.AddNewToolBar(mfr, "tbar")
        tbar.SetStretchMaxWidth()
        ss.ToolBar = tbar

        split = gi.AddNewSplitView(mfr, "split")
        split.Dim = mat32.X
        split.SetStretchMax()

        cv = ss.NewClassView("sv")
        cv.AddFrame(split)
        cv.Config()

        tv = gi.AddNewTabView(split, "tv")

        nv = netview.NetView()
        tv.AddTab(nv, "NetView")
        nv.Var = "Act"
        nv.SetNet(ss.Net)
        ss.NetView = nv
        ss.ConfigNetView(nv)

        plt = eplot.Plot2D()
        tv.AddTab(plt, "TrnEpcPlot")
        ss.TrnEpcPlot = ss.ConfigTrnEpcPlot(plt, ss.TrnEpcLog)

        tg = etview.TensorGrid()
        tv.AddTab(tg, "Weights")
        tg.SetStretchMax()
        ss.WtsGrid = tg
        tg.SetTensor(ss.MtxInputWts)

        plt = eplot.Plot2D()
        tv.AddTab(plt, "TstTrlPlot")
        ss.TstTrlPlot = ss.ConfigTstTrlPlot(plt, ss.TstTrlLog)

        plt = eplot.Plot2D()
        tv.AddTab(plt, "TstEpcPlot")
        ss.TstEpcPlot = ss.ConfigTstEpcPlot(plt, ss.TstEpcLog)

        plt = eplot.Plot2D()
        tv.AddTab(plt, "RunPlot")
        ss.RunPlot = ss.ConfigRunPlot(plt, ss.RunLog)

        split.SetSplitsList(go.Slice_float32([.2, .8]))

        recv = win.This()

        tbar.AddAction(
            gi.ActOpts(
                Label="Init",
                Icon="update",
                Tooltip=
                "Initialize everything including network weights, and start over.  Also applies current params.",
                UpdateFunc=UpdtFuncNotRunning), recv, InitCB)

        tbar.AddAction(
            gi.ActOpts(
                Label="Train",
                Icon="run",
                Tooltip=
                "Starts the network training, picking up from wherever it may have left off.  If not stopped, training will complete the specified number of Runs through the full number of Epochs of training, with testing automatically occuring at the specified interval.",
                UpdateFunc=UpdtFuncNotRunning), recv, TrainCB)

        tbar.AddAction(
            gi.ActOpts(
                Label="Stop",
                Icon="stop",
                Tooltip=
                "Interrupts running.  Hitting Train again will pick back up where it left off.",
                UpdateFunc=UpdtFuncRunning), recv, StopCB)

        tbar.AddAction(
            gi.ActOpts(Label="Step Trial",
                       Icon="step-fwd",
                       Tooltip="Advances one training trial at a time.",
                       UpdateFunc=UpdtFuncNotRunning), recv, StepTrialCB)

        tbar.AddAction(
            gi.ActOpts(
                Label="Step Epoch",
                Icon="fast-fwd",
                Tooltip=
                "Advances one epoch (complete set of training patterns) at a time.",
                UpdateFunc=UpdtFuncNotRunning), recv, StepEpochCB)

        tbar.AddAction(
            gi.ActOpts(Label="Step Run",
                       Icon="fast-fwd",
                       Tooltip="Advances one full training Run at a time.",
                       UpdateFunc=UpdtFuncNotRunning), recv, StepRunCB)

        tbar.AddSeparator("test")

        tbar.AddAction(
            gi.ActOpts(Label="Test Trial",
                       Icon="step-fwd",
                       Tooltip="Runs the next testing trial.",
                       UpdateFunc=UpdtFuncNotRunning), recv, TestTrialCB)

        tbar.AddAction(
            gi.ActOpts(Label="Test All",
                       Icon="fast-fwd",
                       Tooltip="Tests all of the testing trials.",
                       UpdateFunc=UpdtFuncNotRunning), recv, TestAllCB)

        tbar.AddSeparator("log")

        tbar.AddAction(
            gi.ActOpts(
                Label="Reset RunLog",
                Icon="reset",
                Tooltip=
                "Resets the accumulated log of all Runs, which are tagged with the ParamSet used"
            ), recv, ResetRunLogCB)

        tbar.AddSeparator("misc")

        tbar.AddAction(
            gi.ActOpts(Label="Defaults",
                       Icon="update",
                       Tooltip="Restore initial default parameters.",
                       UpdateFunc=UpdtFuncNotRunning), recv, DefaultsCB)

        tbar.AddAction(
            gi.ActOpts(
                Label="New Seed",
                Icon="new",
                Tooltip=
                "Generate a new initial random seed to get different results.  By default, Init re-establishes the same initial seed every time."
            ), recv, NewRndSeedCB)

        tbar.AddAction(
            gi.ActOpts(
                Label="README",
                Icon="file-markdown",
                Tooltip=
                "Opens your browser on the README file that contains instructions for how to run this model."
            ), recv, ReadmeCB)

        # main menu
        appnm = gi.AppName()
        mmen = win.MainMenu
        mmen.ConfigMenus(go.Slice_string([appnm, "File", "Edit", "Window"]))

        amen = gi.Action(win.MainMenu.ChildByName(appnm, 0))
        amen.Menu.AddAppMenu(win)

        emen = gi.Action(win.MainMenu.ChildByName("Edit", 1))
        emen.Menu.AddCopyCutPaste(win)

        win.MainMenuUpdated()
        vp.UpdateEndNoSig(updt)
        win.GoStartEventLoop()
Esempio n. 8
0
    def ConfigGui(ss):
        """
        ConfigGui configures the GoGi gui interface for this simulation,
        """
        width = 1600
        height = 1200

        gi.SetAppName("rl_cond")
        gi.SetAppAbout(
            'rl_cond explores the temporal differences (TD) reinforcement learning algorithm under some basic Pavlovian conditioning environments. See <a href="https://github.com/CompCogNeuro/sims/blob/master/ch7/rl_cond/README.md">README.md on GitHub</a>.</p>'
        )

        win = gi.NewMainWindow("rl_cond", "Reinforcement Learning", width,
                               height)
        ss.Win = win

        vp = win.WinViewport2D()
        ss.vp = vp
        updt = vp.UpdateStart()

        mfr = win.SetMainFrame()

        tbar = gi.AddNewToolBar(mfr, "tbar")
        tbar.SetStretchMaxWidth()
        ss.ToolBar = tbar

        split = gi.AddNewSplitView(mfr, "split")
        split.Dim = mat32.X
        split.SetStretchMax()

        cv = ss.NewClassView("sv")
        cv.AddFrame(split)
        cv.Config()

        tv = gi.AddNewTabView(split, "tv")

        nv = netview.NetView()
        tv.AddTab(nv, "NetView")
        nv.Var = "Act"
        nv.SetNet(ss.Net)
        ss.NetView = nv

        plt = eplot.Plot2D()
        tv.AddTab(plt, "TrnTrlPlot")
        ss.TrnTrlPlot = ss.ConfigTrnTrlPlot(plt, ss.TrnTrlLog)

        tg = etview.TensorGrid()
        tv.AddTab(tg, "Weights")
        tg.SetStretchMax()
        ss.WtsGrid = tg
        tg.SetTensor(ss.RewPredInputWts)

        plt = eplot.Plot2D()
        tv.AddTab(plt, "TrnEpcPlot")
        ss.TrnEpcPlot = ss.ConfigTrnEpcPlot(plt, ss.TrnEpcLog)

        split.SetSplitsList(go.Slice_float32([.2, .8]))

        recv = win.This()

        tbar.AddAction(
            gi.ActOpts(
                Label="Init",
                Icon="update",
                Tooltip=
                "Initialize everything including network weights, and start over.  Also applies current params.",
                UpdateFunc=UpdtFuncNotRunning), recv, InitCB)

        tbar.AddAction(
            gi.ActOpts(
                Label="Train",
                Icon="run",
                Tooltip=
                "Starts the network training, picking up from wherever it may have left off.  If not stopped, training will complete the specified number of Runs through the full number of Epochs of training, with testing automatically occuring at the specified interval.",
                UpdateFunc=UpdtFuncNotRunning), recv, TrainCB)

        tbar.AddAction(
            gi.ActOpts(
                Label="Stop",
                Icon="stop",
                Tooltip=
                "Interrupts running.  Hitting Train again will pick back up where it left off.",
                UpdateFunc=UpdtFuncRunning), recv, StopCB)

        tbar.AddAction(
            gi.ActOpts(
                Label="Step Event",
                Icon="step-fwd",
                Tooltip="Advances one training event (time step) at a time.",
                UpdateFunc=UpdtFuncNotRunning), recv, StepEventCB)

        tbar.AddAction(
            gi.ActOpts(Label="Step Trial",
                       Icon="step-fwd",
                       Tooltip="Advances one training trial at a time.",
                       UpdateFunc=UpdtFuncNotRunning), recv, StepTrialCB)

        tbar.AddAction(
            gi.ActOpts(
                Label="Step Epoch",
                Icon="fast-fwd",
                Tooltip=
                "Advances one epoch (complete set of training patterns) at a time.",
                UpdateFunc=UpdtFuncNotRunning), recv, StepEpochCB)

        tbar.AddAction(
            gi.ActOpts(Label="Step Run",
                       Icon="fast-fwd",
                       Tooltip="Advances one full training Run at a time.",
                       UpdateFunc=UpdtFuncNotRunning), recv, StepRunCB)

        tbar.AddSeparator("views")

        tbar.AddAction(
            gi.ActOpts(Label="Reset Trl Log",
                       Icon="update",
                       Tooltip="Reset trial log.",
                       UpdateFunc=UpdtFuncNotRunning), recv, ResetTrlLogCB)

        tbar.AddAction(
            gi.ActOpts(
                Label="Weights Updt",
                Icon="update",
                Tooltip=
                "Update the Weights grid display to reflect the current weights.",
                UpdateFunc=UpdtFuncNotRunning), recv, WeightsUpdtCB)

        tbar.AddSeparator("misc")

        tbar.AddAction(
            gi.ActOpts(Label="Defaults",
                       Icon="update",
                       Tooltip="Restore initial default parameters.",
                       UpdateFunc=UpdtFuncNotRunning), recv, DefaultsCB)

        tbar.AddAction(
            gi.ActOpts(
                Label="New Seed",
                Icon="new",
                Tooltip=
                "Generate a new initial random seed to get different results.  By default, Init re-establishes the same initial seed every time."
            ), recv, NewRndSeedCB)

        tbar.AddAction(
            gi.ActOpts(
                Label="README",
                Icon="file-markdown",
                Tooltip=
                "Opens your browser on the README file that contains instructions for how to run this model."
            ), recv, ReadmeCB)

        vp.UpdateEndNoSig(updt)

        appnm = gi.AppName()
        mmen = win.MainMenu
        mmen.ConfigMenus(go.Slice_string([appnm, "File", "Edit", "Window"]))

        amen = gi.Action(win.MainMenu.ChildByName(appnm, 0))
        amen.Menu.AddAppMenu(win)

        emen = gi.Action(win.MainMenu.ChildByName("Edit", 1))
        emen.Menu.AddCopyCutPaste(win)

        win.MainMenuUpdated()
        vp.UpdateEndNoSig(updt)
        win.GoStartEventLoop()
Esempio n. 9
0
    def ConfigGui(ss):
        """
        ConfigGui configures the GoGi gui interface for this simulation,
        """
        width = 1600
        height = 1200

        gi.SetAppName("detector")
        gi.SetAppAbout('This simulation shows how an individual neuron can act like a detector, picking out specific patterns from its inputs and responding with varying degrees of selectivity to the match between its synaptic weights and the input activity pattern. See <a href="https://github.com/CompCogNeuro/sims/blob/master/ch2/detector/README.md">README.md on GitHub</a>.</p>')

        win = gi.NewMainWindow("detector", "Neuron as Detector", width, height)
        ss.Win = win

        vp = win.WinViewport2D()
        ss.vp = vp
        updt = vp.UpdateStart()

        mfr = win.SetMainFrame()

        tbar = gi.AddNewToolBar(mfr, "tbar")
        tbar.SetStretchMaxWidth()
        ss.ToolBar = tbar

        split = gi.AddNewSplitView(mfr, "split")
        split.Dim = mat32.X
        split.SetStretchMax()

        cv = ss.NewClassView("sv")
        cv.AddFrame(split)
        cv.Config()

        tv = gi.AddNewTabView(split, "tv")

        nv = netview.NetView()
        tv.AddTab(nv, "NetView")
        nv.Var = "Act"
        nv.SetNet(ss.Net)
        ss.NetView = nv

        nv.ViewDefaults()

        plt = eplot.Plot2D()
        tv.AddTab(plt, "TstTrlPlot")
        ss.TstTrlPlot = ss.ConfigTstTrlPlot(plt, ss.TstTrlLog)

        split.SetSplitsList(go.Slice_float32([.2, .8]))

        recv = win.This()
        
        tbar.AddAction(gi.ActOpts(Label="Init", Icon="update", Tooltip="Initialize everything including network weights, and start over.  Also applies current params.", UpdateFunc=UpdtFuncNotRunning), recv, InitCB)

        tbar.AddAction(gi.ActOpts(Label="Stop", Icon="stop", Tooltip="Interrupts running.  Hitting Train again will pick back up where it left off.", UpdateFunc=UpdtFuncRunning), recv, StopCB)
        
        tbar.AddAction(gi.ActOpts(Label="Test Trial", Icon="step-fwd", Tooltip="Runs the next testing trial.", UpdateFunc=UpdtFuncNotRunning), recv, TestTrialCB)
        
        tbar.AddAction(gi.ActOpts(Label="Test Item", Icon="step-fwd", Tooltip="Prompts for a specific input pattern name to run, and runs it in testing mode.", UpdateFunc=UpdtFuncNotRunning), recv, TestItemCB)
        
        tbar.AddAction(gi.ActOpts(Label="Test All", Icon="fast-fwd", Tooltip="Tests all of the testing trials.", UpdateFunc=UpdtFuncNotRunning), recv, TestAllCB)

        tbar.AddSeparator("log")
        
        tbar.AddAction(gi.ActOpts(Label= "Defaults", Icon= "update", Tooltip= "Restore initial default parameters.", UpdateFunc= UpdtFuncNotRunning), recv, DefaultsCB)

        tbar.AddAction(gi.ActOpts(Label="README", Icon="file-markdown", Tooltip="Opens your browser on the README file that contains instructions for how to run this model."), recv, ReadmeCB)

        # main menu
        appnm = gi.AppName()
        mmen = win.MainMenu
        mmen.ConfigMenus(go.Slice_string([appnm, "File", "Edit", "Window"]))

        amen = gi.Action(win.MainMenu.ChildByName(appnm, 0))
        amen.Menu.AddAppMenu(win)

        emen = gi.Action(win.MainMenu.ChildByName("Edit", 1))
        emen.Menu.AddCopyCutPaste(win)

        win.MainMenuUpdated()
        vp.UpdateEndNoSig(updt)
        win.GoStartEventLoop()
Esempio n. 10
0
    def ConfigGui(ss):
        """
        ConfigGui configures the GoGi gui interface for this simulation,
        """
        width = 1600
        height = 1200

        gi.SetAppName("sem")
        gi.SetAppAbout('sem is trained using Hebbian learning on paragraphs from an early draft of the *Computational Explorations..* textbook, allowing it to learn about the overall statistics of when different words co-occur with other words, and thereby learning a surprisingly capable (though clearly imperfect) level of semantic knowlege about the topics covered in the textbook.  This replicates the key results from the Latent Semantic Analysis research by Landauer and Dumais (1997). See <a href="https://github.com/CompCogNeuro/sims/blob/master/ch9/sem/README.md">README.md on GitHub</a>.</p>')

        win = gi.NewMainWindow("sem", "Sem Semantic Hebbian Learning", width, height)
        ss.Win = win

        vp = win.WinViewport2D()
        ss.vp = vp
        updt = vp.UpdateStart()

        mfr = win.SetMainFrame()

        tbar = gi.AddNewToolBar(mfr, "tbar")
        tbar.SetStretchMaxWidth()
        ss.ToolBar = tbar

        split = gi.AddNewSplitView(mfr, "split")
        split.Dim = mat32.X
        split.SetStretchMax()

        cv = ss.NewClassView("sv")
        cv.AddFrame(split)
        cv.Config()

        tv = gi.AddNewTabView(split, "tv")

        nv = netview.NetView()
        tv.AddTab(nv, "NetView")
        nv.Var = "Act"
        nv.SetNet(ss.Net)
        ss.NetView = nv
        ss.ConfigNetView(nv)

        plt = eplot.Plot2D()
        tv.AddTab(plt, "TrnEpcPlot")
        ss.TrnEpcPlot = ss.ConfigTrnEpcPlot(plt, ss.TrnEpcLog)

        plt = eplot.Plot2D()
        tv.AddTab(plt, "TstTrlPlot")
        ss.TstTrlPlot = ss.ConfigTstTrlPlot(plt, ss.TstTrlLog)

        plt = eplot.Plot2D()
        tv.AddTab(plt, "TstEpcPlot")
        ss.TstEpcPlot = ss.ConfigTstEpcPlot(plt, ss.TstEpcLog)

        plt = eplot.Plot2D()
        tv.AddTab(plt, "TstQuizPlot")
        ss.TstQuizPlot = ss.ConfigTstQuizPlot(plt, ss.TstQuizLog)

        plt = eplot.Plot2D()
        tv.AddTab(plt, "RunPlot")
        ss.RunPlot = ss.ConfigRunPlot(plt, ss.RunLog)

        split.SetSplitsList(go.Slice_float32([.2, .8]))
        recv = win.This()

        tbar.AddAction(gi.ActOpts(Label="Init", Icon="update", Tooltip="Initialize everything including network weights, and start over.  Also applies current params.", UpdateFunc=UpdtFuncNotRunning), recv, InitCB)

        tbar.AddAction(gi.ActOpts(Label="Train", Icon="run", Tooltip="Starts the network training, picking up from wherever it may have left off.  If not stopped, training will complete the specified number of Runs through the full number of Epochs of training, with testing automatically occuring at the specified interval.", UpdateFunc=UpdtFuncNotRunning), recv, TrainCB)
        
        tbar.AddAction(gi.ActOpts(Label="Stop", Icon="stop", Tooltip="Interrupts running.  Hitting Train again will pick back up where it left off.", UpdateFunc=UpdtFuncRunning), recv, StopCB)
        
        tbar.AddAction(gi.ActOpts(Label="Step Trial", Icon="step-fwd", Tooltip="Advances one training trial at a time.", UpdateFunc=UpdtFuncNotRunning), recv, StepTrialCB)
        
        tbar.AddAction(gi.ActOpts(Label="Step Epoch", Icon="fast-fwd", Tooltip="Advances one epoch (complete set of training patterns) at a time.", UpdateFunc=UpdtFuncNotRunning), recv, StepEpochCB)

        tbar.AddAction(gi.ActOpts(Label="Step Run", Icon="fast-fwd", Tooltip="Advances one full training Run at a time.", UpdateFunc=UpdtFuncNotRunning), recv, StepRunCB)
        
        tbar.AddSeparator("spec")
        
        tbar.AddAction(gi.ActOpts(Label= "Open Weights", Icon= "update", Tooltip= "Open weights trained on first phase of training (excluding 'novel' objects)", UpdateFunc=UpdtFuncNotRunning), recv, OpenWtsCB)
        
        tbar.AddAction(gi.ActOpts(Label= "Wt Words", Icon= "search", Tooltip= "get words for currently-selected hidden-layer unit in netview.", UpdateFunc=UpdtFuncNotRunning), recv, WtWordsCB)
        
        tbar.AddSeparator("test")

        tbar.AddAction(gi.ActOpts(Label="Test Trial", Icon="step-fwd", Tooltip="Runs the next testing trial.", UpdateFunc=UpdtFuncNotRunning), recv, TestTrialCB)
        
        tbar.AddAction(gi.ActOpts(Label="Test All", Icon="fast-fwd", Tooltip="Tests all of the testing trials.", UpdateFunc=UpdtFuncNotRunning), recv, TestAllCB)

        tbar.AddAction(gi.ActOpts(Label= "Quiz All", Icon= "fast-fwd", Tooltip= "all of the quiz testing trials.", UpdateFunc=UpdtFuncNotRunning), recv, QuizAllCB)
        
        tbar.AddSeparator("log")
        
        tbar.AddAction(gi.ActOpts(Label="Reset RunLog", Icon="reset", Tooltip="Resets the accumulated log of all Runs, which are tagged with the ParamSet used"), recv, ResetRunLogCB)

        tbar.AddSeparator("misc")
        
        tbar.AddAction(gi.ActOpts(Label="New Seed", Icon="new", Tooltip="Generate a new initial random seed to get different results.  By default, Init re-establishes the same initial seed every time."), recv, NewRndSeedCB)

        tbar.AddAction(gi.ActOpts(Label="README", Icon="file-markdown", Tooltip="Opens your browser on the README file that contains instructions for how to run this model."), recv, ReadmeCB)

        # main menu
        appnm = gi.AppName()
        mmen = win.MainMenu
        mmen.ConfigMenus(go.Slice_string([appnm, "File", "Edit", "Window"]))

        amen = gi.Action(win.MainMenu.ChildByName(appnm, 0))
        amen.Menu.AddAppMenu(win)

        emen = gi.Action(win.MainMenu.ChildByName("Edit", 1))
        emen.Menu.AddCopyCutPaste(win)

        # note: Command in shortcuts is automatically translated into Control for
        # Linux, Windows or Meta for MacOS
        # fmen := win.MainMenu.ChildByName("File", 0).(*gi.Action)
        # fmen.Menu.AddAction(gi.ActOpts{Label: "Open", Shortcut: "Command+O"},
        #   win.This(), func(recv, send ki.Ki, sig int64, data interface{}) {
        #       FileViewOpenSVG(vp)
        #   })
        # fmen.Menu.AddSeparator("csep")
        # fmen.Menu.AddAction(gi.ActOpts{Label: "Close Window", Shortcut: "Command+W"},
        #   win.This(), func(recv, send ki.Ki, sig int64, data interface{}) {
        #       win.Close()
        #   })

        win.MainMenuUpdated()
        vp.UpdateEndNoSig(updt)
        win.GoStartEventLoop()
Esempio n. 11
0
 def Config(self):
     self.Frame.SetStretchMaxWidth()
     self.Frame.SetStretchMaxHeight()
     self.Frame.Lay = gi.LayoutGrid
     self.Frame.Stripes = gi.RowStripes
     self.Frame.SetPropInt("columns", 2)
     updt = self.Frame.UpdateStart()
     self.Frame.SetFullReRender()
     self.Frame.DeleteChildren(True)
     flds = self.Class.__dict__
     self.Views = {}
     for nm, val in flds.items():
         tags = self.FieldTags(nm)
         if self.HasTagValue(tags, "view", "-"):
             continue
         lbl = gi.Label(self.Frame.AddNewChild(gi.KiT_Label(), "lbl_" + nm))
         lbl.SetText(nm)
         if isinstance(val, bool):
             vw = gi.CheckBox(
                 self.Frame.AddNewChild(gi.KiT_CheckBox(),
                                        self.Name + ":" + nm))
             vw.SetChecked(val)
             vw.ButtonSig.Connect(self.Frame, SetBoolValCB)
             if self.HasTagValue(tags, "inactive", "+"):
                 vw.SetInactive()
             self.Views[nm] = vw
         elif isinstance(val, go.GoClass):
             vw = gi.Action(
                 self.Frame.AddNewChild(gi.KiT_Action(),
                                        self.Name + ":" + nm))
             if hasattr(val, "Label"):
                 vw.SetText(val.Label())
             else:
                 vw.SetText(nm)
             vw.SetPropStr("padding", "2px")
             vw.SetPropStr("margin", "2px")
             vw.SetPropStr("border-radius", "4px")
             vw.ActionSig.Connect(self.Frame, EditGoObjCB)
             if self.HasTagValue(tags, "inactive", "+"):
                 vw.SetInactive()
             self.Views[nm] = vw
         elif isinstance(val, pd.DataFrame):
             vw = gi.Action(
                 self.Frame.AddNewChild(gi.KiT_Action(),
                                        self.Name + ":" + nm))
             vw.SetText(nm)
             vw.SetPropStr("padding", "2px")
             vw.SetPropStr("margin", "2px")
             vw.SetPropStr("border-radius", "4px")
             vw.ActionSig.Connect(self.Frame, EditObjCB)
             if self.HasTagValue(tags, "inactive", "+"):
                 vw.SetInactive()
             self.Views[nm] = vw
         elif isinstance(val, (int, float)):
             vw = gi.SpinBox(
                 self.Frame.AddNewChild(gi.KiT_SpinBox(),
                                        self.Name + ":" + nm))
             vw.SetValue(val)
             vw.SpinBoxSig.Connect(self.Frame, SetIntValCB)
             if self.HasTagValue(tags, "inactive", "+"):
                 vw.SetInactive()
             self.Views[nm] = vw
         else:
             vw = gi.TextField(
                 self.Frame.AddNewChild(gi.KiT_TextField(),
                                        self.Name + ":" + nm))
             vw.SetText(str(val))
             vw.SetPropStr("min-width", "10em")
             vw.TextFieldSig.Connect(self.Frame, SetStrValCB)
             if self.HasTagValue(tags, "inactive", "+"):
                 vw.SetInactive()
             self.Views[nm] = vw
     self.Frame.UpdateEnd(updt)
Esempio n. 12
0
File: inhib.py Progetto: mewbak/axon
    def ConfigGui(ss):
        """
        ConfigGui configures the GoGi gui interface for this simulation,
        """
        width = 1600
        height = 1200

        gi.SetAppName("inhib")
        gi.SetAppAbout(
            'This simulation explores how inhibitory interneurons can dynamically control overall activity levels within the network, by providing both feedforward and feedback inhibition to excitatory pyramidal neurons. See <a href="https://github.com/CompCogNeuro/sims/ch3/inhib/README.md">README.md on GitHub</a>.</p>'
        )

        win = gi.NewMainWindow("inhib", "Inhibition", width, height)
        ss.Win = win

        vp = win.WinViewport2D()
        ss.vp = vp
        updt = vp.UpdateStart()

        mfr = win.SetMainFrame()

        tbar = gi.AddNewToolBar(mfr, "tbar")
        tbar.SetStretchMaxWidth()
        ss.ToolBar = tbar

        split = gi.AddNewSplitView(mfr, "split")
        split.Dim = mat32.X
        split.SetStretchMax()

        cv = ss.NewClassView("sv")
        cv.AddFrame(split)
        cv.Config()

        tv = gi.AddNewTabView(split, "tv")

        nv = netview.NetView()
        tv.AddTab(nv, "FF Net")
        nv.Var = "Act"
        nv.Params.MaxRecs = 200
        nv.SetNet(ss.NetFF)
        ss.NetViewFF = nv
        nv.ViewDefaults()

        nv = netview.NetView()
        tv.AddTab(nv, "Bidir Net")
        nv.Var = "Act"
        nv.Params.MaxRecs = 200
        nv.SetNet(ss.NetBidir)
        ss.NetViewBidir = nv

        plt = eplot.Plot2D()
        tv.AddTab(plt, "TstCycPlot")
        ss.TstCycPlot = ss.ConfigTstCycPlot(plt, ss.TstCycLog)

        split.SetSplitsList(go.Slice_float32([.2, .8]))

        recv = win.This()

        tbar.AddAction(
            gi.ActOpts(
                Label="Init",
                Icon="update",
                Tooltip=
                "Initialize everything including network weights, and start over.  Also applies current params.",
                UpdateFunc=UpdtFuncNotRunning), recv, InitCB)

        tbar.AddAction(
            gi.ActOpts(
                Label="Stop",
                Icon="stop",
                Tooltip=
                "Interrupts running.  Hitting Train again will pick back up where it left off.",
                UpdateFunc=UpdtFuncRunning), recv, StopCB)

        tbar.AddAction(
            gi.ActOpts(Label="Test Trial",
                       Icon="step-fwd",
                       Tooltip="Runs the next testing trial.",
                       UpdateFunc=UpdtFuncNotRunning), recv, TestTrialCB)

        tbar.AddSeparator("log")

        tbar.AddAction(
            gi.ActOpts(
                Label="Config Pats",
                Icon="update",
                Tooltip=
                "Generates a new input pattern based on current InputPct amount.",
                UpdateFunc=UpdtFuncNotRunning), recv, ConfigPatsCB)

        tbar.AddAction(
            gi.ActOpts(Label="Defaults",
                       Icon="update",
                       Tooltip="Restore initial default parameters.",
                       UpdateFunc=UpdtFuncNotRunning), recv, DefaultsCB)

        tbar.AddAction(
            gi.ActOpts(
                Label="README",
                Icon="file-markdown",
                Tooltip=
                "Opens your browser on the README file that contains instructions for how to run this model."
            ), recv, ReadmeCB)

        # main menu
        appnm = gi.AppName()
        mmen = win.MainMenu
        mmen.ConfigMenus(go.Slice_string([appnm, "File", "Edit", "Window"]))

        amen = gi.Action(win.MainMenu.ChildByName(appnm, 0))
        amen.Menu.AddAppMenu(win)

        emen = gi.Action(win.MainMenu.ChildByName("Edit", 1))
        emen.Menu.AddCopyCutPaste(win)

        win.MainMenuUpdated()
        vp.UpdateEndNoSig(updt)
        win.GoStartEventLoop()
Esempio n. 13
0
    def ConfigGui(ss):
        """
        ConfigGui configures the GoGi gui interface for this simulation,
        """
        width = 1600
        height = 1200

        gi.SetAppName("a_not_b")
        gi.SetAppAbout(
            'explores how the development of PFC active maintenance abilities can help to make behavior more flexible, in the sense that it can rapidly shift with changes in the environment. The development of flexibility has been extensively explored in the context of Piagets famous A-not-B task, where a toy is first hidden several times in one hiding location (A), and then hidden in a new location (B). Depending on various task parameters, young kids reliably reach back at A instead of updating to B. See <a href="https://github.com/CompCogNeuro/sims/blob/master/ch10/a_not_b/README.md">README.md on GitHub</a>.</p>'
        )

        win = gi.NewMainWindow("a_not_b", "A not B", width, height)
        ss.Win = win

        vp = win.WinViewport2D()
        ss.vp = vp
        updt = vp.UpdateStart()

        mfr = win.SetMainFrame()

        tbar = gi.AddNewToolBar(mfr, "tbar")
        tbar.SetStretchMaxWidth()
        ss.ToolBar = tbar

        split = gi.AddNewSplitView(mfr, "split")
        split.Dim = mat32.X
        split.SetStretchMax()

        cv = ss.NewClassView("sv")
        cv.AddFrame(split)
        cv.Config()

        tv = gi.AddNewTabView(split, "tv")

        nv = netview.NetView()
        tv.AddTab(nv, "NetView")
        nv.Var = "Act"
        nv.SetNet(ss.Net)
        ss.NetView = nv
        ss.ConfigNetView(nv)

        tabv = etview.TableView()
        tv.AddTab(tabv, "TrnTrlTable")
        tabv.SetTable(ss.TrnTrlLog, go.nil)
        ss.TrnTrlTable = tabv

        plt = eplot.Plot2D()
        tv.AddTab(plt, "TrnTrlPlot")
        ss.TrnTrlPlot = ss.ConfigTrnTrlPlot(plt, ss.TrnTrlLog)

        split.SetSplitsList(go.Slice_float32([.2, .8]))
        recv = win.This()

        tbar.AddAction(
            gi.ActOpts(
                Label="Init",
                Icon="update",
                Tooltip=
                "Initialize everything including network weights, and start over.  Also applies current params.",
                UpdateFunc=UpdtFuncNotRunning), recv, InitCB)

        tbar.AddAction(
            gi.ActOpts(
                Label="Train",
                Icon="run",
                Tooltip=
                "Starts the network training, picking up from wherever it may have left off.  If not stopped, training will complete the specified number of Runs through the full number of Epochs of training, with testing automatically occuring at the specified interval.",
                UpdateFunc=UpdtFuncNotRunning), recv, TrainCB)

        tbar.AddAction(
            gi.ActOpts(
                Label="Stop",
                Icon="stop",
                Tooltip=
                "Interrupts running.  Hitting Train again will pick back up where it left off.",
                UpdateFunc=UpdtFuncRunning), recv, StopCB)

        tbar.AddAction(
            gi.ActOpts(Label="Step Trial",
                       Icon="step-fwd",
                       Tooltip="Advances one training trial at a time.",
                       UpdateFunc=UpdtFuncNotRunning), recv, StepTrialCB)

        tbar.AddAction(
            gi.ActOpts(
                Label="Step Epoch",
                Icon="fast-fwd",
                Tooltip=
                "Advances one epoch (complete set of training patterns) at a time.",
                UpdateFunc=UpdtFuncNotRunning), recv, StepEpochCB)

        tbar.AddAction(
            gi.ActOpts(Label="Step Run",
                       Icon="fast-fwd",
                       Tooltip="Advances one full training Run at a time.",
                       UpdateFunc=UpdtFuncNotRunning), recv, StepRunCB)

        tbar.AddSeparator("misc")

        tbar.AddAction(
            gi.ActOpts(
                Label="New Seed",
                Icon="new",
                Tooltip=
                "Generate a new initial random seed to get different results.  By default, Init re-establishes the same initial seed every time."
            ), recv, NewRndSeedCB)

        tbar.AddAction(
            gi.ActOpts(Label="Defaults",
                       Icon="update",
                       Tooltip="Restore initial default parameters.",
                       UpdateFunc=UpdtFuncNotRunning), recv, DefaultsCB)

        tbar.AddAction(
            gi.ActOpts(
                Label="README",
                Icon="file-markdown",
                Tooltip=
                "Opens your browser on the README file that contains instructions for how to run this model."
            ), recv, ReadmeCB)

        # main menu
        appnm = gi.AppName()
        mmen = win.MainMenu
        mmen.ConfigMenus(go.Slice_string([appnm, "File", "Edit", "Window"]))

        amen = gi.Action(win.MainMenu.ChildByName(appnm, 0))
        amen.Menu.AddAppMenu(win)

        emen = gi.Action(win.MainMenu.ChildByName("Edit", 1))
        emen.Menu.AddCopyCutPaste(win)

        # note: Command in shortcuts is automatically translated into Control for
        # Linux, Windows or Meta for MacOS
        # fmen := win.MainMenu.ChildByName("File", 0).(*gi.Action)
        # fmen.Menu.AddAction(gi.ActOpts{Label: "Open", Shortcut: "Command+O"},
        #   win.This(), func(recv, send ki.Ki, sig int64, data interface{}) {
        #       FileViewOpenSVG(vp)
        #   })
        # fmen.Menu.AddSeparator("csep")
        # fmen.Menu.AddAction(gi.ActOpts{Label: "Close Window", Shortcut: "Command+W"},
        #   win.This(), func(recv, send ki.Ki, sig int64, data interface{}) {
        #       win.Close()
        #   })

        win.MainMenuUpdated()
        vp.UpdateEndNoSig(updt)
        win.GoStartEventLoop()
Esempio n. 14
0
    def ConfigGui(ss):
        """
        ConfigGui configures the GoGi gui interface for this simulation,
        """
        width = 1600
        height = 1200

        gi.SetAppName("attn")
        gi.SetAppAbout('attn: This simulation illustrates how object recognition (ventral, what) and spatial (dorsal, where) pathways interact to produce spatial attention effects, and accurately capture the effects of brain damage to the spatial pathway. See <a href="https://github.com/CompCogNeuro/sims/blob/master/ch6/attn/README.md">README.md on GitHub</a>.</p>')

        win = gi.NewMainWindow("attn", "Attention", width, height)
        ss.Win = win

        vp = win.WinViewport2D()
        ss.vp = vp
        updt = vp.UpdateStart()

        mfr = win.SetMainFrame()

        tbar = gi.AddNewToolBar(mfr, "tbar")
        tbar.SetStretchMaxWidth()
        ss.ToolBar = tbar

        split = gi.AddNewSplitView(mfr, "split")
        split.Dim = mat32.X
        split.SetStretchMax()

        cv = ss.NewClassView("sv")
        cv.AddFrame(split)
        cv.Config()

        tv = gi.AddNewTabView(split, "tv")

        nv = netview.NetView()
        tv.AddTab(nv, "NetView")
        nv.Var = "Act"
        nv.SetNet(ss.Net)
        ss.NetView = nv
        ss.ConfigNetView(nv)
        
        plt = eplot.Plot2D()
        tv.AddTab(plt, "TstTrlPlot")
        ss.TstTrlPlot = ss.ConfigTstTrlPlot(plt, ss.TstTrlLog)

        split.SetSplitsList(go.Slice_float32([.2, .8]))

        recv = win.This()
        
        tbar.AddAction(gi.ActOpts(Label="Init", Icon="update", Tooltip="Initialize everything including network weights, and start over.  Also applies current params.", UpdateFunc=UpdtFuncNotRunning), recv, InitCB)

        tbar.AddAction(gi.ActOpts(Label="Stop", Icon="stop", Tooltip="Interrupts running.  Hitting Train again will pick back up where it left off.", UpdateFunc=UpdtFuncRunning), recv, StopCB)
        
        tbar.AddAction(gi.ActOpts(Label="Test Trial", Icon="step-fwd", Tooltip="Runs the next testing trial.", UpdateFunc=UpdtFuncNotRunning), recv, TestTrialCB)

        tbar.AddAction(gi.ActOpts(Label="Test All", Icon="step-fwd", Tooltip="Runs all testing trials.", UpdateFunc=UpdtFuncNotRunning), recv, TestAllCB)
        
        tbar.AddSeparator("log")
        
        tbar.AddAction(gi.ActOpts(Label= "Lesion", Icon= "cut", Tooltip= "Lesion spatial pathways.", UpdateFunc=UpdtFuncNotRunning), recv, LesionCB)

        tbar.AddAction(gi.ActOpts(Label= "Defaults", Icon= "update", Tooltip= "Restore initial default parameters.", UpdateFunc= UpdtFuncNotRunning), recv, DefaultsCB)

        tbar.AddAction(gi.ActOpts(Label="README", Icon="file-markdown", Tooltip="Opens your browser on the README file that contains instructions for how to run this model."), recv, ReadmeCB)

        # main menu
        appnm = gi.AppName()
        mmen = win.MainMenu
        mmen.ConfigMenus(go.Slice_string([appnm, "File", "Edit", "Window"]))

        amen = gi.Action(win.MainMenu.ChildByName(appnm, 0))
        amen.Menu.AddAppMenu(win)

        emen = gi.Action(win.MainMenu.ChildByName("Edit", 1))
        emen.Menu.AddCopyCutPaste(win)

        win.MainMenuUpdated()
        vp.UpdateEndNoSig(updt)
        win.GoStartEventLoop()
Esempio n. 15
0
    def ConfigGui(ss):
        """
        ConfigGui configures the GoGi gui interface for this simulation,
        """
        width = 1600
        height = 1200

        gi.SetAppName("v1rf")
        gi.SetAppAbout(
            'This simulation illustrates how self-organizing learning in response to natural images produces the oriented edge detector receptive field properties of neurons in primary visual cortex (V1). This provides insight into why the visual system encodes information in the way it does, while also providing an important test of the biological relevance of our computational models. See <a href="https://github.com/CompCogNeuro/sims/blob/master/ch6/v1rf/README.md">README.md on GitHub</a>.</p>'
        )

        win = gi.NewMainWindow("v1rf", "V1 Receptive Fields", width, height)
        ss.Win = win

        vp = win.WinViewport2D()
        ss.vp = vp
        updt = vp.UpdateStart()

        mfr = win.SetMainFrame()

        tbar = gi.AddNewToolBar(mfr, "tbar")
        tbar.SetStretchMaxWidth()
        ss.ToolBar = tbar

        split = gi.AddNewSplitView(mfr, "split")
        split.Dim = mat32.X
        split.SetStretchMax()

        cv = ss.NewClassView("sv")
        cv.AddFrame(split)
        cv.Config()

        tv = gi.AddNewTabView(split, "tv")

        nv = netview.NetView()
        tv.AddTab(nv, "NetView")
        nv.Var = "Act"
        nv.SetNet(ss.Net)
        ss.NetView = nv
        ss.ConfigNetView(nv)

        plt = eplot.Plot2D()
        tv.AddTab(plt, "TrnEpcPlot")
        ss.TrnEpcPlot = ss.ConfigTrnEpcPlot(plt, ss.TrnEpcLog)

        tg = etview.TensorGrid()
        tv.AddTab(tg, "Image")
        tg.SetStretchMax()
        ss.CurImgGrid = tg
        tg.SetTensor(ss.TrainEnv.Vis.ImgTsr)

        tg = etview.TensorGrid()
        tv.AddTab(tg, "V1 RFs")
        tg.SetStretchMax()
        ss.WtsGrid = tg
        tg.SetTensor(ss.V1Wts)

        plt = eplot.Plot2D()
        tv.AddTab(plt, "TstTrlPlot")
        ss.TstTrlPlot = ss.ConfigTstTrlPlot(plt, ss.TstTrlLog)

        plt = eplot.Plot2D()
        tv.AddTab(plt, "TstEpcPlot")
        ss.TstEpcPlot = ss.ConfigTstEpcPlot(plt, ss.TstEpcLog)

        plt = eplot.Plot2D()
        tv.AddTab(plt, "RunPlot")
        ss.RunPlot = ss.ConfigRunPlot(plt, ss.RunLog)

        split.SetSplitsList(go.Slice_float32([.2, .8]))

        recv = win.This()

        tbar.AddAction(
            gi.ActOpts(
                Label="Init",
                Icon="update",
                Tooltip=
                "Initialize everything including network weights, and start over.  Also applies current params.",
                UpdateFunc=UpdtFuncNotRunning), recv, InitCB)

        tbar.AddAction(
            gi.ActOpts(
                Label="Train",
                Icon="run",
                Tooltip=
                "Starts the network training, picking up from wherever it may have left off.  If not stopped, training will complete the specified number of Runs through the full number of Epochs of training, with testing automatically occuring at the specified interval.",
                UpdateFunc=UpdtFuncNotRunning), recv, TrainCB)

        tbar.AddAction(
            gi.ActOpts(
                Label="Stop",
                Icon="stop",
                Tooltip=
                "Interrupts running.  Hitting Train again will pick back up where it left off.",
                UpdateFunc=UpdtFuncRunning), recv, StopCB)

        tbar.AddAction(
            gi.ActOpts(Label="Step Trial",
                       Icon="step-fwd",
                       Tooltip="Advances one training trial at a time.",
                       UpdateFunc=UpdtFuncNotRunning), recv, StepTrialCB)

        tbar.AddAction(
            gi.ActOpts(
                Label="Step Epoch",
                Icon="fast-fwd",
                Tooltip=
                "Advances one epoch (complete set of training patterns) at a time.",
                UpdateFunc=UpdtFuncNotRunning), recv, StepEpochCB)

        tbar.AddAction(
            gi.ActOpts(Label="Step Run",
                       Icon="fast-fwd",
                       Tooltip="Advances one full training Run at a time.",
                       UpdateFunc=UpdtFuncNotRunning), recv, StepRunCB)

        tbar.AddSeparator("spec")

        tbar.AddAction(
            gi.ActOpts(
                Label="Open Rec=.2 Wts",
                Icon="updt",
                Tooltip=
                "Open weights trained with excitatory lateral (recurrent) con scale = .2.",
                UpdateFunc=UpdtFuncNotRunning), recv, OpenRec2WtsCB)

        tbar.AddAction(
            gi.ActOpts(
                Label="Open Rec=.05 Wts",
                Icon="updt",
                Tooltip=
                "Open weights trained with excitatory lateral (recurrent) con scale = .05.",
                UpdateFunc=UpdtFuncNotRunning), recv, OpenRec05WtsCB)

        tbar.AddAction(
            gi.ActOpts(
                Label="V1 RFs",
                Icon="file-image",
                Tooltip=
                "Update the V1 Receptive Field (Weights) plot in V1 RFs tab.",
                UpdateFunc=UpdtFuncNotRunning), recv, V1RFsCB)

        tbar.AddSeparator("test")

        tbar.AddAction(
            gi.ActOpts(Label="Test Trial",
                       Icon="step-fwd",
                       Tooltip="Runs the next testing trial.",
                       UpdateFunc=UpdtFuncNotRunning), recv, TestTrialCB)

        tbar.AddAction(
            gi.ActOpts(
                Label="Test Item",
                Icon="step-fwd",
                Tooltip=
                "Prompts for a specific input pattern name to run, and runs it in testing mode.",
                UpdateFunc=UpdtFuncNotRunning), recv, TestItemCB)

        tbar.AddAction(
            gi.ActOpts(Label="Test All",
                       Icon="fast-fwd",
                       Tooltip="Tests all of the testing trials.",
                       UpdateFunc=UpdtFuncNotRunning), recv, TestAllCB)

        tbar.AddSeparator("log")

        tbar.AddAction(
            gi.ActOpts(
                Label="Reset RunLog",
                Icon="reset",
                Tooltip=
                "Resets the accumulated log of all Runs, which are tagged with the ParamSet used"
            ), recv, ResetRunLogCB)

        tbar.AddSeparator("misc")

        tbar.AddAction(
            gi.ActOpts(
                Label="New Seed",
                Icon="new",
                Tooltip=
                "Generate a new initial random seed to get different results.  By default, Init re-establishes the same initial seed every time."
            ), recv, NewRndSeedCB)

        tbar.AddAction(
            gi.ActOpts(
                Label="README",
                Icon="file-markdown",
                Tooltip=
                "Opens your browser on the README file that contains instructions for how to run this model."
            ), recv, ReadmeCB)

        # main menu
        appnm = gi.AppName()
        mmen = win.MainMenu
        mmen.ConfigMenus(go.Slice_string([appnm, "File", "Edit", "Window"]))

        amen = gi.Action(win.MainMenu.ChildByName(appnm, 0))
        amen.Menu.AddAppMenu(win)

        emen = gi.Action(win.MainMenu.ChildByName("Edit", 1))
        emen.Menu.AddCopyCutPaste(win)

        win.MainMenuUpdated()
        vp.UpdateEndNoSig(updt)
        win.GoStartEventLoop()
Esempio n. 16
0
    def ConfigGui(ss):
        """
        ConfigGui configures the GoGi gui interface for this simulation,
        """
        width = 1600
        height = 1200

        gi.SetAppName("cat_dogs")
        gi.SetAppAbout('cats_dogs: This project explores a simple **semantic network** intended to represent a (very small) set of relationships among different features used to represent a set of entities in the world.  In our case, we represent some features of cats and dogs: their color, size, favorite food, and favorite toy. See <a href="https://github.com/CompCogNeuro/sims/blob/master/ch3/cats_dogs/README.md">README.md on GitHub</a>.</p>')

        win = gi.NewMainWindow("cats_dogs", "Cats and Dogs", width, height)
        ss.Win = win

        vp = win.WinViewport2D()
        ss.vp = vp
        updt = vp.UpdateStart()

        mfr = win.SetMainFrame()

        tbar = gi.AddNewToolBar(mfr, "tbar")
        tbar.SetStretchMaxWidth()
        ss.ToolBar = tbar

        split = gi.AddNewSplitView(mfr, "split")
        split.Dim = mat32.X
        split.SetStretchMax()

        cv = ss.NewClassView("sv")
        cv.AddFrame(split)
        cv.Config()

        tv = gi.AddNewTabView(split, "tv")

        nv = netview.NetView()
        tv.AddTab(nv, "NetView")
        nv.Var = "Act"
        nv.SetNet(ss.Net)
        ss.NetView = nv
        ss.ConfigNetView(nv)

        plt = eplot.Plot2D()
        tv.AddTab(plt, "TstCycPlot")
        ss.TstCycPlot = ss.ConfigTstCycPlot(plt, ss.TstCycLog)

        split.SetSplitsList(go.Slice_float32([.2, .8]))

        recv = win.This()
        
        tbar.AddAction(gi.ActOpts(Label="Init", Icon="update", Tooltip="Initialize everything including network weights, and start over.  Also applies current params.", UpdateFunc=UpdtFuncNotRunning), recv, InitCB)

        tbar.AddAction(gi.ActOpts(Label="Stop", Icon="stop", Tooltip="Interrupts running.  Hitting Train again will pick back up where it left off.", UpdateFunc=UpdtFuncRunning), recv, StopCB)
        
        tbar.AddAction(gi.ActOpts(Label="Test Trial", Icon="step-fwd", Tooltip="Runs the next testing trial.", UpdateFunc=UpdtFuncNotRunning), recv, TestTrialCB)
        
        tbar.AddAction(gi.ActOpts(Label="Test Item", Icon="step-fwd", Tooltip="Prompts for a specific input pattern name to run, and runs it in testing mode.", UpdateFunc=UpdtFuncNotRunning), recv, TestItemCB)
        
        tbar.AddAction(gi.ActOpts(Label="Test All", Icon="fast-fwd", Tooltip="Tests all of the testing trials.", UpdateFunc=UpdtFuncNotRunning), recv, TestAllCB)

        tbar.AddSeparator("log")
        
        tbar.AddAction(gi.ActOpts(Label= "Defaults", Icon= "update", Tooltip= "Restore initial default parameters.", UpdateFunc= UpdtFuncNotRunning), recv, DefaultsCB)

        tbar.AddAction(gi.ActOpts(Label="README", Icon="file-markdown", Tooltip="Opens your browser on the README file that contains instructions for how to run this model."), recv, ReadmeCB)

        # main menu
        appnm = gi.AppName()
        mmen = win.MainMenu
        mmen.ConfigMenus(go.Slice_string([appnm, "File", "Edit", "Window"]))

        amen = gi.Action(win.MainMenu.ChildByName(appnm, 0))
        amen.Menu.AddAppMenu(win)

        emen = gi.Action(win.MainMenu.ChildByName("Edit", 1))
        emen.Menu.AddCopyCutPaste(win)

        win.MainMenuUpdated()
        vp.UpdateEndNoSig(updt)
        win.GoStartEventLoop()
Esempio n. 17
0
    def ConfigGui(ss):
        """
        ConfigGui configures the GoGi gui interface for this simulation,
        """
        width = 1600
        height = 1200

        gi.SetAppName("face_categ")
        gi.SetAppAbout('face_categ: This project explores how sensory inputs (in this case simple cartoon faces) can be categorized in multiple different ways, to extract the relevant information and collapse across the irrelevant. It allows you to explore both bottom-up processing from face image to categories, and top-down processing from category values to face images (imagery), including the ability to dynamically iterate both bottom-up and top-down to cleanup partial inputs (partially occluded face images).  See <a href="https://github.com/CompCogNeuro/sims/blob/master/ch3/face_categ/README.md">README.md on GitHub</a>.</p>')

        win = gi.NewMainWindow("face_categ", "Face Categorization", width, height)
        ss.Win = win

        vp = win.WinViewport2D()
        ss.vp = vp
        updt = vp.UpdateStart()

        mfr = win.SetMainFrame()

        tbar = gi.AddNewToolBar(mfr, "tbar")
        tbar.SetStretchMaxWidth()
        ss.ToolBar = tbar

        split = gi.AddNewSplitView(mfr, "split")
        split.Dim = mat32.X
        split.SetStretchMax()

        cv = ss.NewClassView("sv")
        cv.AddFrame(split)
        cv.Config()

        tv = gi.AddNewTabView(split, "tv")

        nv = netview.NetView()
        tv.AddTab(nv, "NetView")
        nv.Var = "Act"
        nv.SetNet(ss.Net)
        ss.NetView = nv
        nv.ViewDefaults()
        ss.ConfigNetView(nv) # add labels etc

        plt = eplot.Plot2D()
        tv.AddTab(plt, "TstTrlPlot")
        ss.TstTrlPlot = ss.ConfigTstTrlPlot(plt, ss.TstTrlLog)

        split.SetSplitsList(go.Slice_float32([.2, .8]))

        recv = win.This()
        
        tbar.AddAction(gi.ActOpts(Label="Init", Icon="update", Tooltip="Initialize everything including network weights, and start over.  Also applies current params.", UpdateFunc=UpdtFuncNotRunning), recv, InitCB)

        tbar.AddAction(gi.ActOpts(Label="Stop", Icon="stop", Tooltip="Interrupts running.  Hitting Train again will pick back up where it left off.", UpdateFunc=UpdtFuncRunning), recv, StopCB)
        
        tbar.AddAction(gi.ActOpts(Label="Test Trial", Icon="step-fwd", Tooltip="Runs the next testing trial.", UpdateFunc=UpdtFuncNotRunning), recv, TestTrialCB)
        
        tbar.AddAction(gi.ActOpts(Label="Test Item", Icon="step-fwd", Tooltip="Prompts for a specific input pattern name to run, and runs it in testing mode.", UpdateFunc=UpdtFuncNotRunning), recv, TestItemCB)
        
        tbar.AddAction(gi.ActOpts(Label="Test All", Icon="fast-fwd", Tooltip="Tests all of the testing trials.", UpdateFunc=UpdtFuncNotRunning), recv, TestAllCB)

        tbar.AddSeparator("log")
        
        tbar.AddAction(gi.ActOpts(Label= "SetInput", Icon= "gear", Tooltip= "set whether the input to the network comes in bottom-up (Input layer) or top-down (Higher-level category layers)", UpdateFunc= UpdtFuncNotRunning), recv, SetInputCB)
                
        tbar.AddAction(gi.ActOpts(Label= "SetPats", Icon= "gear", Tooltip= "set which set of patterns to present -- full or partial faces", UpdateFunc= UpdtFuncNotRunning), recv, SetPatsCB)
                
        tbar.AddAction(gi.ActOpts(Label= "Cluster Plots", Icon= "image", Tooltip= "generate cluster plots of the different layer patterns", UpdateFunc= UpdtFuncNotRunning), recv, ClusterPlotCB)
                
        tbar.AddSeparator("misc")
        
        tbar.AddAction(gi.ActOpts(Label= "Defaults", Icon= "update", Tooltip= "Restore initial default parameters.", UpdateFunc= UpdtFuncNotRunning), recv, DefaultsCB)

        tbar.AddAction(gi.ActOpts(Label="README", Icon="file-markdown", Tooltip="Opens your browser on the README file that contains instructions for how to run this model."), recv, ReadmeCB)

        # main menu
        appnm = gi.AppName()
        mmen = win.MainMenu
        mmen.ConfigMenus(go.Slice_string([appnm, "File", "Edit", "Window"]))

        amen = gi.Action(win.MainMenu.ChildByName(appnm, 0))
        amen.Menu.AddAppMenu(win)

        emen = gi.Action(win.MainMenu.ChildByName("Edit", 1))
        emen.Menu.AddCopyCutPaste(win)

        win.MainMenuUpdated()
        vp.UpdateEndNoSig(updt)
        win.GoStartEventLoop()
Esempio n. 18
0
    def ConfigGui(ss):
        """
        ConfigGui configures the GoGi gui interface for this simulation,
        """
        width = 1600
        height = 1200

        gi.SetAppName("neuron")
        gi.SetAppAbout(
            'This simulation illustrates the basic properties of neural spiking and rate-code activation, reflecting a balance of excitatory and inhibitory influences (including leak and synaptic inhibition). See <a href="https://github.com/CompCogNeuro/sims/blob/master/ch2/neuron/README.md">README.md on GitHub</a>.</p>'
        )

        win = gi.NewMainWindow("neuron", "Neuron", width, height)
        ss.Win = win

        vp = win.WinViewport2D()
        ss.vp = vp
        updt = vp.UpdateStart()

        mfr = win.SetMainFrame()

        tbar = gi.AddNewToolBar(mfr, "tbar")
        tbar.SetStretchMaxWidth()
        ss.ToolBar = tbar

        split = gi.AddNewSplitView(mfr, "split")
        split.Dim = mat32.X
        split.SetStretchMaxWidth()
        split.SetStretchMaxHeight()

        cv = ss.NewClassView("sv")
        cv.AddFrame(split)
        cv.Config()

        tv = gi.AddNewTabView(split, "tv")

        nv = netview.NetView()
        tv.AddTab(nv, "NetView")
        nv.Var = "Act"
        nv.SetNet(ss.Net)
        ss.NetView = nv
        ss.ConfigNetView(nv)

        plt = eplot.Plot2D()
        tv.AddTab(plt, "TstCycPlot")
        ss.TstCycPlot = ss.ConfigTstCycPlot(plt, ss.TstCycLog)

        plt = eplot.Plot2D()
        tv.AddTab(plt, "SpikeVsRatePlot")
        ss.SpikeVsRatePlot = ss.ConfigSpikeVsRatePlot(plt, ss.SpikeVsRateLog)

        split.SetSplitsList(go.Slice_float32([.2, .8]))

        recv = win.This()

        tbar.AddAction(
            gi.ActOpts(
                Label="Init",
                Icon="update",
                Tooltip=
                "Initialize everything including network weights, and start over.  Also applies current params.",
                UpdateFunc=UpdtFuncNotRunning), recv, InitCB)

        tbar.AddAction(
            gi.ActOpts(
                Label="Stop",
                Icon="stop",
                Tooltip=
                "Interrupts running.  Hitting Train again will pick back up where it left off.",
                UpdateFunc=UpdtFuncRunning), recv, StopCB)

        tbar.AddAction(
            gi.ActOpts(Label="Run Cycles",
                       Icon="step-fwd",
                       Tooltip="Runs neuron updating over NCycles.",
                       UpdateFunc=UpdtFuncNotRunning), recv, RunCyclesCB)

        tbar.AddAction(
            gi.ActOpts(Label="Reset Plot",
                       Icon="update",
                       Tooltip="Reset TstCycPlot",
                       UpdateFunc=UpdtFuncNotRunning), recv, ResetPlotCB)

        tbar.AddAction(
            gi.ActOpts(Label="Spike Vs Rate",
                       Icon="play",
                       Tooltip="Runs Spike vs Rate Test",
                       UpdateFunc=UpdtFuncNotRunning), recv, SpikeVsRateCB)

        tbar.AddSeparator("log")

        tbar.AddAction(
            gi.ActOpts(Label="Defaults",
                       Icon="update",
                       Tooltip="Restore initial default parameters.",
                       UpdateFunc=UpdtFuncNotRunning), recv, DefaultsCB)

        tbar.AddAction(
            gi.ActOpts(
                Label="README",
                Icon="file-markdown",
                Tooltip=
                "Opens your browser on the README file that contains instructions for how to run this model."
            ), recv, ReadmeCB)

        # main menu
        appnm = gi.AppName()
        mmen = win.MainMenu
        mmen.ConfigMenus(go.Slice_string([appnm, "File", "Edit", "Window"]))

        amen = gi.Action(win.MainMenu.ChildByName(appnm, 0))
        amen.Menu.AddAppMenu(win)

        emen = gi.Action(win.MainMenu.ChildByName("Edit", 1))
        emen.Menu.AddCopyCutPaste(win)

        win.MainMenuUpdated()
        vp.UpdateEndNoSig(updt)
        win.GoStartEventLoop()