Example #1
0
    def model(self, p):
        model = spa.SPA()
        with model:
            model.vision = spa.Buffer(dimensions=p.D)
            model.phrase = spa.Buffer(dimensions=p.D)
            model.motor = spa.Buffer(dimensions=p.D)
            model.noun = spa.Memory(dimensions=p.D, synapse=0.1)
            model.verb = spa.Memory(dimensions=p.D, synapse=0.1)

            model.bg = spa.BasalGanglia(
                spa.Actions(
                    'dot(vision, WRITE) --> verb=vision',
                    'dot(vision, ONE+TWO+THREE) --> noun=vision',
                    '0.5*(dot(vision, NONE-WRITE-ONE-TWO-THREE) + '
                    'dot(phrase, WRITE*VERB))'
                    '--> motor=phrase*~NOUN',
                ))
            model.thal = spa.Thalamus(model.bg)

            model.cortical = spa.Cortical(
                spa.Actions(
                    'phrase=noun*NOUN',
                    'phrase=verb*VERB',
                ))

            def vision_input(t):
                index = int(t / p.time_per_word) % 3
                return ['WRITE', 'ONE', 'NONE'][index]

            model.input = spa.Input(vision=vision_input)

            self.motor_vocab = model.get_output_vocab('motor')
            self.p_thal = nengo.Probe(model.thal.actions.output, synapse=0.03)
            self.p_motor = nengo.Probe(model.motor.state.output, synapse=0.03)

        split.split_input_nodes(model, max_dim=64)
        self.replaced = split.split_passthrough(model, max_dim=p.split_max_dim)
        if p.pass_ensembles > 0:
            split.pass_ensembles(model, max_dim=p.pass_ensembles)

        if p.backend == 'nengo_spinnaker':
            import nengo_spinnaker
            nengo_spinnaker.add_spinnaker_params(model.config)
            for node in model.all_nodes:
                if node.output is None:
                    if node.size_in > p.pf_max_dim:
                        print 'limiting', node
                        model.config[node].n_cores_per_chip = p.pf_cores
                        model.config[node].n_chips = p.pf_n_chips
            model.config[nengo_spinnaker.Simulator].placer_kwargs = dict(
                effort=0.1)

        if p.fixed_seed:
            for ens in model.all_ensembles:
                ens.seed = 1

        return model
Example #2
0
    def model(self, p):
        model = spa.SPA()
        with model:
            model.vision = spa.Buffer(dimensions=p.D)
            model.phrase = spa.Buffer(dimensions=p.D)
            model.motor = spa.Buffer(dimensions=p.D)
            model.noun = spa.Memory(dimensions=p.D, synapse=0.1)
            model.verb = spa.Memory(dimensions=p.D, synapse=0.1)

            model.bg = spa.BasalGanglia(spa.Actions(
                'dot(vision, WRITE) --> verb=vision',
                'dot(vision, ONE+TWO+THREE) --> noun=vision',
                '0.5*(dot(vision, NONE-WRITE-ONE-TWO-THREE) + '
                     'dot(phrase, WRITE*VERB))'
                     '--> motor=phrase*~NOUN',
                ))
            model.thal = spa.Thalamus(model.bg)

            model.cortical = spa.Cortical(spa.Actions(
                'phrase=noun*NOUN',
                'phrase=verb*VERB',
                ))

            def vision_input(t):
                index = int(t / p.time_per_word) % 3
                return ['WRITE', 'ONE', 'NONE'][index]
            model.input = spa.Input(vision=vision_input)

            self.motor_vocab = model.get_output_vocab('motor')
            self.p_thal = nengo.Probe(model.thal.actions.output, synapse=0.03)
            self.p_motor = nengo.Probe(model.motor.state.output, synapse=0.03)

        split.split_input_nodes(model, max_dim=64)
        self.replaced = split.split_passthrough(model,
                                                max_dim=p.split_max_dim)
        if p.pass_ensembles > 0:
            split.pass_ensembles(model, max_dim=p.pass_ensembles)

        if p.backend == 'nengo_spinnaker':
            import nengo_spinnaker
            nengo_spinnaker.add_spinnaker_params(model.config)
            for node in model.all_nodes:
                if node.output is None:
                    if node.size_in > p.pf_max_dim:
                        print 'limiting', node
                        model.config[node].n_cores_per_chip = p.pf_cores
                        model.config[node].n_chips = p.pf_n_chips
            model.config[
                nengo_spinnaker.Simulator].placer_kwargs = dict(effort=0.1)

        if p.fixed_seed:
            for ens in model.all_ensembles:
                ens.seed = 1

        return model
Example #3
0
    def model(self, p):
        model = spa.SPA()
        with model:
            model.word = spa.State(dimensions=p.D)
            model.marker = spa.State(dimensions=p.D)
            model.memory = spa.State(dimensions=p.D, feedback=1)

            model.cortical = spa.Cortical(spa.Actions(
                'memory = word * marker',
                ))

            def word(t):
                index = t / p.time_per_symbol
                if index < p.n_symbols:
                    return 'S%d' % index
                return '0'

            def marker(t):
                index = t / p.time_per_symbol
                if index < p.n_symbols:
                    return 'M%d' % index
                return '0'

            model.input = spa.Input(word=word, marker=marker)

            self.p_memory = nengo.Probe(model.memory.output, synapse=0.03)
            self.vocab = model.get_output_vocab('memory')

        split.split_input_nodes(model, max_dim=16)
        self.replaced = split.split_passthrough(model,
                                                max_dim=p.split_max_dim)
        if p.pass_ensembles > 0:
            split.pass_ensembles(model, max_dim=p.pass_ensembles)

        if p.backend == 'nengo_spinnaker':
            import nengo_spinnaker
            nengo_spinnaker.add_spinnaker_params(model.config)
            for node in model.all_nodes:
                if node.output is None:
                    if node.size_in > p.pf_max_dim:
                        print 'limiting', node
                        model.config[node].n_cores_per_chip = p.pf_cores
                        model.config[node].n_chips = p.pf_n_chips
            model.config[
                nengo_spinnaker.Simulator].placer_kwargs = dict(effort=0.1)

        split.remove_outputless_passthrough(model)

        if p.fixed_seed:
            for ens in model.all_ensembles:
                ens.seed = 1

        return model
Example #4
0
    def model(self, p):
        model = spa.SPA()
        with model:
            model.word = spa.State(dimensions=p.D)
            model.marker = spa.State(dimensions=p.D)
            model.memory = spa.State(dimensions=p.D, feedback=1)

            model.cortical = spa.Cortical(
                spa.Actions('memory = word * marker', ))

            def word(t):
                index = t / p.time_per_symbol
                if index < p.n_symbols:
                    return 'S%d' % index
                return '0'

            def marker(t):
                index = t / p.time_per_symbol
                if index < p.n_symbols:
                    return 'M%d' % index
                return '0'

            model.input = spa.Input(word=word, marker=marker)

            self.p_memory = nengo.Probe(model.memory.output, synapse=0.03)
            self.vocab = model.get_output_vocab('memory')

        split.split_input_nodes(model, max_dim=16)
        self.replaced = split.split_passthrough(model, max_dim=p.split_max_dim)
        if p.pass_ensembles > 0:
            split.pass_ensembles(model, max_dim=p.pass_ensembles)

        if p.backend == 'nengo_spinnaker':
            import nengo_spinnaker
            nengo_spinnaker.add_spinnaker_params(model.config)
            for node in model.all_nodes:
                if node.output is None:
                    if node.size_in > p.pf_max_dim:
                        print 'limiting', node
                        model.config[node].n_cores_per_chip = p.pf_cores
                        model.config[node].n_chips = p.pf_n_chips
            model.config[nengo_spinnaker.Simulator].placer_kwargs = dict(
                effort=0.1)

        split.remove_outputless_passthrough(model)

        if p.fixed_seed:
            for ens in model.all_ensembles:
                ens.seed = 1

        return model