def _get_n_connections(self, pre_vertex_slice, post_vertex_slice):
        # do the work from self._cset in here
        # get the values for this slice
        pre_lo = pre_vertex_slice.lo_atom
        pre_hi = pre_vertex_slice.hi_atom
        post_lo = post_vertex_slice.lo_atom
        post_hi = post_vertex_slice.hi_atom

        # this is where the magic needs to happen somehow
        if self._full_cset is None:
            self._full_cset = [
                x for x in csa.cross(range(self._n_pre_neurons),
                                     range(self._n_post_neurons)) * self._cset
            ]

        # use CSA to cross the range of this vertex's neurons with the cset
        pair_list = csa.cross(range(pre_lo, pre_hi + 1),
                              range(post_lo, post_hi + 1)) * self._full_cset

        if self._verbose:
            print('full cset: ', self._full_cset)
            print('this vertex pair_list: ', pair_list)
            print('this vertex pre_neurons: ', [x[0] for x in pair_list])
            print('this vertex post_neurons: ', [x[1] for x in pair_list])

        n_connections = len(pair_list)  # size of the array created
        return n_connections, pair_list
Exemple #2
0
    def _get_n_connections(
            self, pre_vertex_slice, post_vertex_slice, synapse_info):
        """
        :param ~pacman.model.graphs.common.Slice pre_vertex_slice:
        :param ~pacman.model.graphs.common.Slice post_vertex_slice:
        :param SynapseInformation synapse_info:
        :rtype: tuple(int, cset.connset.CSet)
        """
        # do the work from self._cset in here

        # this is where the magic needs to happen somehow
        if self.__full_cset is None:
            self.__full_cset = [x for x in csa.cross(
                range(synapse_info.n_pre_neurons),
                range(synapse_info.n_post_neurons)) * self.__cset]

        # use CSA to cross the range of this vertex's neurons with the cset
        pair_list = csa.cross(
            range(pre_vertex_slice.lo_atom, pre_vertex_slice.hi_atom+1),
            range(post_vertex_slice.lo_atom, post_vertex_slice.hi_atom+1)) \
            * self.__full_cset

        if self.verbose:
            print('full cset: ', self.__full_cset)
            print('this vertex pair_list: ', pair_list)
            print('this vertex pre_neurons: ', [x[0] for x in pair_list])
            print('this vertex post_neurons: ', [x[1] for x in pair_list])

        n_connections = len(pair_list)  # size of the array created
        return n_connections, pair_list
    def _get_n_connections(self, pre_vertex_slice, post_vertex_slice):
        # do the work from self._cset in here
        # get the values for this slice
        pre_lo = pre_vertex_slice.lo_atom
        pre_hi = pre_vertex_slice.hi_atom
        post_lo = post_vertex_slice.lo_atom
        post_hi = post_vertex_slice.hi_atom

        # this is where the magic needs to happen somehow
        if self._full_cset is None:
            self._full_cset = [x for x in csa.cross(
                range(self._n_pre_neurons),
                range(self._n_post_neurons)) * self._cset]

        # use CSA to cross the range of this vertex's neurons with the cset
        pair_list = csa.cross(
            range(pre_lo, pre_hi+1),
            range(post_lo, post_hi+1)) * self._full_cset

        if self._verbose:
            print('full cset: ', self._full_cset)
            print('this vertex pair_list: ', pair_list)
            print('this vertex pre_neurons: ',
                  [x[0] for x in pair_list])
            print('this vertex post_neurons: ',
                  [x[1] for x in pair_list])

        n_connections = len(pair_list)  # size of the array created
        return n_connections, pair_list
    def connect(self, projection):
        """Connect-up a Projection."""
        # Cut out finite part
        c = csa.cross((0, projection.pre.size - 1),
                      (0, projection.post.size - 1)) * self.cset

        if csa.arity(self.cset) == 2:
            # Connection-set with arity 2
            for (i, j, weight, delay) in c:
                projection.connection_manager.connect(projection.pre[i],
                                                      [projection.post[j]],
                                                      weight, delay)
        elif CSAConnector.isConstant (self.weights) \
             and CSAConnector.isConstant (self.delays):
            # Mask with constant weights and delays
            for (i, j) in c:
                projection.connection_manager.connect(projection.pre[i],
                                                      [projection.post[j]],
                                                      self.weights,
                                                      self.delays)
        else:
            # Mask with weights and/or delays iterable
            weights = self.weights
            if CSAConnector.isConstant(weights):
                weights = CSAConnector.constantIterator(weights)
            delays = self.delays
            if CSAConnector.isConstant(delays):
                delays = CSAConnector.constantIterator(delays)
            for (i, j), weight, delay in zip(c, weights, delays):
                projection.connection_manager.connect(projection.pre[i],
                                                      [projection.post[j]],
                                                      weight, delay)
Exemple #5
0
    def connect(self, projection):
        """Connect-up a Projection."""
        if self.delays is None:
            self.delays = projection._simulator.state.min_delay
        # Cut out finite part
        c = csa.cross(
            (0, projection.pre.size - 1),
            (0, projection.post.size -
             1)) * self.cset  # can't we cut out just the columns we want?

        if csa.arity(self.cset) == 2:
            # Connection-set with arity 2
            for (i, j, weight, delay) in c:
                projection._convergent_connect([projection.pre[i]],
                                               projection.post[j], weight,
                                               delay)
        elif CSAConnector.isConstant (self.weights) \
             and CSAConnector.isConstant (self.delays):
            # Mask with constant weights and delays
            for (i, j) in c:
                projection._convergent_connect([projection.pre[i]],
                                               projection.post[j],
                                               self.weights, self.delays)
        else:
            # Mask with weights and/or delays iterable
            weights = self.weights
            if CSAConnector.isConstant(weights):
                weights = repeat(weights)
            delays = self.delays
            if CSAConnector.isConstant(delays):
                delays = repeat(delays)
            for (i, j), weight, delay in zip(c, weights, delays):
                projection._convergent_connect([projection.pre[i]],
                                               projection.post[j], weight,
                                               delay)
Exemple #6
0
    def connect(self, projection):
        """Connect-up a Projection."""
        if self.delays is None:
            self.delays = projection._simulator.state.min_delay
        # Cut out finite part
        c = csa.cross((0, projection.pre.size-1), (0, projection.post.size-1)) * self.cset  # can't we cut out just the columns we want?

        if csa.arity(self.cset) == 2:
            # Connection-set with arity 2
            for (i, j, weight, delay) in c:
                projection._convergent_connect([projection.pre[i]], projection.post[j], weight, delay)
        elif CSAConnector.isConstant (self.weights) \
             and CSAConnector.isConstant (self.delays):
            # Mask with constant weights and delays
            for (i, j) in c:
                projection._convergent_connect([projection.pre[i]], projection.post[j], self.weights, self.delays)
        else:
            # Mask with weights and/or delays iterable
            weights = self.weights
            if CSAConnector.isConstant(weights):
                weights = repeat(weights)
            delays = self.delays
            if CSAConnector.isConstant(delays):
                delays = repeat(delays)
            for (i, j), weight, delay in zip (c, weights, delays):
                projection._convergent_connect([projection.pre[i]], projection.post[j], weight, delay)
    def _connect(self):
        '''Connect populations.'''

        finite_set = csa.cross(xrange(self._N_s), xrange(self._N_t))
        if self._fan == 'in':
            self._cs = csa.cset(csa.random(fanIn=self._C) * finite_set)
        else:
            self._cs = csa.cset(csa.random(fanOut=self._C) * finite_set)
    def _connect(self):
        '''Connect populations.'''

        sigma = self._params['sigma']
        cutoff = self._max_dist
        self._cs = csa.cset(
            csa.cross([0], xrange(self._N - 1)) *
            (csa.random * (csa.gaussian(sigma, cutoff) * self._d)), 1.0, 1.0)
    def _connect(self):
        '''Connect populations.'''

        finite_set = csa.cross(xrange(self._N_s), xrange(self._N_t))
        if self._fan == 'in':
            cs = csa.cset(csa.random(fanIn=self._C) * finite_set)
        else:
            cs = csa.cset(csa.random(fanOut=self._C) * finite_set)
        nest.CGConnect(self._source_pop, self._target_pop, csa.cset(cs))
Exemple #10
0
    def connect(self, projection):
        """Connect-up a Projection."""
        # Cut out finite part
        c = csa.cross((0, projection.pre.size - 1), (0, projection.post.size - 1)) * self.cset  # can't we cut out just the columns we want?

        if csa.arity(self.cset) == 2:
            # Connection-set with arity 2
            for (i, j, weight, delay) in c:
                projection._convergent_connect([projection.pre[i]], projection.post[j], weight, delay)
        elif csa.arity(self.cset) == 0:
            # inefficient implementation as a starting point
            connection_map = numpy.zeros((projection.pre.size, projection.post.size), dtype=bool)
            for addr in c:
                connection_map[addr] = True
            self._connect_with_map(projection, LazyArray(connection_map))
        else:
            raise NotImplementedError
    def _connect(self):
        '''Connect populations.'''

        g1 = self._geometryFunction(self._ls)
        g2 = self._geometryFunction(self._lt)
        d = csa.euclidMetric2d(g1, g2)
        sigma = self._params['sigma']
        cutoff = self._max_dist
        cs = csa.cset(
            csa.cross([0], xrange(self._N - 1)) *
            (csa.random * (csa.gaussian(sigma, cutoff) * d)), 1.0, 1.0)
        nest.CGConnect(
            nest.GetLeaves(self._ls)[0],
            nest.GetLeaves(self._lt)[0], cs, {
                'weight': 0,
                'delay': 1
            })
Exemple #12
0
    def connect(self, projection):
        """Connect-up a Projection."""
        # Cut out finite part
        c = csa.cross((0, projection.pre.size - 1), (0, projection.post.size - 1)) * self.cset  # can't we cut out just the columns we want?

        if csa.arity(self.cset) == 2:
            # Connection-set with arity 2
            for (i, j, weight, delay) in c:
                projection._convergent_connect([projection.pre[i]], projection.post[j], weight, delay)
        elif csa.arity(self.cset) == 0:
            # inefficient implementation as a starting point
            connection_map = numpy.zeros((projection.pre.size, projection.post.size), dtype=bool)
            for addr in c:
                connection_map[addr] = True
            self._connect_with_map(projection, LazyArray(connection_map))
        else:
            raise NotImplementedError
Exemple #13
0
    def _connect(self):
        '''Connect populations.'''

        finite_set = csa.cross(xrange(self._N_s), xrange(self._N_t))
        cs = csa.cset(csa.random(p=self._p) * finite_set)
        nest.CGConnect(self._source_pop, self._target_pop, csa.cset(cs))
    def _connect(self):
        '''Connect populations.'''

        finite_set = csa.cross(xrange(self._N_s), xrange(self._N_t))
        self._cs = csa.cset(csa.random(p=self._p) * finite_set)