Hi -
I’m trying to model the Wisconsin Card Sort Test. It seems as if it should be trivially easy, but I can’t work out a counter.
The model compares 2 vectors with a compare object, the output of which is sent to a node.
If the values are similar, let’s say output is > 0.8, the model is supposed to keep following that rule until it has done it correctly 10 times in a row. The problem with my code is that the node can’t capture the idea that separate steps have occurred.
My gut is that some variation on the delay_node example will work, but right now that is beyond me.
thanks
Howard C.
import nengo
import numpy as np
import nengo.spa as spa
import random
D = 16
model = spa.SPA()
with model:
model.vocab = spa.Vocabulary(D)
model.vocab.parse('CORRECT + INCORRECT + NUMBER + SHAPE + COLOR')
model.pt_response = spa.State(D)
model.tester_response = spa.State(D)
def output_pt(t):
if 0 < t < 1:
return 'SHAPE'
elif 1 < t < 2:
return 'COLOR'
elif 2 < t < 3:
return 'NUMBER'
elif 3 < t < 4:
return 'NUMBER'
elif 4 < t < 5:
return 'NUMBER'
elif 5 < t < 6:
return 'COLOR'
elif 6 < t < 7:
return 'NUMBER'
else:
return '0'
def correct_response(t):
if 0 < t < 10:
return 'NUMBER'
elif 1 < t < 2:
return 'COLOR'
elif 2 < t < 3:
return 'NUMBER'
elif 3 < t < 4:
return 'NUMBER'
else:
return '0'
model.input_pt = spa.Input(pt_response = output_pt)
model.input_tester = spa.Input(tester_response = correct_response)
model.Compare = spa.Compare(vocab = model.vocab, dimensions = D)
nengo.Connection(model.pt_response.output, model.Compare.inputA, synapse = 0)
nengo.Connection(model.tester_response.output, model.Compare.inputB, synapse = 0)
node_1 = nengo.Node(size_in = 1, size_out = 1)
nengo.Connection(model.Compare.output, node_1)
def counter(t,x,count = 0):
if x < 0.8:
count = 0
return count
elif x > 0.8 and count < 10:
count = count + 1
return count
else:
count = 0
return count
node_1.output = counter