Bases: glimpse.models.base.model.Layer
Enumerator for model layers.
Specifier for the preprocessed input.
Specifier for the result of S1 filtering.
Specifier for the result of C1 pooling.
Specifier for the result of S2 filtering.
Specifier for the result of C2 (local) pooling.
Return the unordered set of all layers.
Return type: | list of LayerSpec |
---|
Example:
>>> assert(Layer.IMAGE in Layer.AllLayers())
Lookup a LayerSpec object by ID.
Parameters: | id – Model-unique layer id_ifier. |
---|---|
Return type: | LayerSpec |
Example:
>>> lyr = Layer.FromId(Layer.IMAGE.id_)
>>> assert(lyr == Layer.IMAGE)
Lookup a LayerSpec object by name.
This method is not case sensitive.
Parameters: | name (str) – Layer name. |
---|---|
Return type: | LayerSpec |
Example:
>>> lyr = Layer.FromName(Layer.IMAGE.name)
>>> assert(lyr == Layer.IMAGE)
Determine if one layer appears later in the network than another.
Parameters: |
|
---|---|
Return type: | bool |
Examples:
>>> assert(Layer.IsSublayer(Layer.SOURCE, Layer.IMAGE))
>>> assert(not Layer.IsSublayer(Layer.IMAGE, Layer.SOURCE))
Determine the top layer in this network.
The top-most layer is defined as the layer on which no other layer depends. If multiple layers meet this criteria, then the first such layer (as returned by AllLayers()) is returned.
Return type: | LayerSpec |
---|
Example:
>>> assert(Layer.TopLayer() == Layer.IMAGE)
Specifier for the result of C1 pooling.
Specifier for the result of C2 (local) pooling.
Specifier for the preprocessed input.
Specifier for the result of S1 filtering.
Specifier for the result of S2 filtering.
Bases: glimpse.models.base.model.State
A container for the Model state.
Bases: glimpse.models.base.model.Model
Create a 2-part, HMAX-like hierarchy of S+C layers.
Compute the C1 layer activity from multi-scale S1 activity.
Parameters: | s1s (list of 3D ndarray of float) – S1 maps indexed by scale. |
---|---|
Returns: | C1 maps indexed by scale and orientation. |
Return type: | list of 3D ndarray of float |
Compute global C2 layer activity from multi-scale S2 activity.
Parameters: | s2s – S2 maps indexed by scale and prototype. |
---|---|
Type : | s2s: list of list of 2D ndarray of float |
Returns: | C2 activity for each prototype. |
Return type: | 1D ndarray of float |
Compute retinal layer activity from the input image.
Parameters: | img – Image data. |
---|---|
Type : | 2D ndarray of float |
Return type: | 2D ndarray of float |
Apply S1 processing to some existing retinal layer data.
Note
This method pools over phase, so the output has only scale and orientation bands.
Parameters: | retina (2D ndarray of float) – Result of retinal layer processing. |
---|---|
Returns: | S1 maps indexed by scale and orientation. |
Return type: | list of 3D ndarray of float |
Compute the S2 layer activity from multi-scale C1 activity.
Parameters: | c1s (list of 3D ndarray of float) – C1 maps indexed by scale and orientation. |
---|---|
Returns: | S2 maps indexed by scale, kernel width, and prototype. |
Return type: | list of list of 3D ndarray of float |
Create a model state wrapper for the given image source.
Parameters: |
|
---|---|
Return type: | state.State subclass |
If source is an array, values should lie in the range [0,1).
Add a callback to compute a value for a node.
Note: be careful of passing a lambda function for f, as this will likely cause an error if serialized.
The set of S1 kernels, which is generated if not set.
Returns: | S1 kernels indexed by orientation, and phase. |
---|---|
Return type: | 4D ndarray of float |
The set of S2 kernels.
Returns: | S2 kernels indexed by kernel size, kernel offset, and orientation. |
---|---|
Return type: | list of 4D ndarray of float |
Bases: glimpse.models.base.param.Params
Parameter container for glimpse.models.ml.
The expected shape of the S1 kernels array, including band structure.
Return type: | tuple of int |
---|
Determine if the model uses unit-norm S1 kernels.
Return type: | bool |
---|
The expected shape of a single S2 kernel.
One shape tuple is returned for each S2 kernel shape supported by the model.
Return type: | tuple of tuple of int |
---|
The set of supported S2 kernel widths (i.e., spatial extents).
Return type: | tuple of int |
---|
Determine if the model uses unit-norm S2 kernels.
Return type: | bool |
---|
Compute the smallest retinal layer that supports the given parameters.
This function discounts the effect of scaling.
Parameters: | params – Parameter settings for model. |
---|---|
Return type: | int |
Returns: | Length of smaller edge of retina. |
Compute the number of scale bands supported for a given retinal size.
This ensures that at least one S2 unit can be computed for every scale band.
Parameters: |
|
---|---|
Return type: | int |
Returns: | Number of scales. |
Normalize an array, such that each location contains equal energy.
For each X-Y location, the vector \(a\) of data (containing activation for each band) is sphered according to:
where \(\mu_a\) and \(\sigma_a\) are the mean and standard deviation of \(a\), respectively.
Caution
This function modifies the input data in-place.
Parameters: | data (3D ndarray of float) – Layer activity to modify. |
---|---|
Returns: | The data array. |
Return type: | 3D ndarray of float |
Compute the receptive field for a given S2 unit.
Parameters: |
|
---|---|
Return type: | 4-tuple of int |
Returns: | Bounding box (top, bottom, left, right) in image coordinates. |
Plot the location of an S2 unit’s receptive field on a given image.
Parameters: |
|
---|
Requires matplotlib.