예제 #1
0
    def enable_learning(self, period=None, offset=None):
        """
        Enables learning for all the synapses of this projection.

        *Parameters*:

        * **period** determines how often the synaptic variables will be updated.
        * **offset** determines the offset at which the synaptic variables will be updated relative to the current time.

        For example, providing the following parameters at time 10 ms::

            enable_learning(period=10., offset=5.)

        would call the updating methods at times 15, 25, 35, etc...

        The default behaviour is that the synaptic variables are updated at each time step. The parameters must be multiple of ``dt``
        """
        # Check arguments
        if period != None and offset!=None:
            if offset >= period:
                Global._error('enable_learning(): the offset must be smaller than the period.')
                exit(0)
        if period == None and offset!=None:
            Global._error('enable_learning(): if you define an offset, you have to define a period.')
            exit(0)
        try:
            self.cyInstance._set_update(True)
            self.cyInstance._set_plasticity(True)
            if period != None:
                self.cyInstance._set_update_period(int(period/Global.config['dt']))
            else:
                self.cyInstance._set_update_period(int(1))
                period = Global.config['dt']
            if offset != None:
                relative_offset = Global.get_time() % period + offset
                self.cyInstance._set_update_offset(int(relative_offset%period))
            else:
                self.cyInstance._set_update_offset(int(0))
        except:
            Global._warning('Enable_learning() is only possible after compile()')
예제 #2
0
    def enable_learning(self, period=None, offset=None):
        """
        Enables learning for all the synapses of this projection.

        *Parameters*:

        * **period**: determines how often the synaptic variables will be updated.
        * **offset**: determines the offset at which the synaptic variables will be updated relative to the current time.

        For example, providing the following parameters at time 10 ms::

            enable_learning(period=10., offset=5.)

        would call the updating methods at times 15, 25, 35, etc...

        The default behaviour is that the synaptic variables are updated at each time step. The parameters must be multiple of ``dt``
        """
        # Check arguments
        if not period is None and not offset is None:
            if offset >= period:
                Global._error('enable_learning(): the offset must be smaller than the period.')

        if period is None and not offset is None:
            Global._error('enable_learning(): if you define an offset, you have to define a period.')

        try:
            self.cyInstance._set_update(True)
            self.cyInstance._set_plasticity(True)
            if period != None:
                self.cyInstance._set_update_period(int(period/Global.config['dt']))
            else:
                self.cyInstance._set_update_period(int(1))
                period = Global.config['dt']
            if offset != None:
                relative_offset = Global.get_time() % period + offset
                self.cyInstance._set_update_offset(int(int(relative_offset%period)/Global.config['dt']))
            else:
                self.cyInstance._set_update_offset(int(0))
        except:
            Global._warning('Enable_learning() is only possible after compile()')
예제 #3
0
 def get_time(self):
     "Returns the current time in ms."
     return Global.get_time(self.id)
예제 #4
0
 def get_time(self):
     "Returns the current time in ms."
     return Global.get_time(self.id)