Hi,
I require assistance with my custom process. I want to write a custom process that iterates over the input (vectors) and assigns a duration to each vector, such that each vector is presented for a different period of time.
My process works in general, however when I apply it in my model, the index only updates for the input process, not the target process, and remains 0 during the simulation.
Here is the code for the process:
# Create Custom Process
class FlexibleDuration(nengo.Process):
inputs = NdarrayParam("inputs", shape=("...",))
presentation_time = NdarrayParam("presentation_time", shape=("...",))
def __init__(self, inputs, presentation_time, timer, index, internal_t, **kwargs):
self.inputs = inputs
self.presentation_time = presentation_time
self.timer = timer
self.index = index
self.internal_t = internal_t
super().__init__(
default_size_in=0, default_size_out=self.inputs[0].size, **kwargs
)
def make_step(self, shape_in, shape_out, dt, rng, state):
assert shape_in == (0,)
assert shape_out == (self.inputs[0].size,)
n = len(self.inputs)
inputs = self.inputs.reshape(n, -1)
n1 = len(self.inputs)
presentation_time = self.presentation_time.reshape(n1, -1)
index = int(self.index)
timer = int(self.timer)
internal_t = int(self.internal_t)
def step_presentinput(t):
self.internal_t += dt
#print(t,self.internal_t, self.timer)
if self.internal_t > self.timer:
self.index += 1
if self.index == len(self.inputs):
self.index = 0
self.timer += self.presentation_time[self.index]
#print('in loop ', self.internal_t, self.index, self.timer)
return inputs[self.index]
return step_presentinput
This is how I create the processes afterwards:
c_timer = duration_shuff[0]
c_index = 0
c_internal_t = 0
s_timer = duration_shuff[0]
s_index = 0
s_internal_t = 0
process_in = FlexibleDuration(c_mat_shuff, presentation_time=duration_shuff,timer=c_timer,index=c_index,internal_t=c_internal_t)
process_target = FlexibleDuration(s_mat_shuff, presentation_time=duration_shuff,timer=s_timer,index=s_index,internal_t=s_internal_t)
And this is how I integrate it in the model:
inp = nengo.Node(process_in)
target = nengo.Node(process_target)
I hope you can help me, thanks in advance!