Sheet classes.
A Sheet is a two-dimensional arrangement of processing units, typically modeling a neural region or a subset of cells in a neural region. Any new Sheet classes added to this directory will automatically become available for any model.
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.
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.
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.
Bases: topo.sheet.JointNormalizingCFSheet
A JointNormalizingCFSheet implementing the idea of settling.
Breaks continuous time up into discrete iterations, each consisting of a series of activations, up to a fixed number of settling steps. Settling is controlled by the tsettle parameter; once that number of settling steps has been reached, an external input is required before the sheet will activate again.
See the LISSOM algorithm (Sirosh and Miikkulainen, Biological Cybernetics 71:66-78, 1994) for one example of its usage.
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.
Compute norm_total for each CF in each projection from a group to be normalized jointly.
Call the learn() method on every Projection to the Sheet, and call the output functions (jointly if necessary).
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.
Pass the accumulated stimulation through self.output_fns and send it out on the default output port.
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.
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.
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: 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: 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.)
Generate the output and send it out the Activity port.
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.
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.
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.
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.
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.generatorsheet.GeneratorSheet
Sheet that generates a timed sequence of patterns.
This sheet will repeatedly generate the input_sequence, with the given onsets. The sequence is repeated every self.period time units. If the total length of the sequence is longer than self.period, a warning is issued and the sequence repeats immediately after completion.
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.)
Generate the output and send it out the Activity port.
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.
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.
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.cf.CFSheet
A type of CFSheet extended to support joint sum-based normalization.
For L1 normalization, joint normalization means normalizing the sum of (the absolute values of) all weights in a set of corresponding CFs in different Projections, rather than only considering weights in the same CF.
This class provides a mechanism for grouping Projections (see _port_match and _grouped_in_projections) and a learn() function that computes the joint sums. Joint normalization also requires having ConnectionField store and return a norm_total for each neuron, and having an TransferFn that will respect this norm_total rather than the strict total of the ConnectionField’s weights. At present, CFPOF_DivisiveNormalizeL1 and CFPOF_DivisiveNormalizeL1_opt do use norm_total; others can be extended to do something similar if necessary.
To enable joint normalization, you can declare that all the incoming connections that should be normalized together each have a dest_port of:
dest_port=(‘Activity’,’JointNormalize’, ‘AfferentGroup1’),
Then all those that have this dest_port will be normalized together, as long as an appropriate TransferFn is being used.
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.
Compute norm_total for each CF in each projection from a group to be normalized jointly.
Call the learn() method on every Projection to the Sheet, and call the output functions (jointly if necessary).
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.
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: topo.base.sheet.Sheet
Copies incoming Activity patterns to its activity matrix and output port.
Trivial Sheet class that is useful primarily as a placeholder for data that is computed elsewhere but that you want to appear as a Sheet, e.g. when wrapping an external simulation.
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.
(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.
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.
Bases: topo.sheet.JointNormalizingCFSheet
CFSheet that runs continuously, with no ‘resting’ periods between pattern presentations.
Note that learning occurs only when the time is a whole number.
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.
Compute norm_total for each CF in each projection from a group to be normalized jointly.
Call the learn() method on every Projection to the Sheet, and call the output functions (jointly if necessary).
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.
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.
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.
Compute norm_total for each CF in each projection from a group to be normalized jointly.
Bases: holoviews.core.boundingregion.BoundingRegion
A rectangular bounding box defined either by two points forming an axis-aligned rectangle (or simply a radius for a square).
Return the coordinates of the center of this BoundingBox
Returns true if the given point is contained within the bounding box, where all boundaries of the box are considered to be inclusive.
Return True if the given point is contained within the bounding box, where the bottom and right boundaries are considered exclusive.
Returns true if the given BoundingBox x is contained within the bounding box, where at least one of the boundaries of the box has to be exclusive.
Returns true if the given BoundingBox x is contained within the bounding box, including cases of exact match.
return left,bottom,right,top values for the BoundingBox.
Returns true if the given point is contained within the bounding box, where the right and upper boundaries are exclusive, and the left and lower boundaries are inclusive. Useful for tiling a plane into non-overlapping regions.
alias of float64
A Sheet class for composing activity from different sheets into a single activity matrix. Primarily a simple example of how to make a sheet class, but can also be useful.
Bases: topo.base.sheet.Sheet
A Sheet that combines the activity of 2 or more other sheets into a single activity matrix. When connecting a sheet to a composer, you can specify the location at which that sheet’s input will be mapped into the composer by adding the ‘origin’ argument to the connect() call e.g.:
sim.connect(input_sheet.name,composer.name,delay=1, origin=(0.25,0.25))
will cause (0,0) on input sheet’s activity to map to (0.25,0.25) on composer’s activity.
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.
Configure a specific input port.
origin = (default (0,0)) The offset in the output matrix where this port’s input should be placed.
(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.
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.
Specific support for the LISSOM algorithm.
Convenience function for scheduling a default set of events typically used with a LISSOM model sheet. The parameters used are the defaults from Miikkulainen, Bednar, Choe, and Sirosh (2005), Computational Maps in the Visual Cortex, Springer.
Note that Miikulainen 2005 specifies only one output_fn for the LISSOM model sheet; where these scheduled actions operate on an output_fn, they do so only on the first output_fn in the sheet’s list of output_fns.
Installs afferent learning rate changes for any projection whose name contains the keyword specified by aff_name (typically “Afferent”).
The st argument determines the timescale relative to a 20000-iteration simulation, and results in the default 10000-iteration simulation for the default st=0.5.
The ids argument specifies the input density scale, i.e. how much input there is at each iteration, on average, relative to the default. The ars argument specifies how much to scale the afferent learning rate, if necessary.
If increase_inhibition is true, gradually increases the strength of the inhibitory connection, typically used for natural image simulations.
Inline-optimized Sheet classes
Compute norm_total for each CF in each projection from a group to be normalized jointly.
Bases: topo.sheet.JointNormalizingCFSheet
A JointNormalizingCFSheet implementing the idea of settling.
Breaks continuous time up into discrete iterations, each consisting of a series of activations, up to a fixed number of settling steps. Settling is controlled by the tsettle parameter; once that number of settling steps has been reached, an external input is required before the sheet will activate again.
See the LISSOM algorithm (Sirosh and Miikkulainen, Biological Cybernetics 71:66-78, 1994) for one example of its usage.
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.
Compute norm_total for each CF in each projection from a group to be normalized jointly.
Call the learn() method on every Projection to the Sheet, and call the output functions (jointly if necessary).
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.
Pass the accumulated stimulation through self.output_fns and send it out on the default output port.
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.
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.
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: 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.
This class finds the brightest pixel of the image, returns it in white and other in black. This class also gives instructions to move the camera.
Bases: topo.base.sheet.Sheet
Given an incoming Activity pattern, find the brightest pixel and output an activity pattern where all but this pixel is set to zero. Also controls a pan/tilt/zoom camera, instructing it to move so that the brightest pixel will be in the center of the sheet.
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.)
Determine the next location to move in the specified image, using whatever criterion is appropriate for this class. Returns a tuple of (pos,bbox), where pos is the (row,column) coordinate of the next position, and bbox is a bounding box around that coordinate, with whatever size is appropriate for this class. Returns None if no appropriate location can be found.
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.
Move the camera to centre the returned location.
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.
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.
Bases: topo.sheet.ptztracker.PtzTracker
This class is used to define the position of the brightest pixel in the image.
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.)
Draws three boxes arond the returned location.
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.
Move the camera to centre the returned location.
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.
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.
Bases: topo.sheet.ptztracker.PtzTracker
This class is used to detect face in the image and draws a rectangle around each detected face.
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.)
Draws three boxes arond the returned location.
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.
Move the camera to centre the returned location.
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.
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.
Sheets for simulating a moving eye.
This module provides two classes, ShiftingGeneratorSheet, and SaccadeController, that can be used to simulate a moving eye, controlled by topographic neural activity from structures like the superior colliculus.
ShiftingGeneratorSheet is a subclass of GeneratorSheet that accepts a saccade command on the ‘Saccade’ port in the form of a tuple: (amplitude,direction), specified in degrees. It shifts its sheet bounds in response to this command, keeping the centroid of the bounds within a prespecified boundingregion.
SaccadeController is a subclass of CFSheet that accepts CF projections and decodes its resulting activity into a saccade command suitable for controlling a ShiftingGeneratorSheet.
Bases: topo.base.cf.CFSheet
Sheet that decodes activity on CFProjections into a saccade command.
This class accepts CF-projected input and computes its activity like a normal CFSheet, then decodes that activity into a saccade amplitude and direction as would be specified by activity in the superior colliculi. The X dimension of activity corresponds to amplitude, the Y dimension to direction. The activity is decoded to a single (x,y) point according to the parameter decode_method.
From this (x,y) point an (amplitude,direction) pair, specified in degrees, is computed using the parameters amplitude_scale and direction scale. That pair is then sent out on the ‘Saccade’ output port.
NOTE: Non-linear mappings for saccade commands, as in Ottes, et al (below), are assumed to be provided using the coord_mapperg parameter of the incoming CFProjection.
References: Ottes, van Gisbergen, Egglermont. 1986. Visuomotor fields of the superior colliculus: a quantitative model. Vision Research; 26(6): 857-73.
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 the sheet coords of the (weighted) centroid of sheet activity.
If the activity argument is not None, then it is used instead of sheet.activity. If the sheet activity is all zero, the centroid of the sheet bounds is returned.
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: topo.sheet.SequenceGeneratorSheet
A GeneratorSheet that takes an extra input on port ‘Saccade’ that specifies a saccade command as a tuple (amplitude,direction), indicating the relative size and direction of the saccade in degrees. The parameter visual_angle_scale defines the relationship between degrees and sheet coordinates. The parameter saccade bounds limits the region within which the saccades may occur.
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.)
Push the current input_generator onto a stack for future retrieval.
Move the bounds toward the fixation point.
Moves the bounds toward the fixation point specified in self.fixation_point, potentially with noise as specified by the parameter self.fixation_jitter.
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.
Shift the bounding box by the given amplitude and direction.
Amplitude and direction are specified in degrees, and will be converted using the sheet’s visual_angle_scale parameter. Negative directions are always downward, regardless of whether the amplitude is positive (rightword) or negative (leftward). I.e. straight-down = -90, straight up = +90.
The generate argument indicates whether or not to generate output after shifting. If generate is None, then the value of the sheet’s generate_on_shift parameter will be used.
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.
Return the sheet coords of the (weighted) centroid of sheet activity.
If the activity argument is not None, then it is used instead of sheet.activity. If the sheet activity is all zero, the centroid of the sheet bounds is returned.
The SLISSOM class.
Bases: topo.sheet.SettlingCFSheet
A Sheet class implementing the SLISSOM algorithm (Choe and Miikkulainen, Neurocomputing 21:139-157, 1998).
A SLISSOM sheet is a SettlingCFSheet sheet extended to include spiking neurons using dynamic synapses.
For now, this is the same as the parent’s activate(), plus fixed+dynamic thresholding. Overloading was necessary to avoid self.send_output() being invoked before thresholding. This function also updates and maintains internal values such as membrane_potential, spike, etc.
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.
SLISSOM-specific input_event handeling: On a new afferent input, DO NOT clear the activity matrix unless reset_on_new_iteration is True.
Compute norm_total for each CF in each projection from a group to be normalized jointly.
Call the learn() method on every Projection to the Sheet, and call the output functions (jointly if necessary).
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.
Matrixplot membrane potential trace of the unit designated by the trace_coords list.
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.
Plot membrane potential trace of the unit designated by the trace_coords list. This plot has trace_n data points.
(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.
Pass the accumulated stimulation through self.output_fns and send it out on the default output port.
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.
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.
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.
Plot membrane potential trace of the unit designated by the trace_coords list. This plot has trace_n data points. This method simply calls plot_trace().
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.