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

Class ConnectionField

source code

                       object --+    
                                |    
param.parameterized.Parameterized --+
                                    |
                                   ConnectionField
Known Subclasses:

A set of weights on one input Sheet.

Each ConnectionField contributes to the activity of one unit on the output sheet, and is normally used as part of a Projection including many other ConnectionFields.

Nested Classes [hide private]

Inherited from param.parameterized.Parameterized: __metaclass__

Instance Methods [hide private]
 
__del_norm_total(self)
Delete any cached norm_total that may have been set.
source code
 
__get_norm_total(self)
Return the stored norm_value, if any, or else the current sum of the weights.
source code
 
__init__(self, input_sheet, template=BoundingBox(radius=0.1), weights_generator=Constant(bounds=BoundingBox(radius=0.5), mask=None, mask_shape..., mask=None, output_fn=IdentityOF(name='IdentityOF00014', norm_value=None, print_leve..., **params)
Create weights at the specified (x,y) location on the specified input_sheet.
source code
 
__set_norm_total(self, new_norm_total)
Set an explicit value to be returned by norm_total.
source code
 
_create_input_sheet_slice(self, template)
Create the input_sheet_slice, which provides the appropriate Slice for this CF on the input_sheet (as well as providing this CF's exact bounds).
source code
 
change_bounds(self, template, mask, output_fn=IdentityOF(name='IdentityOF00015', norm_value=None, print_leve...)
Change the bounding box for this ConnectionField.
source code
 
change_density(self, new_wt_density)
Rescale the weight matrix in place, interpolating or decimating as necessary.
source code
 
get_bounds(self) source code
 
get_input_matrix(self, activity) source code

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, script_repr, 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]
  _has_norm_total = False
bool(x) -> bool
  min_matrix_radius = param.Integer(default= 1, bounds= (0, None...
Enforced minimum for radius of weights matrix.
  x = param.Number(default= 0.0, softbounds= (-1.0, 1.0), consta...
The x coordinate of the location of the center of this ConnectionField on the input Sheet, e.g.
  y = param.Number(default= 0.0, softbounds= (-1.0, 1.0), consta...
The y coordinate of the location of the center of this ConnectionField on the input Sheet, e.g.

Inherited from param.parameterized.Parameterized: name, print_level

Properties [hide private]
  bounds
  input_sheet_slice
  mask
  norm_total
The norm_total property returns a value useful in computing a sum-based weight normalization.
  weights

Inherited from object: __class__

Method Details [hide private]

__del_norm_total(self)

source code 
Delete any cached norm_total that may have been set. See the norm_total property for more details.

__get_norm_total(self)

source code 
Return the stored norm_value, if any, or else the current sum of the weights. See the norm_total property for more details.

__init__(self, input_sheet, template=BoundingBox(radius=0.1), weights_generator=Constant(bounds=BoundingBox(radius=0.5), mask=None, mask_shape..., mask=None, output_fn=IdentityOF(name='IdentityOF00014', norm_value=None, print_leve..., **params)
(Constructor)

source code 

Create weights at the specified (x,y) location on the specified input_sheet.

The supplied template (if a BoundingRegion) is converted to a Slice, moved to the specified (x,y) location, and then the weights pattern is drawn inside by the weights_generator.

Note that if the appropriate template Slice is already known, then it can be passed in instead of a BoundingRegion template. This slice will then be used directly, instead of converting the template into a Slice.

The supplied template object itself will not be modified (it is copied before use).

The mask allows the weights to be limited to being non-zero in a subset of the rectangular weights area. The actual mask used is a view of the given mask created by cropping to the boundaries of the input_sheet, so that the weights all correspond to actual locations in the input sheet. For instance, if a circular pattern of weights is desired, the mask should have a disk-shaped pattern of elements with value 1, surrounded by elements with the value 0. If the CF extends over the edge of the input sheet then the weights will actually be half-moon (or similar) rather than circular.

Overrides: object.__init__

__set_norm_total(self, new_norm_total)

source code 
Set an explicit value to be returned by norm_total. See the norm_total property for more details.

_create_input_sheet_slice(self, template)

source code 

Create the input_sheet_slice, which provides the appropriate Slice for this CF on the input_sheet (as well as providing this CF's exact bounds).

Also creates the weights_slice, which provides the Slice for this weights matrix (in case it must be cropped at an edge).

change_bounds(self, template, mask, output_fn=IdentityOF(name='IdentityOF00015', norm_value=None, print_leve...)

source code 

Change the bounding box for this ConnectionField.

Discards weights or adds new (zero) weights as necessary, preserving existing values where possible.

Currently only supports reducing the size, not increasing, but should be extended to support increasing as well.

Note that the supplied template will be modified, so if you're also using them elsewhere you should pass copies.


Class Variable Details [hide private]

_has_norm_total

bool(x) -> bool

Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.

Value:
False

min_matrix_radius

Enforced minimum for radius of weights matrix. The default of 1 gives a minimum matrix of 3x3. 0 would allow a 1x1 matrix.
Value:
param.Integer(default= 1, bounds= (0, None), doc= """
        Enforced minimum for radius of weights matrix.
        The default of 1 gives a minimum matrix of 3x3. 0 would
        allow a 1x1 matrix.""")

x

The x coordinate of the location of the center of this ConnectionField on the input Sheet, e.g. for use when determining where the weight matrix lines up with the input Sheet matrix.
Value:
param.Number(default= 0.0, softbounds= (-1.0, 1.0), constant= True, doc= """
        The x coordinate of the location of the center of this ConnectionField
        on the input Sheet, e.g. for use when determining where the weight matrix
        lines up with the input Sheet matrix.""")

y

The y coordinate of the location of the center of this ConnectionField on the input Sheet, e.g. for use when determining where the weight matrix lines up with the input Sheet matrix.
Value:
param.Number(default= 0.0, softbounds= (-1.0, 1.0), constant= True, doc= """
        The y coordinate of the location of the center of this ConnectionField
        on the input Sheet, e.g. for use when determining where the weight matrix
        lines up with the input Sheet matrix.""")

Property Details [hide private]

bounds

Get Method:
get_bounds(self)

norm_total

The norm_total property returns a value useful in computing a sum-based weight normalization.

By default, the value returned is simply the current sum of the connection weights. However, another value can be substituted by setting norm_total explicitly, and this cached value will then be returned instead.

This mechanism has two main purposes. First, it allows a learning function to cache the sum value for an output function to use later without computation, which can result in significant time savings. Second, the extra level of indirection allows the sum value to be manipulated before it is used, to implement operations like joint normalization across corresponding CFs in multiple Projections.

Apart from such cases, norm_total can be ignored.

Note that every person who uses a class that sets or gets norm_total must be very careful to ensure that stale values will never be accessed. A good way to do this is to make sure that the value is only set just before it will be used, and deleted as soon as it has been accessed.

WARNING: Any c-optimized code can bypass this property and access directly _has_norm_total, _norm_total

Get Method:
__get_norm_total(self) - Return the stored norm_value, if any, or else the current sum of the weights.
Set Method:
__set_norm_total(self, new_norm_total) - Set an explicit value to be returned by norm_total.
Delete Method:
__del_norm_total(self) - Delete any cached norm_total that may have been set.