interface=wm_interface)) defaults = Construct(name=buffer("defaults"), process=Constants(strengths=default_strengths)) acs = Structure(name=subsystem("acs")) with acs: # We include a flow_in construct to handle converting chunk activations # from working memory into features that the ACS can understand. Construct(name=flow_in("wm"), process=TopDown(source=buffer("wm"), chunks=nacs_cdb)) Construct(name=features("main"), process=MaxNodes(sources=[ buffer("acs_ctrl"), flow_in("wm"), buffer("defaults") ])) # This terminus controls the working memory. Construct(name=terminus("wm"), process=ActionSelector(source=features("main"), temperature=.01, interface=alice.assets.wm_interface)) # This terminus controls the agent's speech actions.
alice = Structure(name=agent("alice")) with alice: stimulus = Construct(name=buffer("stimulus"), process=Stimulus()) nacs = Structure(name=subsystem("nacs"), assets=Assets(chunk_db=chunk_db)) with nacs: # Although the entry point for the NACS are chunks, in this example we # start with features as there are no constructs that initially # activate chunks in the NACS activation cycle. Construct(name=features("main"), process=MaxNodes(sources=[buffer("stimulus")])) Construct(name=flow_bt("main"), process=BottomUp(source=features("main"), chunks=nacs.assets.chunk_db)) Construct(name=chunks("main"), process=MaxNodes(sources=[flow_bt("main")])) # Termini # In addition to introducting chunk extraction, this example # demonstrates the use of two temrmini in one single subsytem. We # include one terminus for the output of the top level and one for the # bottom level.
stimulus = Construct( name=buffer("stimulus"), process=Stimulus() ) nacs = Structure( name=subsystem("nacs"), ) with nacs: Construct( name=flow_in("lag"), process=Lag( source=features("main"), max_lag=1 ) ) Construct( name=features("main"), process= MaxNodes( sources=[ buffer("stimulus"), flow_in("lag") ] ) )
defaults = Construct(name=buffer("defaults"), process=Constants(strengths=default_strengths)) # This simulation adds an entirely new subsystem to the model: the # action-centered subystem, which handles action selection. We keep this # ACS to a bare minimum. acs = Structure(name=subsystem("acs")) with acs: # Assembly of the ACS is similar to the NACS, but features are the # (primary) entry points for activations. Construct( name=features("main"), process=MaxNodes(sources=[buffer("acs_ctrl"), buffer("defaults")])) # We define an action terminus in ACS for controlling flow gating in # NACS. To do this, we make use of the ActionSelector emitter, which # selects, for each command dimension in its client interface, a single # value through boltzmann sampling, and forwards activations of any # parameter features defined in the interface. Construct(name=terminus("nacs"), process=ActionSelector(source=features("main"), interface=alice.assets.gate_interface, temperature=0.01)) # Next, we set up the NACS, adding the `Gated` wrapper where necessary.
# of a stimulus buffer. In more sophisticated models, reinforcements may be # generated by the Meta-Cognitive Subsystem. reinforcement = Construct(name=buffer("reinforcement"), process=Stimulus()) acs = Structure(name=subsystem("acs")) with acs: # We use a simple repeater to relay the actions selected on the # previous step back to the qnet. Construct(name=flow_in("ext_actions_lag1"), process=Repeater(source=terminus("ext_actions"))) Construct(name=features("in"), process=MaxNodes(sources=[buffer("sensory")])) # We construct the Q-Net just like any other Process instance and # integrate it into the bottom level. Note that it is designated as a # construct of type flow_bb. The particular Process class used here, # SimpleQNet, will construct an MLP with two hidden layers containing 5 # nodes each. Weight updates occur at each step (i.e., training is # online) through gradient descent with backpropagation. # On each trial, the q-net outputs its Q values to drive action # selection at the designated terminus. The Q values are squashed prior # being output to ensure that they lie in [0, 1]. qnet = Construct(name=flow_bb("q_net"), process=SimpleQNet(