def model(self, p): self.proto = PROTOCOLS[p.protocol] self.stim_provider = StimulusProvider(self.proto, p.distractor_rate, p.recall_duration) self.vocabs = Vocabularies(self.stim_provider, p.item_d, p.context_d, self.proto.n_items + 3, np.random.RandomState(p.seed + 1)) with spa.Network(seed=p.seed) as model: model.cue = CUE(self.stim_provider, self.vocabs, p.beta, p.gamma, p.ose_thr, p.ordinal_prob, p.noise, p.min_evidence) self.p_recalls = nengo.Probe(model.cue.output, synapse=0.01) self.p_pos = nengo.Probe(model.cue.output_pos, synapse=0.01) self.probes = { 'ctx': nengo.Probe(model.cue.tcm.current_ctx.current.mem.output, synapse=0.01), 'ctx_spikes': nengo.Probe( model.cue.tcm.current_ctx.current.mem.state_ensembles. ensembles[-1].neurons, 'spikes'), } return model
def model(self, p): self.stim_provider = MixedSelStimulusProvider(p.sequence) self.vocabs = Vocabularies(self.stim_provider, p.item_d, p.context_d, self.stim_provider.n_total_items, np.random.RandomState(p.seed + 1)) with spa.Network(seed=p.seed) as model: model.cue = CUE(self.stim_provider, self.vocabs, p.beta, p.gamma, p.ose_thr, 1., p.noise, p.min_evidence) self.p = nengo.Probe(model.cue.ose.mem.mem.output, synapse=0.01) self.p_spikes = nengo.Probe( model.cue.ose.mem.mem.state_ensembles.ensembles[-1].neurons, 'spikes') self.debug_probes = {} if p.debug: for k in self.debug_probes: self.debug_probes[k] = nengo.Probe(self.debug_probes[k], synapse=0.01) return model
def model(self, p): self.proto = PROTOCOLS[p.protocol] self.stim_provider = StimulusProvider(self.proto, p.distractor_rate, p.recall_duration) self.vocabs = Vocabularies(self.stim_provider, p.item_d, p.context_d, self.proto.n_items + 3, np.random.RandomState(p.seed + 1)) with spa.Network(seed=p.seed) as model: model.cue = CUE(self.stim_provider, self.vocabs, p.beta, p.gamma, p.ose_thr, p.ordinal_prob, p.noise, p.min_evidence) self.p_recalls = nengo.Probe(model.cue.output, synapse=0.01) self.p_pos = nengo.Probe(model.cue.output_pos, synapse=0.01) self.probes = { 'stm': nengo.Probe(model.cue.ose.mem.mem.output, synapse=0.01), 'stm_spikes': nengo.Probe( model.cue.ose.mem.mem.state_ensembles.ensembles[-1]. neurons, 'spikes'), 'm_tf_input_cue': nengo.Probe(model.cue.tcm.net_m_tf.input_cue, synapse=0.01), 'm_tf_input_target': nengo.Probe(model.cue.tcm.net_m_tf.input_target, synapse=0.01), 'm_tf_output': nengo.Probe(model.cue.tcm.net_m_tf.output, synapse=0.01), 'm_tf_output_no_filter': nengo.Probe(model.cue.tcm.net_m_tf.output, synapse=None), } for c in model.cue.tcm.net_m_tf.connections: if (c.pre in model.cue.tcm.net_m_tf.state.all_ensembles and hasattr(c.post, 'obj') and c.post.obj is model.cue.tcm.net_m_tf.output): self.probes['m_tf_weights'] = nengo.Probe(c, 'weights') break self.m_tf_post = model.cue.tcm_recall_gate.state_ensembles.ensembles[ -1] return model
def model(self, p): if p.rand_pos == 'None': rand_pos = None else: rand_pos = int(p.rand_pos) self.stim_provider = HebbRepStimulusProvider( n_total_items=9, n_items_per_list=9, n_lists=24, rep_pattern=[x == '1' for x in p.rep_pattern], rand_pos=rand_pos, pi=1., recall_duration=60.) self.vocabs = Vocabularies( self.stim_provider, p.item_d, p.context_d, self.stim_provider.n_total_items, np.random.RandomState(p.seed + 1)) with spa.Network(seed=p.seed) as model: model.cue = CUE( self.stim_provider, self.vocabs, p.beta, p.gamma, p.ose_thr, p.ordinal_prob, p.noise, p.min_evidence, decay=p.decay, extensions={p.extension}) self.p_recalls = nengo.Probe(model.cue.output, synapse=0.01) self.p_pos = nengo.Probe(model.cue.output_pos, synapse=0.01) self.debug_probes = { 'start_of_serial_recall': model.cue.start_of_serial_recall, 'start_of_free_recall': model.cue.start_of_free_recall, 'start_of_pres_phase': model.cue.start_of_pres_phase, } if p.debug: for k in self.debug_probes: self.debug_probes[k] = nengo.Probe( self.debug_probes[k], synapse=0.01) return model
def model(self, p): if p.extension is None: extensions = set() else: extensions = {p.extension} random.seed(p.seed) self.proto = PROTOCOLS[p.protocol] self.stim_provider = RecognitionStimulusProvider( self.proto, p.distractor_rate) self.vocabs = Vocabularies(self.stim_provider, p.item_d, p.context_d, self.proto.n_items + 3, np.random.RandomState(p.seed + 1)) with spa.Network(seed=p.seed) as model: model.cue = CUE(self.stim_provider, self.vocabs, p.beta, p.gamma, p.ose_thr, p.ordinal_prob, p.noise, p.min_evidence, decay=p.decay, extensions=extensions) self.p_pos = nengo.Probe(model.cue.tcm.input_pos, synapse=0.01) self.p_ctx = nengo.Probe(model.cue.tcm.current_ctx.current.mem. state_ensembles.ensembles[-1].neurons, 'spikes', synapse=None) self.p_vhat = nengo.Probe( model.cue.recall.buf.mem.state_ensembles.ensembles[-1].neurons, 'spikes', synapse=None) self.p_phat = nengo.Probe(model.cue.pos_recall.buf.mem. state_ensembles.ensembles[-1].neurons, 'spikes', synapse=None) self.p_p = nengo.Probe( model.cue.in_pos_gate.state_ensembles.ensembles[-1].neurons, 'spikes', synapse=None) self.p_tf_out = nengo.Probe( model.cue.tcm.net_m_tf.state.state_ensembles.ensembles[-1]. neurons[:800], 'spikes', synapse=None) self.p_ose = nengo.Probe( model.cue.ose.mem.mem.state_ensembles.ensembles[-1].neurons, 'spikes', synapse=None) self.debug_probes = { 'recall_state': model.cue.recall.state.output, 'recall_threshold': model.cue.recall.threshold.heaviside, 'recall_buf': model.cue.recall.buf.output, 'pos_recall_state': model.cue.pos_recall.state.output, 'pos_recall_buf': model.cue.pos_recall.buf.output, 'aml_comp': model.cue.tcm.net_m_tf.compare.output, 'ctx': model.cue.tcm.current_ctx.output, 'ctx_update': model.cue.tcm.current_ctx.input_update_context, 'inhib_recall': model.cue.recall.inhibit.output, 'out_inhibit_gate': model.cue.recall.out_inhibit_gate.output, 'recall_ctx': model.cue.tcm.net_m_ft.output, 'recall_ctx_cue': model.cue.tcm.net_m_ft.input_cue, 'input_pos': model.cue.tcm.input_pos, 'current_ctx': model.cue.tcm.current_ctx.output, 'input_update_ctx': model.cue.tcm.input_update_context, 'sim_th': model.cue.sim_th.output, 'last_item': model.cue.last_item.output, 'ose_output': model.cue.ose.output, 'tcm_output': model.cue.tcm.net_m_tf.output, 'failed_recall_int': model.cue.recall.failed_recall_int, 'failed_recall': model.cue.recall.failed_recall, 'failed_recall_heaviside': model.cue.recall.failed_recall_heaviside, 'start_of_serial_recall': model.cue.start_of_serial_recall, 'start_of_free_recall': model.cue.start_of_free_recall, 'pos_state': model.cue.pos.state.output, 'pos_state_in': model.cue.pos.state.input, 'pos_inhibit_threshold': model.cue.pos.inhibit_threshold.output, 'pos_advance_threshold': model.cue.pos.advance_threshold.output, 'input_inc': model.cue.pos.input_inc, 'no_pos_count': model.cue.ctrl.output_no_pos_count, 'ose_recall_gate': model.cue.ose_recall_gate.output, 'tcm_recall_gate': model.cue.tcm_recall_gate.output, 'pos_gate': model.cue.pos_gate.output, 'ose': model.cue.ose.mem.output, 'buf_input_store': model.cue.recall.buf_input_store, # 'out_inhib_gate_update': model.cue.recall.out_inhib_gate_update, # 'input_update_inhibit': model.cue.recall.input_update_inhibit, 'sim_th_neg': model.cue.sim_th_neg, 'sim_th_pos': model.cue.sim_th_pos, } if p.debug: for k in self.debug_probes: self.debug_probes[k] = nengo.Probe(self.debug_probes[k], synapse=0.01) return model
# coding: utf-8 from cue.model import CUE, Vocabularies from cue.protocols import StimulusProvider, Recall proto = Recall(n_items=20, pi=1., ipi=0., ri=0., lr=10., serial=False, exp_data=None) stim_provider = StimulusProvider(proto, 0., recall_duration=60.) vocabs = Vocabularies(stim_provider, 256, 256, proto.n_items) model = CUE(stim_provider, vocabs, 0.6, 0.9775, 0.1, 0.1, 0.009, 0.035) n_item_recall = model.recall.n_neurons n_pos_recall = model.pos_recall.n_neurons if __name__ == '__main__': print("TCM", model.tcm.n_neurons) print("ctx", model.tcm.current_ctx.n_neurons) print("OSE", model.ose.n_neurons) print("pos", model.pos.n_neurons) print("recall", n_item_recall + n_pos_recall) print("item recall", n_item_recall) print("pos recall", n_pos_recall) print("total", model.n_neurons)