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

Class ConnectionField

source code


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.

Instance Methods [hide private]
 
__get_norm_total(self)
Return the stored norm_value, if any, or else the current sum of the weights.
source code
 
__set_norm_total(self, new_norm_total)
Set an explicit value to be returned by norm_total.
source code
 
__del_norm_total(self)
Delete any cached norm_total that may have been set.
source code
 
get_bounds(self, input_sheet) source code
 
__init__(self, input_sheet, x=0.0, y=0.0, template=BoundingBox(radius=0.1), weights_generator=Constant(bounds=BoundingBox(radius=0.5), mask=None, mask_shape..., mask=Constant(bounds=BoundingBox(radius=0.5), mask=None, mask_shape..., output_fns=None, min_matrix_radius=1)
Create weights at the specified (x,y) location on the specified input_sheet.
source code
 
_create_input_sheet_slice(self, input_sheet, x, y, template, min_matrix_radius)
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
 
get_input_matrix(self, activity) source code

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

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

Inherited from object: __class__

Method Details [hide private]

__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.

__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.

__del_norm_total(self)

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

__init__(self, input_sheet, x=0.0, y=0.0, template=BoundingBox(radius=0.1), weights_generator=Constant(bounds=BoundingBox(radius=0.5), mask=None, mask_shape..., mask=Constant(bounds=BoundingBox(radius=0.5), mask=None, mask_shape..., output_fns=None, min_matrix_radius=1)
(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__

_create_input_sheet_slice(self, input_sheet, x, y, template, min_matrix_radius)

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


Property Details [hide private]

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.