Created
November 21, 2015 20:55
-
-
Save Seanny123/db387b14a2f66fb8d12f to your computer and use it in GitHub Desktop.
Counting test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import nengo | |
from nengo import spa | |
import numpy | |
from collections import OrderedDict | |
print(numpy.version.version) | |
D = 64 | |
vocab = spa.Vocabulary(D, unitary=["ONE"]) | |
number_dict = {"ONE":1, "TWO":2, "THREE":3, "FOUR":4, "FIVE":5, | |
"SIX":6, "SEVEN":7, "EIGHT":8, "NINE":9} | |
number_ordered = OrderedDict(sorted(number_dict.items(), key=lambda t: t[1])) | |
number_range = 4 | |
vocab.parse("NONE") | |
vocab.parse("ONE") | |
number_list = number_ordered.keys() | |
for i in range(number_range): | |
vocab.add(number_list[i+1], vocab.parse("%s*ONE" % number_list[i])) | |
join_num = "+".join(number_list[0:number_range]) | |
num_ord_filt = OrderedDict(number_ordered.items()[:number_range]) | |
print(join_num) | |
vocab.add("ALLNUM", vocab.parse(join_num)) | |
model = spa.SPA(vocab) | |
with model: | |
model.q1 = spa.State(D) | |
model.q2 = spa.State(D) | |
model.answer = spa.State(D) | |
# reload | |
actions = spa.Actions( | |
# If the input isn't blank, read it in | |
q1= | |
"dot(q1, ONE+TWO)" | |
"--> answer=q1*ONE", | |
q2= | |
"dot(q2, ONE+TWO)" | |
"--> answer=q2*ONE", | |
) | |
model.bg = spa.BasalGanglia(actions) | |
model.thal = spa.Thalamus(model.bg) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment