Basic files needed by all Topographica programs.
This package should be self-contained, i.e., should not refer to any other part of Topographica. For instance, no file may include an import statement like ‘from topo.package.module import’ or ‘import topo.package.module’. This policy ensures that all of the Topographica packages outside of this one are optional.
However, this package does depend on two related non-Topographica packages, i.e. param and imagen, and will not work without those being available in the Python path.
General utility functions and classes for Topographica that require numpy.
Bases: param.parameterized.Parameterized
Divide two scalars or arrays with a constant (c) offset on the denominator to allow setting the gain or to avoid divide-by-zero issues. The non-constant part of the denominator (y) is clipped to ensure that it has only positive values.
param Number c (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: param.parameterized.Parameterized
Allows multiplying with a constant offset parameter. Useful to ensure positive scaling of responses.
param Number c (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Returns a new matrix consisting of the given matrix with a border or margin of the given width filled with the given value.
Returns the coordinates of the maximum element in the given array.
Return the centroid (center of gravity) for a 2D array.
In-place, one-sided version of numpy.clip().
i.e. numpy.clip(arr,a_min=lower_bound,out=arr) if it existed.
In-place, one-sided version of numpy.clip().
i.e. numpy.clip(arr,a_max=upper_bound,out=arr) if it existed.
Divisively normalize an array to sum to 1.0
Writes the given matrix to a new file of the given name, in Octave format.
Print the given Numpy matrix in Octave format, listing the given matrix name and the object that owns it (if any).
ConnectionField and associated classes.
This module defines some basic classes of objects used to create simulations of cortical sheets that take input through connection fields that project from other cortical sheets (or laterally from themselves).
ConnectionField: Holds a single connection field within a CFProjection.
CFProjection: A set of ConnectionFields mapping from a Sheet into a ProjectionSheet.
CFSheet: A subclass of ProjectionSheet that provides an interface to the underlying ConnectionFields in any projection of type CFProjection.
Bases: object
Iterator to walk through all ConnectionFields of all neurons in the destination Sheet of the given CFProjection. Each iteration yields the tuple (cf,i) where cf is the ConnectionField at position i in the projection’s flatcfs list.
If active_units_mask is True, inactive units will be skipped. If ignore_sheet_mask is True, even units excluded by the sheet mask will be included.
Bases: topo.base.cf.CFPLearningFn
CFLearningFunction performing no learning.
param ClassSelector single_cf_fn (allow_None=False, constant=True, default=<IdentityLF IdentityLF01275>, instantiate=True, is_instance=True, pickle_default_value=True, precedence=None, readonly=False)
Return the learning rate for a single connection assuming that the total rate is to be divided evenly among all the units in the connection field.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: topo.base.cf.CFPLearningFn
CFPLearningFunction applying the specified single_cf_fn to each CF.
Return the learning rate for a single connection assuming that the total rate is to be divided evenly among all the units in the connection field.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: param.parameterized.Parameterized
Compute new CFs for a CFProjection based on input and output activity values.
Objects in this hierarchy of callable function objects compute a new set of CFs when given input and output patterns and a set of ConnectionField objects. Used for updating the weights of one CFProjection.
Objects in this class must support being called as a function with the arguments specified below.
Return the learning rate for a single connection assuming that the total rate is to be divided evenly among all the units in the connection field.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: topo.base.cf.CFPOutputFn
CFPOutputFn that leaves the CFs unchanged.
Must never be changed or subclassed, because it might never be called. (I.e., it could simply be tested for and skipped.)
param ClassSelector single_cf_fn (allow_None=False, constant=True, default=<IdentityTF IdentityTF01278>, instantiate=True, is_instance=True, pickle_default_value=True, precedence=None, readonly=False)
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: topo.base.cf.CFPOutputFn
Applies the specified single_cf_fn to each CF in the CFProjection for which the mask is nonzero.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: param.parameterized.Parameterized
Type for an object that applies some operation (typically something like normalization) to all CFs in a CFProjection for which the specified mask (typically the activity at the destination of this projection) is nonzero.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: topo.base.cf.CFPResponseFn
Generic large-scale response function based on a simple single-CF function.
Applies the single_cf_fn to each CF in turn. For the default single_cf_fn of DotProduct(), does a basic dot product of each CF with the corresponding slice of the input array. This function is likely to be slow to run, but it is easy to extend with any arbitrary single-CF response function.
The single_cf_fn must be a function f(X,W) that takes two identically shaped matrices X (the input) and W (the ConnectionField weights) and computes a scalar activation value based on those weights.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: param.parameterized.Parameterized
Map an input activity matrix into an output matrix using the CFs in a CFProjection.
Objects in this hierarchy of callable function objects compute a response matrix when given an input pattern and a set of ConnectionField objects. Typically used as part of the activation function for a neuron, computing activation for one Projection.
Objects in this class must support being called as a function with the arguments specified below, and are assumed to modify the activity matrix in place.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: topo.base.projection.Projection
A projection composed of ConnectionFields from a Sheet into a ProjectionSheet.
CFProjection computes its activity using a response_fn of type CFPResponseFn (typically a CF-aware version of mdot) and output_fns (typically none). The initial contents of the ConnectionFields mapping from the input Sheet into the target ProjectionSheet are controlled by the weights_generator, cf_shape, and weights_output_fn parameters, while the location of the ConnectionField is controlled by the coord_mapper parameter.
Any subclass has to implement the interface activate(self,input_activity) that computes the response from the input and stores it in the activity array.
param Number precedence (allow_None=False, bounds=None, constant=False, default=0.8, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
Apply the weights_output_fns to each unit.
If active_units_mask is True, inactive units will be skipped.
alias of ConnectionField
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Temporarily override plasticity of medium and long term internal state.
This function should be implemented by all subclasses so that it preserves the ability of the Projection to compute activity, i.e. to operate over a short time scale, while preventing any lasting changes to the state.
For instance, if new_plasticity_state is False, in a Projection with modifiable connection weights, the values of those weights should temporarily be made fixed and unchanging after this call. For a Projection with automatic normalization, homeostatic plasticity, or other features that depend on a history of events (rather than just the current item being processed), changes in those properties would be disabled temporarily. Setting the plasticity state to False is useful during analysis operations (e.g. map measurement) that would otherwise change the state of the underlying network.
Any process that does not have any lasting state, such as those affecting only the current activity level, should not be affected by this call.
By default, this call simply calls override_plasticity_state() on the Projection’s output_fn, and sets the ‘plastic’ parameter to False.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Returns the activity in a single projection
Remove this connection from its src’s list of out_connections and its dest’s list of in_connections.
Restore previous plasticity state of medium and long term internal state after a override_plasticity_state call.
This function should be implemented by all subclasses to remove the effect of the most recent override_plasticity_state call, e.g. to reenable plasticity of any type that was disabled.
Generate a runnable command for creating this connection.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Pop the most recently pushed activity state of the stack.
Push the current activity state onto the stack.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Return a single connection field Image, for the unit located nearest to sheet coordinate (sheet_x,sheet_y).
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: topo.base.projection.ProjectionSheet
A ProjectionSheet providing access to the ConnectionFields in its CFProjections.
CFSheet is a Sheet built from units indexed by Sheet coordinates (x,y). Each unit can have one or more ConnectionFields on another Sheet (via this sheet’s CFProjections). Thus CFSheet is a more concrete version of a ProjectionSheet; a ProjectionSheet does not require that there be units or weights of any kind. Unless you need access to the underlying ConnectionFields for visualization or analysis, CFSheet and ProjectionSheet are interchangeable.
Collect activity from each projection, combine it to calculate the activity for this sheet, and send the result out.
Subclasses may override this method to whatever it means to calculate activity in that subclass.
Return the number of items that have been saved by state_push().
Given arbitary sheet coordinates, return the sheet coordinates of the center of the closest unit.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
The sheet’s true density (i.e. the xdensity, which is equal to the ydensity for a Sheet.)
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Accept input from some sheet. Call .present_input() to compute the stimulation from that sheet.
By default, call the learn() and apply_learn_output_fns() methods on every Projection to this Sheet.
Any other type of learning can be implemented by overriding this method. Called from self.process_current_time() _after_ activity has been propagated.
Convert a floating-point location (float_row,float_col) in matrix coordinates to its corresponding location (x,y) in sheet coordinates.
Valid for scalar or array float_row and float_col.
Inverse of sheet2matrix().
Return (x,y) where x and y are the floating point coordinates of the center of the given matrix cell (row,col). If the matrix cell represents a 0.2 by 0.2 region, then the center location returned would be 0.1,0.1.
NOTE: This is NOT the strict mathematical inverse of sheet2matrixidx(), because sheet2matrixidx() discards all but the integer portion of the continuous matrix coordinate.
Valid only for scalar or array row and col.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Estimate the memory bytes taken by this Sheet and its Projections.
Typically, this number will include the activity array and any similar arrays, plus memory taken by all incoming Projections. It will not usually include memory taken by the Python dictionary or various “housekeeping” attributes, which usually contribute only a small amount to the memory requirements. Thus this value should be considered only a rough lower bound from which memory requirements and memory usage patterns can be estimated.
Subclasses should reimplement this method if they store a significant amount of data other than in the activity array and the projections.
Count the total size of all incoming projections, in number of connections.
Temporarily override plasticity state of medium and long term internal state.
This function should be implemented by all subclasses so that when new_plasticity_state=False, it preserves the ability of the ProjectionSheet to compute activity, i.e. to operate over a short time scale, while preventing any lasting changes to the state.
Any process that does not have any lasting state, such as those affecting only the current activity level, should not be affected by this call.
By default, calls override_plasticity_state() on the ProjectionSheet’s output_fns and all of its incoming Projections, and also enables the ‘plastic’ parameter for this ProjectionSheet. The old value of the plastic parameter is saved to an internal stack to be restored by restore_plasticity_state().
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Provide the given input_activity to each in_projection that has a dest_port equal to the specified port, asking each one to compute its activity.
The sheet’s own activity is not calculated until activate() is called.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Called by the simulation after all the events are processed for the current time but before time advances. Allows the event processor to send any events that must be sent before time advances to drive the simulation.
Return either a named input p, or a dictionary {projection_name, projection} of all the in_connections for this ProjectionSheet.
A minor convenience function for finding projections by name; the sheet’s list of in_connections usually provides simpler access to the Projections.
Delete the dictionary entry with key entry ‘view_name’ to save memory.
Return an array of Y-coordinates corresponding to the rows of the activity matrix of the sheet, and an array of X-coordinates corresponding to the columns.
Generate a runnable command for creating this EventProcessor.
Send some data out to all connections on the given src_port. The data is deepcopied before it is sent out, to ensure that future changes to the data are not reflected in events from the past.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Convert a point (x,y) in Sheet coordinates to continuous matrix coordinates.
Returns (float_row,float_col), where float_row corresponds to y, and float_col to x.
Valid for scalar or array x and y.
Note about Bounds For a Sheet with BoundingBox(points=((-0.5,-0.5),(0.5,0.5))) and density=3, x=-0.5 corresponds to float_col=0.0 and x=0.5 corresponds to float_col=3.0. float_col=3.0 is not inside the matrix representing this Sheet, which has the three columns (0,1,2). That is, x=-0.5 is inside the BoundingBox but x=0.5 is outside. Similarly, y=0.5 is inside (at row 0) but y=-0.5 is outside (at row 3) (it’s the other way round for y because the matrix row index increases as y decreases).
Convert a point (x,y) in sheet coordinates to the integer row and column index of the matrix cell in which that point falls, given a bounds and density. Returns (row,column).
Note that if coordinates along the right or bottom boundary are passed into this function, the returned matrix coordinate of the boundary will be just outside the matrix, because the right and bottom boundaries are exclusive.
Valid for scalar or array x and y.
Return x,y where x is a vector of sheet coordinates representing the x-center of each matrix cell, and y represents the corresponding y-center of the cell.
Return an array of x-coordinates and an array of y-coordinates corresponding to the activity matrix of the sheet.
Called by the simulation when the EventProcessor is added to the simulation.
If an EventProcessor needs to have any code run when it is added to the simulation, the code can be put into this method in the subclass.
Subclasses Sheet state_pop to also pop projection activities.
Subclasses Sheet state_push to also push projection activities.
Creates the list of UnitView objects for a particular unit in this CFSheet. (There is one UnitView for each Projection to this CFSheet).
Each UnitView is then added to the sheet_views of its source sheet. It returns the list of all UnitViews for the given unit.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
The spacing between elements in an underlying matrix representation, in the x direction.
The spacing between elements in an underlying matrix representation, in the y direction.
Bases: object
A set of weights on one input Sheet.
Each ConnectionField contributes to the activity of one unit on the output sheet, and is normally used as part of a Projection including many other ConnectionFields.
The norm_total property returns a value useful in computing a sum-based weight normalization.
By default, the value returned is simply the current sum of the connection weights. However, another value can be substituted by setting norm_total explicitly, and this cached value will then be returned instead.
This mechanism has two main purposes. First, it allows a learning function to cache the sum value for an output function to use later without computation, which can result in significant time savings. Second, the extra level of indirection allows the sum value to be manipulated before it is used, to implement operations like joint normalization across corresponding CFs in multiple Projections.
Apart from such cases, norm_total can be ignored.
Note that every person who uses a class that sets or gets norm_total must be very careful to ensure that stale values will never be accessed. A good way to do this is to make sure that the value is only set just before it will be used, and deleted as soon as it has been accessed.
WARNING: Any c-optimized code can bypass this property and access directly _has_norm_total, _norm_total
Bases: exceptions.ValueError
Error thrown when trying to create an empty CF.
Bases: topo.base.cf.CFProjection
A CFProjection with resizable weights.
param Number precedence (allow_None=False, bounds=None, constant=False, default=0.8, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
Activate using the specified response_fn and output_fn.
Apply the weights_output_fns to each unit.
If active_units_mask is True, inactive units will be skipped.
Return the specified ConnectionField
Return the bounds of the specified ConnectionField.
alias of ConnectionField
Change the bounding box for all of the ConnectionFields in this Projection.
Calls change_bounds() on each ConnectionField.
Currently only allows reducing the size, but should be extended to allow increasing as well.
Rescales the weight matrix in place, interpolating or resampling as needed.
Not yet implemented.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
For a CFProjection, learn consists of calling the learning_fn.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Temporarily override plasticity of medium and long term internal state.
This function should be implemented by all subclasses so that it preserves the ability of the Projection to compute activity, i.e. to operate over a short time scale, while preventing any lasting changes to the state.
For instance, if new_plasticity_state is False, in a Projection with modifiable connection weights, the values of those weights should temporarily be made fixed and unchanging after this call. For a Projection with automatic normalization, homeostatic plasticity, or other features that depend on a history of events (rather than just the current item being processed), changes in those properties would be disabled temporarily. Setting the plasticity state to False is useful during analysis operations (e.g. map measurement) that would otherwise change the state of the underlying network.
Any process that does not have any lasting state, such as those affecting only the current activity level, should not be affected by this call.
By default, this call simply calls override_plasticity_state() on the Projection’s output_fn, and sets the ‘plastic’ parameter to False.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Returns the activity in a single projection
Remove this connection from its src’s list of out_connections and its dest’s list of in_connections.
Restore previous plasticity state of medium and long term internal state after a override_plasticity_state call.
This function should be implemented by all subclasses to remove the effect of the most recent override_plasticity_state call, e.g. to reenable plasticity of any type that was disabled.
Generate a runnable command for creating this connection.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Pop the most recently pushed activity state of the stack.
Push the current activity state onto the stack.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Return a single connection field Image, for the unit located nearest to sheet coordinate (sheet_x,sheet_y).
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Wrapper for Numpy.vectorize to make it work properly with different Numpy versions.
Specified explicitly when creating weights matrix - required for optimized C functions.
alias of float32
EventProcessor classes.
An EventProcessor is an object that the Simulation is aware of, and can accept simulation Events. EventProcessors can also generate Events, and will presumably do some computation as well. Most EventProcessors will be in other more specific packages, such as topo.sheet; those here are the remaining uncategorized EventProcessors. Any new EventProcessors classes added to this directory will automatically become available for any model.
Bases: topo.base.simulation.EventProcessor
A simple pulse generator node.
Produces pulses (scalars) of a fixed amplitude at a fixed frequency and phase. Period and phase are in units of simulation time.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Called by the simulation before advancing the simulation time. Allows the event processor to do any computation that requires that all events for this time have been delivered. Computations performed in this method should not generate any events with a zero time delay, or else causality could be violated. (By default, does nothing.)
Generate a runnable command for creating this EventProcessor.
Send some data out to all connections on the given src_port. The data is deepcopied before it is sent out, to ensure that future changes to the data are not reflected in events from the past.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: topo.base.simulation.EventProcessor
A simple unit that outputs the running sum of input received thus far.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Generate a runnable command for creating this EventProcessor.
Send some data out to all connections on the given src_port. The data is deepcopied before it is sent out, to ensure that future changes to the data are not reflected in events from the past.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Called by the simulation when the EventProcessor is added to the simulation.
If an EventProcessor needs to have any code run when it is added to the simulation, the code can be put into this method in the subclass.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: topo.base.simulation.EventProcessor
A simple pulse-accumulator threshold node. Accumulates incoming pulses. When the accumulated value rises above threshold, it generates a pulse of a given amplitude and resets the accumulator to zero.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Called by the simulation before advancing the simulation time. Allows the event processor to do any computation that requires that all events for this time have been delivered. Computations performed in this method should not generate any events with a zero time delay, or else causality could be violated. (By default, does nothing.)
Generate a runnable command for creating this EventProcessor.
Send some data out to all connections on the given src_port. The data is deepcopied before it is sent out, to ensure that future changes to the data are not reflected in events from the past.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Called by the simulation when the EventProcessor is added to the simulation.
If an EventProcessor needs to have any code run when it is added to the simulation, the code can be put into this method in the subclass.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Basic function objects.
TransferFns: accept and modify a 2d array ResponseFns: accept two 2d arrays and return a scalar LearningFns: accept two 2d arrays and a scalar, return one of the arrays modified
Bases: param.parameterized.Parameterized
Abstract base class for functions mapping from a 2D coordinate into another one.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: topo.base.functionfamily.ResponseFn
Return the sum of the element-by-element product of two 2D arrays.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: topo.base.functionfamily.LearningFn
Basic Hebbian rule; Dayan and Abbott, 2001, equation 8.3.
Increases each weight in proportion to the product of this neuron’s activity and the input activity.
Requires some form of output_fn normalization for stability.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: topo.base.functionfamily.LearningFn
Identity function; does not modify the weights.
For speed, calling this function object is sometimes optimized away entirely. To make this feasible, it is not allowable to derive other classes from this object, modify it to have different behavior, add side effects, or anything of that nature.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: topo.base.functionfamily.CoordinateMapperFn
Return the x coordinate of the given coordinate.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: param.parameterized.Parameterized
Abstract base class for learning functions that plug into CFPLF_Plugin.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: param.parameterized.Parameterized
Abstract base class for response functions that plug into CFPRF_Plugin.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
GeneratorSheet: a sheet with a pattern generator.
Bases: topo.base.generatorsheet.GeneratorSheet
A GeneratorSheet that handles input patterns with multiple simultaneous channels.
Accepts either a single-channel or an NChannel input_generator. If the input_generator stores separate channel patterns, it is used as-is; if other (single-channel) PatternGenerators are used, the Class behaves like a normal GeneratorSheet.
When a pattern is generated, the average of the channels is sent out on the Activity port as usual for a GeneratorSheet, and channel activities are sent out on the Activity0, Activity1, ..., ActivityN-1 ports. Thus this class can be used just like GeneratorSheet, but with optional color channels available, too.
If the input_generator is NChannel, this GeneratorSheet will handle the separate channels and create the specific output ports. If the input_generator is single-channel (eg, a monochrome image) then this GeneratorSheet will behave as a normal non-NChannel GeneratorSheet.
Collect activity from each projection, combine it to calculate the activity for this sheet, and send the result out.
Subclasses will need to override this method to whatever it means to calculate activity in that subclass.
Return the number of items that have been saved by state_push().
Given arbitary sheet coordinates, return the sheet coordinates of the center of the closest unit.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
The sheet’s true density (i.e. the xdensity, which is equal to the ydensity for a Sheet.)
Works as in the superclass, but also generates NChannel output and sends it out on the Activity0, Activity1, ..., ActivityN ports.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Convert a floating-point location (float_row,float_col) in matrix coordinates to its corresponding location (x,y) in sheet coordinates.
Valid for scalar or array float_row and float_col.
Inverse of sheet2matrix().
Return (x,y) where x and y are the floating point coordinates of the center of the given matrix cell (row,col). If the matrix cell represents a 0.2 by 0.2 region, then the center location returned would be 0.1,0.1.
NOTE: This is NOT the strict mathematical inverse of sheet2matrixidx(), because sheet2matrixidx() discards all but the integer portion of the continuous matrix coordinate.
Valid only for scalar or array row and col.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return a lower bound for the memory taken by this sheet, in bytes.
Typically, this number will include the activity array and any similar arrays, plus any other significant data owned (in some sense) by this Sheet. It will not usually include memory taken by the Python dictionary or various “housekeeping” attributes, which usually contribute only a small amount to the memory requirements.
Subclasses should reimplement this method if they store a significant amount of data other than in the activity array.
Temporarily override plasticity of medium and long term internal state.
This function should be implemented by all subclasses so that it preserves the ability of the Sheet to compute activity, i.e. to operate over a short time scale, while preventing any lasting changes to the state (if new_plasticity_state=False).
Any operation that does not have any lasting state, such as those affecting only the current activity level, should not be affected by this call.
By default, simply saves a copy of the plastic flag to an internal stack (so that it can be restored by restore_plasticity_state()), and then sets plastic to new_plasticity_state.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
Discard the current input_generator, and retrieve the previous one from the stack.
Warns if no input_generator is available on the stack.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Called by the simulation before advancing the simulation time. Allows the event processor to do any computation that requires that all events for this time have been delivered. Computations performed in this method should not generate any events with a zero time delay, or else causality could be violated. (By default, does nothing.)
Push the current input_generator onto a stack for future retrieval.
Delete the dictionary entry with key entry ‘view_name’ to save memory.
Restores plasticity of medium and long term internal state after a override_plasticity_state call.
This function should be implemented by all subclasses to remove the effect of the most recent override_plasticity_state call, i.e. to restore plasticity of any type that was overridden.
Return an array of Y-coordinates corresponding to the rows of the activity matrix of the sheet, and an array of X-coordinates corresponding to the columns.
Generate a runnable command for creating this EventProcessor.
Send some data out to all connections on the given src_port. The data is deepcopied before it is sent out, to ensure that future changes to the data are not reflected in events from the past.
Set the default value of param_name.
Equivalent to setting param_name on the class.
If single-channel generators are used, the Class reverts to a simple GeneratorSheet behavior. If NChannel inputs are used, it will update the number of channels of the ChannelGeneratorSheet to match those of the input. If the number of channels doesn’t change, there’s no need to reset.
Convert a point (x,y) in Sheet coordinates to continuous matrix coordinates.
Returns (float_row,float_col), where float_row corresponds to y, and float_col to x.
Valid for scalar or array x and y.
Note about Bounds For a Sheet with BoundingBox(points=((-0.5,-0.5),(0.5,0.5))) and density=3, x=-0.5 corresponds to float_col=0.0 and x=0.5 corresponds to float_col=3.0. float_col=3.0 is not inside the matrix representing this Sheet, which has the three columns (0,1,2). That is, x=-0.5 is inside the BoundingBox but x=0.5 is outside. Similarly, y=0.5 is inside (at row 0) but y=-0.5 is outside (at row 3) (it’s the other way round for y because the matrix row index increases as y decreases).
Convert a point (x,y) in sheet coordinates to the integer row and column index of the matrix cell in which that point falls, given a bounds and density. Returns (row,column).
Note that if coordinates along the right or bottom boundary are passed into this function, the returned matrix coordinate of the boundary will be just outside the matrix, because the right and bottom boundaries are exclusive.
Valid for scalar or array x and y.
Return x,y where x is a vector of sheet coordinates representing the x-center of each matrix cell, and y represents the corresponding y-center of the cell.
Return an array of x-coordinates and an array of y-coordinates corresponding to the activity matrix of the sheet.
Pop the most recently saved state off the stack.
See state_push() for more details.
Save the current state of this sheet to an internal stack.
This method is used by operations that need to test the response of the sheet without permanently altering its state, e.g. for measuring maps or probing the current behavior non-invasively. By default, only the activity pattern of this sheet is saved, but subclasses should add saving for any additional state that they maintain, or strange bugs are likely to occur. The state can be restored using state_pop().
Note that Sheets that do learning need not save the values of all connection weights, if any, because plasticity can be turned off explicitly. Thus this method is intended only for shorter-term state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
The spacing between elements in an underlying matrix representation, in the x direction.
The spacing between elements in an underlying matrix representation, in the y direction.
Bases: topo.base.sheet.Sheet
Sheet for generating a series of 2D patterns.
Typically generates the patterns by choosing parameters from a random distribution, but can use any mechanism.
Collect activity from each projection, combine it to calculate the activity for this sheet, and send the result out.
Subclasses will need to override this method to whatever it means to calculate activity in that subclass.
Return the number of items that have been saved by state_push().
Given arbitary sheet coordinates, return the sheet coordinates of the center of the closest unit.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
The sheet’s true density (i.e. the xdensity, which is equal to the ydensity for a Sheet.)
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Convert a floating-point location (float_row,float_col) in matrix coordinates to its corresponding location (x,y) in sheet coordinates.
Valid for scalar or array float_row and float_col.
Inverse of sheet2matrix().
Return (x,y) where x and y are the floating point coordinates of the center of the given matrix cell (row,col). If the matrix cell represents a 0.2 by 0.2 region, then the center location returned would be 0.1,0.1.
NOTE: This is NOT the strict mathematical inverse of sheet2matrixidx(), because sheet2matrixidx() discards all but the integer portion of the continuous matrix coordinate.
Valid only for scalar or array row and col.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return a lower bound for the memory taken by this sheet, in bytes.
Typically, this number will include the activity array and any similar arrays, plus any other significant data owned (in some sense) by this Sheet. It will not usually include memory taken by the Python dictionary or various “housekeeping” attributes, which usually contribute only a small amount to the memory requirements.
Subclasses should reimplement this method if they store a significant amount of data other than in the activity array.
Temporarily override plasticity of medium and long term internal state.
This function should be implemented by all subclasses so that it preserves the ability of the Sheet to compute activity, i.e. to operate over a short time scale, while preventing any lasting changes to the state (if new_plasticity_state=False).
Any operation that does not have any lasting state, such as those affecting only the current activity level, should not be affected by this call.
By default, simply saves a copy of the plastic flag to an internal stack (so that it can be restored by restore_plasticity_state()), and then sets plastic to new_plasticity_state.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
Discard the current input_generator, and retrieve the previous one from the stack.
Warns if no input_generator is available on the stack.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Called by the simulation before advancing the simulation time. Allows the event processor to do any computation that requires that all events for this time have been delivered. Computations performed in this method should not generate any events with a zero time delay, or else causality could be violated. (By default, does nothing.)
Delete the dictionary entry with key entry ‘view_name’ to save memory.
Restores plasticity of medium and long term internal state after a override_plasticity_state call.
This function should be implemented by all subclasses to remove the effect of the most recent override_plasticity_state call, i.e. to restore plasticity of any type that was overridden.
Return an array of Y-coordinates corresponding to the rows of the activity matrix of the sheet, and an array of X-coordinates corresponding to the columns.
Generate a runnable command for creating this EventProcessor.
Send some data out to all connections on the given src_port. The data is deepcopied before it is sent out, to ensure that future changes to the data are not reflected in events from the past.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Set the input_generator, overwriting the existing one by default.
If push_existing is false, the existing input_generator is discarded permanently. Otherwise, the existing one is put onto a stack, and can later be restored by calling pop_input_generator.
Convert a point (x,y) in Sheet coordinates to continuous matrix coordinates.
Returns (float_row,float_col), where float_row corresponds to y, and float_col to x.
Valid for scalar or array x and y.
Note about Bounds For a Sheet with BoundingBox(points=((-0.5,-0.5),(0.5,0.5))) and density=3, x=-0.5 corresponds to float_col=0.0 and x=0.5 corresponds to float_col=3.0. float_col=3.0 is not inside the matrix representing this Sheet, which has the three columns (0,1,2). That is, x=-0.5 is inside the BoundingBox but x=0.5 is outside. Similarly, y=0.5 is inside (at row 0) but y=-0.5 is outside (at row 3) (it’s the other way round for y because the matrix row index increases as y decreases).
Convert a point (x,y) in sheet coordinates to the integer row and column index of the matrix cell in which that point falls, given a bounds and density. Returns (row,column).
Note that if coordinates along the right or bottom boundary are passed into this function, the returned matrix coordinate of the boundary will be just outside the matrix, because the right and bottom boundaries are exclusive.
Valid for scalar or array x and y.
Return x,y where x is a vector of sheet coordinates representing the x-center of each matrix cell, and y represents the corresponding y-center of the cell.
Return an array of x-coordinates and an array of y-coordinates corresponding to the activity matrix of the sheet.
Pop the most recently saved state off the stack.
See state_push() for more details.
Save the current state of this sheet to an internal stack.
This method is used by operations that need to test the response of the sheet without permanently altering its state, e.g. for measuring maps or probing the current behavior non-invasively. By default, only the activity pattern of this sheet is saved, but subclasses should add saving for any additional state that they maintain, or strange bugs are likely to occur. The state can be restored using state_pop().
Note that Sheets that do learning need not save the values of all connection weights, if any, because plasticity can be turned off explicitly. Thus this method is intended only for shorter-term state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
The spacing between elements in an underlying matrix representation, in the x direction.
The spacing between elements in an underlying matrix representation, in the y direction.
Projection and related classes.
Bases: topo.base.projection.CompositeSheetMask
A composite SheetMask that computes its value as the logical AND (i.e. intersection) of its sub-masks.
param List submasks (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
Ensure that whenever somebody accesses the data they are not None.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: topo.base.projection.SheetMask
A SheetMask that computes its value from other SheetMasks.
param List submasks (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
Ensure that whenever somebody accesses the data they are not None.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: topo.base.projection.SheetMask
A SheetMask where the mask includes a neighborhood around active neurons.
Given a radius and a threshold, considers a neuron active if at least one neuron in the radius is over the threshold.
Ensure that whenever somebody accesses the data they are not None.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Initialize mask to default value (with no neurons masked out).
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Update the current mask based on the current activity and a previous mask.
Should be called only if calculate() has already been called since the last reset(); potentially faster to compute than redoing the entire calculate().
Subclasses should override this method to compute some non-default mask.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: topo.base.projection.CompositeSheetMask
A composite SheetMask that computes its value as the logical OR (i.e. union) of its sub-masks.
param List submasks (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
Ensure that whenever somebody accesses the data they are not None.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: topo.base.simulation.EPConnection
A projection from a Sheet into a ProjectionSheet.
Projections are required to support the activate() method, which will construct a matrix the same size as the target ProjectionSheet, from an input matrix of activity from the source Sheet. Other than that, a Projection may be of any type.
param Number strength (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
param Number precedence (allow_None=False, bounds=None, constant=False, default=0.5, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
Compute an activity matrix for output, based on the specified input_activity.
Subclasses must override this method to whatever it means to calculate activity in that subclass.
Sub-classes can implement this function if they wish to perform an operation after learning has completed, such as normalizing weight values across different projections.
The active_units_mask argument determines whether or not to apply the output_fn to non-responding units.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
This function has to be re-implemented by sub-classes, if they wish to support learning.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Estimate the memory bytes taken by this Projection.
By default, counts only the activity array, but subclasses should implement this method to include also the bytes taken by weight arrays and any similar arrays, as a rough lower bound from which memory requirements and memory usage patterns can be estimated.
Return the size of this projection, in number of connections.
Must be implemented by subclasses, if only to declare that no connections are stored.
Temporarily override plasticity of medium and long term internal state.
This function should be implemented by all subclasses so that it preserves the ability of the Projection to compute activity, i.e. to operate over a short time scale, while preventing any lasting changes to the state.
For instance, if new_plasticity_state is False, in a Projection with modifiable connection weights, the values of those weights should temporarily be made fixed and unchanging after this call. For a Projection with automatic normalization, homeostatic plasticity, or other features that depend on a history of events (rather than just the current item being processed), changes in those properties would be disabled temporarily. Setting the plasticity state to False is useful during analysis operations (e.g. map measurement) that would otherwise change the state of the underlying network.
Any process that does not have any lasting state, such as those affecting only the current activity level, should not be affected by this call.
By default, this call simply calls override_plasticity_state() on the Projection’s output_fn, and sets the ‘plastic’ parameter to False.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Remove this connection from its src’s list of out_connections and its dest’s list of in_connections.
Restore previous plasticity state of medium and long term internal state after a override_plasticity_state call.
This function should be implemented by all subclasses to remove the effect of the most recent override_plasticity_state call, e.g. to reenable plasticity of any type that was disabled.
Generate a runnable command for creating this connection.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: topo.base.sheet.Sheet
A Sheet whose activity is computed using Projections from other sheets.
A standard ProjectionSheet expects its input to be generated from other Sheets. Upon receiving an input event, the ProjectionSheet interprets the event data to be (a copy of) an activity matrix from another sheet. The ProjectionSheet provides a copy of this matrix to each Projection from that input Sheet, asking each one to compute their own activity in response. The same occurs for any other pending input events.
After all events have been processed for a given time, the ProjectionSheet computes its own activity matrix using its activate() method, which by default sums all its Projections’ activity matrices and passes the result through user-specified output_fns() before sending it out on the default output port. The activate() method can be overridden to sum some of the projections, multiply that by the sum of other projections, etc., to model modulatory or other more complicated types of connections.
Collect activity from each projection, combine it to calculate the activity for this sheet, and send the result out.
Subclasses may override this method to whatever it means to calculate activity in that subclass.
Return the number of items that have been saved by state_push().
Given arbitary sheet coordinates, return the sheet coordinates of the center of the closest unit.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
The sheet’s true density (i.e. the xdensity, which is equal to the ydensity for a Sheet.)
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Accept input from some sheet. Call .present_input() to compute the stimulation from that sheet.
By default, call the learn() and apply_learn_output_fns() methods on every Projection to this Sheet.
Any other type of learning can be implemented by overriding this method. Called from self.process_current_time() _after_ activity has been propagated.
Convert a floating-point location (float_row,float_col) in matrix coordinates to its corresponding location (x,y) in sheet coordinates.
Valid for scalar or array float_row and float_col.
Inverse of sheet2matrix().
Return (x,y) where x and y are the floating point coordinates of the center of the given matrix cell (row,col). If the matrix cell represents a 0.2 by 0.2 region, then the center location returned would be 0.1,0.1.
NOTE: This is NOT the strict mathematical inverse of sheet2matrixidx(), because sheet2matrixidx() discards all but the integer portion of the continuous matrix coordinate.
Valid only for scalar or array row and col.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Estimate the memory bytes taken by this Sheet and its Projections.
Typically, this number will include the activity array and any similar arrays, plus memory taken by all incoming Projections. It will not usually include memory taken by the Python dictionary or various “housekeeping” attributes, which usually contribute only a small amount to the memory requirements. Thus this value should be considered only a rough lower bound from which memory requirements and memory usage patterns can be estimated.
Subclasses should reimplement this method if they store a significant amount of data other than in the activity array and the projections.
Temporarily override plasticity state of medium and long term internal state.
This function should be implemented by all subclasses so that when new_plasticity_state=False, it preserves the ability of the ProjectionSheet to compute activity, i.e. to operate over a short time scale, while preventing any lasting changes to the state.
Any process that does not have any lasting state, such as those affecting only the current activity level, should not be affected by this call.
By default, calls override_plasticity_state() on the ProjectionSheet’s output_fns and all of its incoming Projections, and also enables the ‘plastic’ parameter for this ProjectionSheet. The old value of the plastic parameter is saved to an internal stack to be restored by restore_plasticity_state().
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Provide the given input_activity to each in_projection that has a dest_port equal to the specified port, asking each one to compute its activity.
The sheet’s own activity is not calculated until activate() is called.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Called by the simulation after all the events are processed for the current time but before time advances. Allows the event processor to send any events that must be sent before time advances to drive the simulation.
Return either a named input p, or a dictionary {projection_name, projection} of all the in_connections for this ProjectionSheet.
A minor convenience function for finding projections by name; the sheet’s list of in_connections usually provides simpler access to the Projections.
Delete the dictionary entry with key entry ‘view_name’ to save memory.
Return an array of Y-coordinates corresponding to the rows of the activity matrix of the sheet, and an array of X-coordinates corresponding to the columns.
Generate a runnable command for creating this EventProcessor.
Send some data out to all connections on the given src_port. The data is deepcopied before it is sent out, to ensure that future changes to the data are not reflected in events from the past.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Convert a point (x,y) in Sheet coordinates to continuous matrix coordinates.
Returns (float_row,float_col), where float_row corresponds to y, and float_col to x.
Valid for scalar or array x and y.
Note about Bounds For a Sheet with BoundingBox(points=((-0.5,-0.5),(0.5,0.5))) and density=3, x=-0.5 corresponds to float_col=0.0 and x=0.5 corresponds to float_col=3.0. float_col=3.0 is not inside the matrix representing this Sheet, which has the three columns (0,1,2). That is, x=-0.5 is inside the BoundingBox but x=0.5 is outside. Similarly, y=0.5 is inside (at row 0) but y=-0.5 is outside (at row 3) (it’s the other way round for y because the matrix row index increases as y decreases).
Convert a point (x,y) in sheet coordinates to the integer row and column index of the matrix cell in which that point falls, given a bounds and density. Returns (row,column).
Note that if coordinates along the right or bottom boundary are passed into this function, the returned matrix coordinate of the boundary will be just outside the matrix, because the right and bottom boundaries are exclusive.
Valid for scalar or array x and y.
Return x,y where x is a vector of sheet coordinates representing the x-center of each matrix cell, and y represents the corresponding y-center of the cell.
Return an array of x-coordinates and an array of y-coordinates corresponding to the activity matrix of the sheet.
Called by the simulation when the EventProcessor is added to the simulation.
If an EventProcessor needs to have any code run when it is added to the simulation, the code can be put into this method in the subclass.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
The spacing between elements in an underlying matrix representation, in the x direction.
The spacing between elements in an underlying matrix representation, in the y direction.
Bases: param.parameterized.Parameterized
An abstract class that defines a mask over a ProjectionSheet object.
This class is typically used for optimization, where mask indicates which neurons are active and should be processed further. A mask can also be used for lesion experiments, to specify which units should be kept inactive.
See the code for CFProjection and CFResponseFn to see how this class can be used to restrict the computation to only those neurons that the Mask lists as active.
Calculate a new mask based on the activity of the sheet.
For instance, in an algorithm like LISSOM that is based on a process of feedforward activation followed by lateral settling, the calculation is done at the beginning of each iteration after the feedforward activity has been calculated.
Subclasses should override this method to compute some non-default mask.
Ensure that whenever somebody accesses the data they are not None.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Update the current mask based on the current activity and a previous mask.
Should be called only if calculate() has already been called since the last reset(); potentially faster to compute than redoing the entire calculate().
Subclasses should override this method to compute some non-default mask.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Neural sheet objects and associated functions.
The Sheet class is the base class for EventProcessors that simulate topographically mapped sheets of units (neurons or columns). A Sheet is an EventProcessor that maintains a rectangular array of activity values, and sends the contents of this array as the data element in events.
The Sheet itself is a SheetCoordinateSystem, so that units may be accessed by sheet or matrix coordinates. In general, however, sheets should be thought of as having arbitrary density and sheet coordinates should be used wherever possible, except when the code needs direct access to a specific unit. By adhering to this convention, one should be able to write and debug a simulation at a low density, and then scale it up to run at higher densities (or down for lower densities) simply by changing e.g. Sheet.nominal_density.
Bases: topo.base.simulation.EventProcessor, holoviews.core.sheetcoords.SheetCoordinateSystem
The generic base class for neural sheets.
See SheetCoordinateSystem for how Sheet represents space, and EventProcessor for how Sheet handles time.
output_fns are functions that take an activity matrix and produce an identically shaped output matrix. The default is having no output_fns.
Collect activity from each projection, combine it to calculate the activity for this sheet, and send the result out.
Subclasses will need to override this method to whatever it means to calculate activity in that subclass.
Given arbitary sheet coordinates, return the sheet coordinates of the center of the closest unit.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
The sheet’s true density (i.e. the xdensity, which is equal to the ydensity for a Sheet.)
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Called by the simulation when an EPConnectionEvent is delivered; the EventProcessor should process the data somehow.
Convert a floating-point location (float_row,float_col) in matrix coordinates to its corresponding location (x,y) in sheet coordinates.
Valid for scalar or array float_row and float_col.
Inverse of sheet2matrix().
Return (x,y) where x and y are the floating point coordinates of the center of the given matrix cell (row,col). If the matrix cell represents a 0.2 by 0.2 region, then the center location returned would be 0.1,0.1.
NOTE: This is NOT the strict mathematical inverse of sheet2matrixidx(), because sheet2matrixidx() discards all but the integer portion of the continuous matrix coordinate.
Valid only for scalar or array row and col.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return a lower bound for the memory taken by this sheet, in bytes.
Typically, this number will include the activity array and any similar arrays, plus any other significant data owned (in some sense) by this Sheet. It will not usually include memory taken by the Python dictionary or various “housekeeping” attributes, which usually contribute only a small amount to the memory requirements.
Subclasses should reimplement this method if they store a significant amount of data other than in the activity array.
Temporarily override plasticity of medium and long term internal state.
This function should be implemented by all subclasses so that it preserves the ability of the Sheet to compute activity, i.e. to operate over a short time scale, while preventing any lasting changes to the state (if new_plasticity_state=False).
Any operation that does not have any lasting state, such as those affecting only the current activity level, should not be affected by this call.
By default, simply saves a copy of the plastic flag to an internal stack (so that it can be restored by restore_plasticity_state()), and then sets plastic to new_plasticity_state.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Called by the simulation before advancing the simulation time. Allows the event processor to do any computation that requires that all events for this time have been delivered. Computations performed in this method should not generate any events with a zero time delay, or else causality could be violated. (By default, does nothing.)
Delete the dictionary entry with key entry ‘view_name’ to save memory.
Restores plasticity of medium and long term internal state after a override_plasticity_state call.
This function should be implemented by all subclasses to remove the effect of the most recent override_plasticity_state call, i.e. to restore plasticity of any type that was overridden.
Return an array of Y-coordinates corresponding to the rows of the activity matrix of the sheet, and an array of X-coordinates corresponding to the columns.
Generate a runnable command for creating this EventProcessor.
Send some data out to all connections on the given src_port. The data is deepcopied before it is sent out, to ensure that future changes to the data are not reflected in events from the past.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Convert a point (x,y) in Sheet coordinates to continuous matrix coordinates.
Returns (float_row,float_col), where float_row corresponds to y, and float_col to x.
Valid for scalar or array x and y.
Note about Bounds For a Sheet with BoundingBox(points=((-0.5,-0.5),(0.5,0.5))) and density=3, x=-0.5 corresponds to float_col=0.0 and x=0.5 corresponds to float_col=3.0. float_col=3.0 is not inside the matrix representing this Sheet, which has the three columns (0,1,2). That is, x=-0.5 is inside the BoundingBox but x=0.5 is outside. Similarly, y=0.5 is inside (at row 0) but y=-0.5 is outside (at row 3) (it’s the other way round for y because the matrix row index increases as y decreases).
Convert a point (x,y) in sheet coordinates to the integer row and column index of the matrix cell in which that point falls, given a bounds and density. Returns (row,column).
Note that if coordinates along the right or bottom boundary are passed into this function, the returned matrix coordinate of the boundary will be just outside the matrix, because the right and bottom boundaries are exclusive.
Valid for scalar or array x and y.
Return x,y where x is a vector of sheet coordinates representing the x-center of each matrix cell, and y represents the corresponding y-center of the cell.
Return an array of x-coordinates and an array of y-coordinates corresponding to the activity matrix of the sheet.
Called by the simulation when the EventProcessor is added to the simulation.
If an EventProcessor needs to have any code run when it is added to the simulation, the code can be put into this method in the subclass.
Pop the most recently saved state off the stack.
See state_push() for more details.
Save the current state of this sheet to an internal stack.
This method is used by operations that need to test the response of the sheet without permanently altering its state, e.g. for measuring maps or probing the current behavior non-invasively. By default, only the activity pattern of this sheet is saved, but subclasses should add saving for any additional state that they maintain, or strange bugs are likely to occur. The state can be restored using state_pop().
Note that Sheets that do learning need not save the values of all connection weights, if any, because plasticity can be turned off explicitly. Thus this method is intended only for shorter-term state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
The spacing between elements in an underlying matrix representation, in the x direction.
The spacing between elements in an underlying matrix representation, in the y direction.
Topographica SheetView objects and its subclasses.
For use with the Topographica plotting and data analysis mechanisms. A Sheet object has its internal data which remains hidden, but it will create views of this data depending on the Sheet defaults or the information requested. This way there can be multiple views recorded for a single sheet, and a view can be passed around independent of the originating source object.
Bases: param.parameterized.Parameterized
Class provided for backward compatibility with earlier SheetView component.
param Number precedence (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
param Number row_precedence (allow_None=False, bounds=None, constant=False, default=0.5, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
param String src_name (allow_None=True, basestring=<type ‘basestring’>, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
param Parameter cyclic_range (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Return the requested view as a (data, bbox) tuple. Provided for backward compatibility with the original Topographica SheetView model. It is now easier to access the data and bounds attributes directly.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Function for backward compatibility with earlier UnitView component. Original docstring for UnitView:
Consists of an X,Y position for the unit that this View is created for. Returns an appropriately defined SheetView.
UnitViews should be stored in Sheets via a tuple (‘Weights’,Sheet,Projection,X,Y). The dictionary in Sheets can be accessed by any valid key.
A general-purpose Simulation class for discrete events.
The Simulation object is the central object of a simulation. It handles the simulation clock time and maintains communication between the components of the simulation.
A simulation is structured as a directed graph of event-processing nodes called EventProcessors (EPs). EventProcessors generate data-carrying Events, which are routed through the graph to other EventProcessors via delayed connections. Most objects in the simulation will be a subclass of EventProcessor, customized to provide some specific behavior.
There are different subclasses of Event, each doing different types of computation, and each can contain any arbitrary Python data. A simulation begins by giving each EventProcessor an opportunity to send any initial events. It then proceeds by processing and delivering events to EventProcessors in time order. After all events for the current time are processed, the simulation gives each EventProcessor a chance to do any final computation, after which simulation time skips to the time of the earliest event remaining in the queue.
PORTS
All connections between EPs are tagged with a source port and a destination port. Ports are internal addresses that EPs can use to distinguish between inputs and outputs. A port specifier can be any hashable Python object. If not specified, the input and output ports for a connection default to None.
src_ports distinguish different types of output that an EP may produce. When sending output, the EP must call self.send_output() separately for each port. dest_ports distinguish different types of input an EP may receive and process. The EP is free to interpret the input port designation on an incoming event in any way it chooses.
An example dest_port might be for an EP that receives ‘ordinary’ neural activity on the default port, and receives a separate modulatory signal that influences learning. The originator of the modulatory signal might have a connection to the EP with dest_port = ‘Modulation’. Multiple ports can be grouped by a dest EP by assuming a convention that the keys are tuples, e.g. (‘JointNormalize’,’Group1’), (‘JointNormalize’,’Group2’).
An example src_port use might be an EP that sends different events to itself than it sends out to other EPs. In this case the self connections might have src_port = ‘Recurrent’, and probably also a special dest_port.
Bases: topo.base.simulation.Event
An Event consisting of a command string to execute.
Bases: param.parameterized.Parameterized
EPConnection stores basic information for a connection between two EventProcessors.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Remove this connection from its src’s list of out_connections and its dest’s list of in_connections.
Generate a runnable command for creating this connection.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: topo.base.simulation.Event
An Event for delivery to an EPConnection.
Provides access to a data field, which can be used for anything the src wants to provide, and a link to the connection over which it has arrived, so that the dest can determine what to do with the data.
By default, the data is deepcopied before being added to this instance for safety (e.g. so that future changes to data structures do not affect messages arriving from the past). However, if you can ensure that the copying is not necessary (e.g. if you deepcoy before sending a set of identical messages), then you can pass deep_copy=False to avoid the copy.
Bases: object
Hierarchy of classes for storing simulation events of various types.
Bases: param.parameterized.Parameterized
Base class for EventProcessors, i.e. objects that can accept and handle events. This base class handles the basic mechanics of connections and sending events, and stores both incoming and outgoing connections.
The dest_ports attribute specifies which dest_ports are supported by this class; subclasses can augment or change this list if they wish. The special value dest_ports=None means to accept connections to any dest_port, while dest_ports=[None,’Trigger’] means that only connections to port None or port ‘Trigger’ are accepted.
Similarly, the src_ports attribute specifies which src_ports will be given output by this class.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Called by the simulation when an EPConnectionEvent is delivered; the EventProcessor should process the data somehow.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Called by the simulation before advancing the simulation time. Allows the event processor to do any computation that requires that all events for this time have been delivered. Computations performed in this method should not generate any events with a zero time delay, or else causality could be violated. (By default, does nothing.)
Generate a runnable command for creating this EventProcessor.
Send some data out to all connections on the given src_port. The data is deepcopied before it is sent out, to ensure that future changes to the data are not reflected in events from the past.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Called by the simulation when the EventProcessor is added to the simulation.
If an EventProcessor needs to have any code run when it is added to the simulation, the code can be put into this method in the subclass.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Parameter whose value can be any EventProcessor instance.
Bases: topo.base.simulation.Event
Event that contains a sequence of other events to be scheduled and executed.
The .time attributes of the events in the sequence are interpreted as offsets relative to the start time of the sequence itself.
Bases: topo.base.simulation.Event
Event that executes a given function function(*args,**kw).
Bases: topo.base.simulation.EventSequence
An EventSequence that reschedules itself periodically
Takes a period argument that determines how often the sequence will be scheduled. If the length of the sequence is longer than the period, then the length of the sequence will be used as the period.
Bases: topo.base.simulation.Simulation
A (quasi) real-time simulation object.
This subclass of Simulation attempts to maintain a correspondence between simulation time and real time, as defined by the timescale parameter. Real time simulation instances still maintain a nominal, discrete simulation time that determines the order of event delivery.
At the beginning of each simulation time epoch, the simulation marks the actual wall clock time. After event delivery for that epoch has ended, the simulation calculates the amount of computation time used for event processing, and executes a real sleep for the remainder of the epoch. If the computation time for the epoch exceeded the real time, a warning is issued and processing proceeds immediately to the next simulation time epoch.
RUN HOOKS
The simulation includes as parameters two lists of functions/callables, run_start_hooks and run_stop_hooks, that will be called immediately before and after event processing during a call to .run(). This allows, for example, starting and stopping of real-time devices that might use resources while the simulation is not running.
Return a string suitable for labeling an object created by the current simulation at the current time. By default this is simply the name of the simulation + ” ” + the result from evaluating the time_printing_format parameter.
Connect the src EventProcessor to the dest EventProcessor.
The src and dest should be string names of existing EPs. Returns the connection that was created. If the connection hasn’t been given a name, it defaults to ‘srcTodest’.
Return a list of all unique connections to or from any object.
Convert the supplied time to the Simulation’s time_type.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Enqueue an Event at an absolute simulation clock time.
Clear out all scheduled events of the specified type.
For instance, with event_type=EPConnectionEvent, this function can be used to ensure that no pending EPConnectionEvents will remain on the queue during some analysis or measurement operation. One will usually want to do a state_push before using this function, then clear out the events that should be deleted, do the measurement or analysis, and then do state_pop to restore the original state.
Pop the most recently saved events queue off the stack.
Same as state_pop(), but does not restore EventProcessors’ state.
Save a copy of the events queue for later restoration.
Same as state_push(), but does not ask EventProcessors to save their state.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Set the layout_location of simulation objects in a grid pattern.
Takes a list of lists of simulation objects, or names of simulation objects, and positions them with layout_locations left-to-right, top-to-bottom, starting at (xstart,ystart) and advancing by xstep and ystep.
The object None can be placed in the grid to skip a grid space.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return a dictionary of simulation objects having the specified base class. All simulation objects have a base class of EventProcessor, and so the baseclass must be either EventProcessor or one of its subclasses.
If there is a simulator called s, you can type e.g. s.objects().keys() to see a list of the names of all objects.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Add a command to execute in __main__.__dict__ at the specified time.
The command should be a string and times may be either a single time value or a list of times.
Return a nearly runnable script recreating this simulation.
Needs some work to make the result truly runnable.
Only scheduled commands that have not yet been executed are included, because executed commands are not kept around.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Sleep for the number of real milliseconds seconds corresponding to the given delay, subtracting off the amount of time elapsed since the last sleep.
Pop the most recently saved state off the stack.
See state_push() for more details.
Save a copy of the current state of the simulation for later restoration.
The saved copy includes all the events on the simulator stack (saved using event_push()). Each EventProcessor is also asked to save its own state. This operation is useful for testing something while being able to roll back to the original state.
Returns the specified time (or the current time, if none specified) formatted using time.time_printing_format, which allows users to control how much precision, etc. is used for time displays.
A property that simply returns self.timestr(); useful for setting the interactive command-line prompt.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: param.parameterized.Parameterized, topo.base.simulation.OptionalSingleton
A simulation class that uses a simple sorted event list (instead of e.g. a sched.scheduler object) to manage events and dispatching.
Simulation is a singleton: there is only one instance of Simulation, no matter how many times it is instantiated.
Return a string suitable for labeling an object created by the current simulation at the current time. By default this is simply the name of the simulation + ” ” + the result from evaluating the time_printing_format parameter.
Connect the src EventProcessor to the dest EventProcessor.
The src and dest should be string names of existing EPs. Returns the connection that was created. If the connection hasn’t been given a name, it defaults to ‘srcTodest’.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Clear out all scheduled events of the specified type.
For instance, with event_type=EPConnectionEvent, this function can be used to ensure that no pending EPConnectionEvents will remain on the queue during some analysis or measurement operation. One will usually want to do a state_push before using this function, then clear out the events that should be deleted, do the measurement or analysis, and then do state_pop to restore the original state.
Pop the most recently saved events queue off the stack.
Same as state_pop(), but does not restore EventProcessors’ state.
Save a copy of the events queue for later restoration.
Same as state_push(), but does not ask EventProcessors to save their state.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Set the layout_location of simulation objects in a grid pattern.
Takes a list of lists of simulation objects, or names of simulation objects, and positions them with layout_locations left-to-right, top-to-bottom, starting at (xstart,ystart) and advancing by xstep and ystep.
The object None can be placed in the grid to skip a grid space.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return a dictionary of simulation objects having the specified base class. All simulation objects have a base class of EventProcessor, and so the baseclass must be either EventProcessor or one of its subclasses.
If there is a simulator called s, you can type e.g. s.objects().keys() to see a list of the names of all objects.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
Process simulation events for the specified duration or until the specified time.
Arguments:
duration = length of simulation time to run. Default: run indefinitely while there are still events in the event_queue.
until = maximum simulation time to simulate. Default: run indefinitely while there are still events in the event queue.
If both duration and until are used, the one that is reached first will apply.
Note that duration and until should be specified in a format suitable for conversion (coercion?) into the Simulation’s _time_type.
Add a command to execute in __main__.__dict__ at the specified time.
The command should be a string and times may be either a single time value or a list of times.
Return a nearly runnable script recreating this simulation.
Needs some work to make the result truly runnable.
Only scheduled commands that have not yet been executed are included, because executed commands are not kept around.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Advance the simulator time by the specified amount. By default simply increments the _time value, but subclasses can override this method as they wish, e.g. to wait for an external real time clock to advance first.
Pop the most recently saved state off the stack.
See state_push() for more details.
Save a copy of the current state of the simulation for later restoration.
The saved copy includes all the events on the simulator stack (saved using event_push()). Each EventProcessor is also asked to save its own state. This operation is useful for testing something while being able to roll back to the original state.
Returns the specified time (or the current time, if none specified) formatted using time.time_printing_format, which allows users to control how much precision, etc. is used for time displays.
A property that simply returns self.timestr(); useful for setting the interactive command-line prompt.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.
Bases: param.parameterized.Parameterized
Provides a countdown timer for functions that run repeatedly.
There are two distinct ways to use the timer.
The first, via call_and_time(), is for calling some function every specified number of steps for a specified duration. Currently call_and_time() is used for timing calls to simulation.run() every 1.0 steps for 100 iterations. See the Simulation class for an example of using the timer in this way.
The second, via call_fixed_num_times(), is for calling some function repeatedly a specified number of times. A case to use call_fixed_num_times() would be timing pattern presentations, where the number of times the pattern_presenter will be called is known in advance. Additionally, this method allows a list of arguments to be passed to the function (in this case, the permutation for each call).
Call self.func(args_for_iterations[i]) for all i in args_for_iterations.
Print msg merged with args as a debugging statement.
See Python’s logging module for details of message formatting.
Return {parameter_name:parameter.default} for all non-constant Parameters.
Note that a Parameter for which instantiate==True has its default instantiated.
Return a list of name,value pairs for all Parameters of this object.
If onlychanged is True, will only return values that are not equal to the default value.
Print msg merged with args as a message.
See Python’s logging module for details of message formatting.
Return the Parameters of this class as the dictionary {name: parameter_object}
Includes Parameters from this class and its superclasses.
(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.
Print the default values of all cls’s Parameters.
Print the values of all this object’s Parameters.
time() -> floating point number
Return the current time in seconds since the Epoch. Fractions of a second may be present if the system clock provides them.
Variant of __repr__ designed for generating a runnable script.
Set the default value of param_name.
Equivalent to setting param_name on the class.
Restore the most recently saved state.
See state_push() for more details.
Save this instance’s state.
For Parameterized instances, this includes the state of dynamically generated values.
Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().
Generally, this method is used by operations that need to test something without permanently altering the objects’ state.
Print msg merged with args as a verbose message.
See Python’s logging module for details of message formatting.
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.
See Python’s logging module for details of message formatting.