nengo / nengo-gui

Nengo interactive visualizer
Other
95 stars 38 forks source link

Need some intuition just output few schematic point variable in one plot #1033

Open Runnlion opened 3 years ago

Runnlion commented 3 years ago

When I reimplement a github project "spa-poem" , I don't konw how to output a graph just contain few variables. The output graph has the enatirly schematic vocabularies.

I want a graph with few variables we want

I considered to run it in juypter and set the vocabulary value like "SNAKE", but I dont konw how to set the value of a nengo_spa.model_name

Thanks

xchoo commented 3 years ago

In the NengoGUI, you can specify what vocabulary to use for a Semantic Pointer cloud display by specifying the vocabulary to use with a specific spa component. For example, in the code below, both state1 and state2 represent identical information (you can see from the vector graphs that the vector represented by both components are the identical), the semantic pointer cloud display is different. The state1 semantic pointer cloud only shows "A", while the state2 semantic pointer cloud shows both "A" and "C".

The Code:

import nengo
import nengo_spa as spa

dim = 32
vocab = spa.Vocabulary(dimensions=dim)
vocab.populate("A;B;C;D;E")
vocab2 = vocab.create_subset(["A", "B"])

with spa.Network() as model:
    stim = spa.Transcode("A+C", output_vocab=vocab)
    state1 = spa.State(vocab=vocab2, seed=0)  # Using the custom (smaller) vocabulary
    state2 = spa.State(vocab=vocab, seed=0)  # Using the "default" vocabulary
    nengo.Connection(stim.output, state1.input)
    nengo.Connection(state1.output, state2.input)

Sample output from NengoGUI image

Some notes: Just to prove that no information is lost, the output of state1 is connected to the input of state2. If information had been lost by changing the the vocabulary of state1, the output of state2 would reflect state1 (i.e., just "A", instead of "A" and "C").

Additionally, note that Nengo has a dedicated support forum, found at https://forum.nengo.ai . It provides a wealth of resources for you to search to related to all of the Nengo products (e.g., Nengo, NengoGUI, Nengo Loihi, etc.).