Package topo :: Package base :: Module projection :: Class ProjectionSheet
[hide private]
[frames] | no frames]

Class ProjectionSheet

source code


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.

Nested Classes [hide private]

Inherited from param.parameterized.Parameterized: __metaclass__

Instance Methods [hide private]
 
__init__(self, **params)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
_dest_connect(self, conn)
See EventProcessor's _dest_connect(); raises an error if conn is not a Projection.
source code
 
_grouped_in_projections(self, ptype)
Return a dictionary of lists of incoming Projections, grouped by type.
source code
 
_port_match(self, key, portlist)
Returns True if the given key matches any port on the given list.
source code
 
activate(self)
Collect activity from each projection, combine it to calculate the activity for this sheet, and send the result out.
source code
 
input_event(self, conn, data)
Accept input from some sheet.
source code
 
learn(self)
By default, call the learn() and apply_learn_output_fns() methods on every Projection to this Sheet.
source code
 
n_bytes(self)
Estimate the memory bytes taken by this Sheet and its Projections.
source code
 
n_conns(self)
Count the total size of all incoming projections, in number of connections.
source code
 
override_plasticity_state(self, new_plasticity_state)
Temporarily override plasticity state of medium and long term internal state.
source code
 
present_input(self, input_activity, conn)
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.
source code
 
process_current_time(self)
Called by the simulation after all the events are processed for the current time but before time advances.
source code
 
projections(self, name=None)
Return either a named input p, or a dictionary {projection_name, projection} of all the in_connections for this ProjectionSheet.
source code
 
restore_plasticity_state(self)
Restores plasticity of medium and long term internal state after a override_plasticity_state call.
source code

Inherited from sheet.Sheet: activity_len, release_sheet_view, row_col_sheetcoords, sheet_cols, sheet_rows, sheetcoords_of_idx_grid, state_pop, state_push

Inherited from sheet.Sheet (private): _get_density

Inherited from simulation.EventProcessor: script_repr, send_output, start

Inherited from simulation.EventProcessor (private): _src_connect

Inherited from param.parameterized.Parameterized: __getstate__, __repr__, __setstate__, __str__, debug, defaults, force_new_dynamic_value, get_param_values, get_value_generator, inspect_value, message, print_param_values, set_default, set_dynamic_time_fn, set_param, verbose, warning

Inherited from sheetcoords.SheetCoordinateSystem: closest_cell_center, matrix2sheet, matrixidx2sheet, sheet2matrix, sheet2matrixidx, sheetcoordinates_of_matrixidx

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Class Methods [hide private]

Inherited from param.parameterized.Parameterized: params, print_param_defaults

Class Variables [hide private]
  allow_skip_non_responding_units = param.Boolean(default= True,...
If true, then units that are inactive after the response function has been called can be skipped in subsequent processing.
  dest_ports = ['Activity']
list() -> new list list(sequence) -> new list initialized from sequence's items
  mask = param.Parameter(default= SheetMask(), instantiate= True...
SheetMask object for computing which units need to be computed further.
  name = <param.parameterized.String object at 0xa9aad6c>
String identifier for this object.
  src_ports = ['Activity']
list() -> new list list(sequence) -> new list initialized from sequence's items

Inherited from sheet.Sheet: apply_output_fns, layout_location, nominal_bounds, nominal_density, output_fns, plastic, precedence, row_precedence

Inherited from param.parameterized.Parameterized: print_level

Properties [hide private]

Inherited from sheet.Sheet: density

Inherited from sheetcoords.SheetCoordinateSystem: shape, xdensity, ydensity

Inherited from object: __class__

Method Details [hide private]

__init__(self, **params)
(Constructor)

source code 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__init__
(inherited documentation)

_dest_connect(self, conn)

source code 
See EventProcessor's _dest_connect(); raises an error if conn is not a Projection. Subclasses of ProjectionSheet that know how to handle other types of Connections should override this method.
Overrides: simulation.EventProcessor._dest_connect

_grouped_in_projections(self, ptype)

source code 

Return a dictionary of lists of incoming Projections, grouped by type.

Each projection of type <ptype> is grouped according to the name of the port, into a single list within the dictionary.

The entry None will contain those that are not of type <ptype>, while the other entries will contain a list of Projections, each of which has type ptype.

Example: to obtain the lists of projections that should be jointly normalised together, call __grouped_in_projection('JointNormalize').

_port_match(self, key, portlist)

source code 

Returns True if the given key matches any port on the given list.

A port is considered a match if the port is == to the key, or if the port is a tuple whose first element is == to the key, or if both the key and the port are tuples whose first elements are ==.

This approach allows connections to be grouped using tuples.

Overrides: simulation.EventProcessor._port_match

activate(self)

source code 

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.

Overrides: sheet.Sheet.activate

input_event(self, conn, data)

source code 
Accept input from some sheet. Call .present_input() to compute the stimulation from that sheet.
Overrides: simulation.EventProcessor.input_event

learn(self)

source code 

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.

n_bytes(self)

source code 

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.

Overrides: sheet.Sheet.n_bytes

override_plasticity_state(self, new_plasticity_state)

source code 

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().

Overrides: sheet.Sheet.override_plasticity_state

present_input(self, input_activity, conn)

source code 

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.

process_current_time(self)

source code 
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.
Overrides: simulation.EventProcessor.process_current_time

projections(self, name=None)

source code 

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.

restore_plasticity_state(self)

source code 

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.

Overrides: sheet.Sheet.restore_plasticity_state
(inherited documentation)

Class Variable Details [hide private]

allow_skip_non_responding_units

If true, then units that are inactive after the response function has been called can be skipped in subsequent processing. Whether or not the units will actually be skipped depends on the implementation of learning and learning output functions.
Value:
param.Boolean(default= True, doc= """
        If true, then units that are inactive after the response
        function has been called can be skipped in subsequent
        processing. Whether or not the units will actually be skipped
        depends on the implementation of learning and learning output
        functions.""")

mask

SheetMask object for computing which units need to be computed further. The object should be an instance of SheetMask, and will compute which neurons will be considered active for the purposes of further processing. The default mask effectively disables all masking, but subclasses can use this mask to implement optimizations, non-rectangular Sheet shapes, lesions, etc.
Value:
param.Parameter(default= SheetMask(), instantiate= True, doc= """
        SheetMask object for computing which units need to be computed further.
        The object should be an instance of SheetMask, and will
        compute which neurons will be considered active for the
        purposes of further processing.  The default mask effectively
        disables all masking, but subclasses can use this mask to
        implement optimizations, non-rectangular Sheet shapes,
        lesions, etc.""")