Package topo :: Package base :: Module cf :: Class CFProjection
[hide private]
[frames] | no frames]

Class CFProjection

source code

                       object --+            
                                |            
param.parameterized.Parameterized --+        
                                    |        
              simulation.EPConnection --+    
                                        |    
                    projection.Projection --+
                                            |
                                           CFProjection
Known Subclasses:

A projection composed of ConnectionFields from a Sheet into a ProjectionSheet.

CFProjection computes its activity using a response_fn of type CFPResponseFn (typically a CF-aware version of mdot) and output_fn (which is typically IdentityOF). The initial contents of the ConnectionFields mapping from the input Sheet into the target ProjectionSheet are controlled by the weights_generator, cf_shape, and weights_output_fn parameters, while the location of the ConnectionField is controlled by the coord_mapper parameter.

Any subclass has to implement the interface activate(self,input_activity) that computes the response from the input and stores it in the activity array.

Nested Classes [hide private]

Inherited from param.parameterized.Parameterized: __metaclass__

Instance Methods [hide private]
 
__init__(self, initialize_cfs=True, **params)
Initialize the Projection with a set of cf_type objects (typically ConnectionFields), each located at the location in the source sheet corresponding to the unit in the target sheet.
source code
 
_cleanup(self) source code
 
activate(self, input_activity)
Activate using the specified response_fn and output_fn.
source code
 
apply_learn_output_fn(self, mask)
Sub-classes can implement this function if they wish to perform an operation after learning has completed, such as normalizing weight values across different projections.
source code
 
cf(self, r, c)
Return the specified ConnectionField
source code
 
change_bounds(self, nominal_bounds_template)
Change the bounding box for all of the ConnectionFields in this Projection.
source code
 
change_density(self, new_wt_density)
Rescales the weight matrix in place, interpolating or resampling as needed.
source code
 
create_mask(self, shape, bounds_template, sheet)
Create the mask (see ConnectionField.__init__()).
source code
 
get_view(self, sheet_x, sheet_y, timestamp)
Return a single connection field UnitView, for the unit located nearest to sheet coordinate (sheet_x,sheet_y).
source code
 
learn(self)
For a CFProjection, learn consists of calling the learning_fn.
source code
 
n_units(self)
Return the number of unmasked units in a typical ConnectionField.
source code

Inherited from projection.Projection: get_projection_view, override_plasticity_state, restore_plasticity_state

Inherited from simulation.EPConnection: remove, script_repr

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_dynamic_time_fn, state_pop, state_push, verbose, warning

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

Class Methods [hide private]

Inherited from param.parameterized.Parameterized: params, print_param_defaults

Class Variables [hide private]
  allow_null_cfs = param.Boolean(default= False, doc= "Whether o...
Whether or not the projection can have entirely empty CFs
  apply_output_fn_init = param.Boolean(default= True, doc= ...
Whether to apply the output function to connection fields (e.g.
  autosize_mask = param.Boolean(default= True, constant= True, p...
Topographica sets the mask size so that it is the same as the connection field's size, unless this parameter is False - in which case the user-specified size of the cf_shape is used.
  cf_shape = param.ClassSelector(PatternGenerator, default= patt...
Define the shape of the connection fields.
  cf_type = param.Parameter(default= ConnectionField, constant= ...
Type of ConnectionField to use when creating individual CFs.
  coord_mapper = param.ClassSelector(CoordinateMapperFn, default...
Function to map a projected coordinate into the target sheet.
  learning_fn = param.ClassSelector(CFPLearningFn, default= CFPL...
Function for computing changes to the weights based on one activation step.
  learning_rate = param.Number(default= 0.0, softbounds= (0, 100...
Amount of learning at each step for this projection, specified in units that are independent of the density of each Sheet.
  nominal_bounds_template = BoundingRegionParameter(default= Bou...
Bounds defining the Sheet area covered by a prototypical ConnectionField.
  precedence = param.Number(default= 0.8)
  response_fn = param.ClassSelector(CFPResponseFn, default= CFPR...
Function for computing the Projection response to an input pattern.
  same_cf_shape_for_all_cfs = param.Boolean(default= True, doc= ...
Whether or not to share a single cf_shape mask for all CFs.
  strength = param.Number(default= 1.0, doc= ...
Global multiplicative scaling applied to the Activity of this Sheet.
  weights_generator = param.ClassSelector(PatternGenerator, defa...
Generate initial weights values.
  weights_output_fn = param.ClassSelector(CFPOutputFn, default= ...
Function applied to each CF after learning.

Inherited from projection.Projection: activity_group, dest_port, output_fn, plastic, src_port

Inherited from simulation.EPConnection: delay, dest, private, src

Inherited from param.parameterized.Parameterized: name, print_level

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, initialize_cfs=True, **params)
(Constructor)

source code 

Initialize the Projection with a set of cf_type objects (typically ConnectionFields), each located at the location in the source sheet corresponding to the unit in the target sheet. The cf_type objects are stored in the 'cfs' array.

The nominal_bounds_template specified may be altered: the bounds must be fitted to the Sheet's matrix, and the weights matrix must have odd dimensions. These altered bounds are passed to the individual connection fields.

A mask for the weights matrix is constructed. The shape is specified by cf_shape; the size defaults to the size of the nominal_bounds_template.

Overrides: object.__init__

activate(self, input_activity)

source code 
Activate using the specified response_fn and output_fn.
Overrides: projection.Projection.activate

apply_learn_output_fn(self, mask)

source code 

Sub-classes can implement this function if they wish to perform an operation after learning has completed, such as normalizing weight values across different projections.

The mask argument determines which units should have their output_fn applied; units that are nonzero in the mask must have the function applied, while those that are zero may or may not have the function applied (depending on various optimizations).

Overrides: projection.Projection.apply_learn_output_fn
(inherited documentation)

change_bounds(self, nominal_bounds_template)

source code 

Change the bounding box for all of the ConnectionFields in this Projection.

Calls change_bounds() on each ConnectionField.

Currently only allows reducing the size, but should be extended to allow increasing as well.

change_density(self, new_wt_density)

source code 

Rescales the weight matrix in place, interpolating or resampling as needed.

Not yet implemented.

learn(self)

source code 
For a CFProjection, learn consists of calling the learning_fn.
Overrides: projection.Projection.learn

Class Variable Details [hide private]

allow_null_cfs

Whether or not the projection can have entirely empty CFs
Value:
param.Boolean(default= False, doc= "Whether or not the projection can have entirel\
y empty CFs")

apply_output_fn_init

Whether to apply the output function to connection fields (e.g. for normalization) when the CFs are first created.
Value:
param.Boolean(default= True, doc= """
        Whether to apply the output function to connection fields (e.g. for 
        normalization) when the CFs are first created.""")

autosize_mask

Topographica sets the mask size so that it is the same as the connection field's size, unless this parameter is False - in which case the user-specified size of the cf_shape is used. In normal usage of Topographica, this parameter should remain True.
Value:
param.Boolean(default= True, constant= True, precedence=-1, doc= """
        Topographica sets the mask size so that it is the same as the connection f\
ield's
        size, unless this parameter is False - in which case the user-specified si\
ze of
        the cf_shape is used. In normal usage of Topographica, this parameter shou\
ld
        remain True.""")

cf_shape

Define the shape of the connection fields.
Value:
param.ClassSelector(PatternGenerator, default= patterngenerator.Constant(), consta\
nt= True, doc= "Define the shape of the connection fields.")

cf_type

Type of ConnectionField to use when creating individual CFs.
Value:
param.Parameter(default= ConnectionField, constant= True, doc= "Type of Connection\
Field to use when creating individual CFs.")

coord_mapper

Function to map a projected coordinate into the target sheet.
Value:
param.ClassSelector(CoordinateMapperFn, default= IdentityMF(), doc= 'Function to m\
ap a projected coordinate into the target sheet.')

learning_fn

Function for computing changes to the weights based on one activation step.
Value:
param.ClassSelector(CFPLearningFn, default= CFPLF_Plugin(), doc= 'Function for com\
puting changes to the weights based on one activation step.')

learning_rate

Amount of learning at each step for this projection, specified in units that are independent of the density of each Sheet.
Value:
param.Number(default= 0.0, softbounds= (0, 100), doc= """
        Amount of learning at each step for this projection, specified
        in units that are independent of the density of each Sheet.""")

nominal_bounds_template

Bounds defining the Sheet area covered by a prototypical ConnectionField. The true bounds will differ depending on the density (see create_slice_template()).
Value:
BoundingRegionParameter(default= BoundingBox(radius= 0.1), doc= """
        Bounds defining the Sheet area covered by a prototypical ConnectionField.
        The true bounds will differ depending on the density (see create_slice_tem\
plate()).""")

response_fn

Function for computing the Projection response to an input pattern.
Value:
param.ClassSelector(CFPResponseFn, default= CFPRF_Plugin(), doc= 'Function for com\
puting the Projection response to an input pattern.')

same_cf_shape_for_all_cfs

Whether or not to share a single cf_shape mask for all CFs. If True, the cf_shape is evaluated only once and shared for all CFs, which saves computation time and memory. If False, the cf_shape is evaluated once for each CF, allowing each to have its own shape.
Value:
param.Boolean(default= True, doc= """
        Whether or not to share a single cf_shape mask for all CFs.
        If True, the cf_shape is evaluated only once and shared for
        all CFs, which saves computation time and memory.  If False,
        the cf_shape is evaluated once for each CF, allowing each to
        have its own shape.""")

strength

Global multiplicative scaling applied to the Activity of this Sheet.
Value:
param.Number(default= 1.0, doc= """
        Global multiplicative scaling applied to the Activity of this Sheet.""")

weights_generator

Generate initial weights values.
Value:
param.ClassSelector(PatternGenerator, default= patterngenerator.Constant(), consta\
nt= True, doc= "Generate initial weights values.")

weights_output_fn

Function applied to each CF after learning.
Value:
param.ClassSelector(CFPOutputFn, default= CFPOF_Plugin(), doc= 'Function applied t\
o each CF after learning.')