topo.base Package


base Package

Basic files needed by all Topographica programs.

This package should be self-contained, i.e., should not refer to any other part of Topographica. For instance, no file may include an import statement like ‘from topo.package.module import’ or ‘import topo.package.module’. This policy ensures that all of the Topographica packages outside of this one are optional.

However, this package does depend on two related non-Topographica packages, i.e. param and imagen, and will not work without those being available in the Python path.


arrayutil Module

Inheritance diagram of topo.base.arrayutil

General utility functions and classes for Topographica that require numpy.

class topo.base.arrayutil.DivideWithConstant(**params)[source]

Bases: param.parameterized.Parameterized

Divide two scalars or arrays with a constant (c) offset on the denominator to allow setting the gain or to avoid divide-by-zero issues. The non-constant part of the denominator (y) is clipped to ensure that it has only positive values.

param Number c (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2b07aa31d890>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2b07aa31daf8>
inspect_value = <functools.partial object at 0x2b07aa31dba8>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2b07aa31db50>
set_param = <functools.partial object at 0x2b07aa31dcb0>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

topo.base.arrayutil.L2norm(v)[source]

Return the L2 norm of the vector v.

class topo.base.arrayutil.MultiplyWithConstant(**params)[source]

Bases: param.parameterized.Parameterized

Allows multiplying with a constant offset parameter. Useful to ensure positive scaling of responses.

param Number c (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2b07aa31d9f0>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2b07aa31dd08>
inspect_value = <functools.partial object at 0x2b07aa31d998>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2b07aa31df70>
set_param = <functools.partial object at 0x2b07aaead208>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

topo.base.arrayutil.add_border(matrix, width=1, value=0.0)[source]

Returns a new matrix consisting of the given matrix with a border or margin of the given width filled with the given value.

topo.base.arrayutil.arg(z)[source]

Return the complex argument (phase) of z. (z in radians.)

topo.base.arrayutil.array_argmax(arr)[source]

Returns the coordinates of the maximum element in the given array.

topo.base.arrayutil.centroid(array_2D)[source]

Return the centroid (center of gravity) for a 2D array.

topo.base.arrayutil.clip_lower(arr, lower_bound)[source]

In-place, one-sided version of numpy.clip().

i.e. numpy.clip(arr,a_min=lower_bound,out=arr) if it existed.

topo.base.arrayutil.clip_upper(arr, upper_bound)[source]

In-place, one-sided version of numpy.clip().

i.e. numpy.clip(arr,a_max=upper_bound,out=arr) if it existed.

topo.base.arrayutil.divisive_normalization(weights)[source]

Divisively normalize an array to sum to 1.0

topo.base.arrayutil.octave_output(filename, mat, name='mat', owner='')[source]

Writes the given matrix to a new file of the given name, in Octave format.

topo.base.arrayutil.octave_str(mat, name='mat', owner='')[source]

Print the given Numpy matrix in Octave format, listing the given matrix name and the object that owns it (if any).

topo.base.arrayutil.ufunc_script_repr(f, imports, prefix=None, settings=None)[source]

Return a runnable representation of the numpy ufunc f, and an import statement for its module.

topo.base.arrayutil.wrap(lower, upper, x)[source]

Circularly alias the numeric value x into the range [lower,upper).

Valid for cyclic quantities like orientations or hues.


cf Module

Inheritance diagram of topo.base.cf

ConnectionField and associated classes.

This module defines some basic classes of objects used to create simulations of cortical sheets that take input through connection fields that project from other cortical sheets (or laterally from themselves).

ConnectionField: Holds a single connection field within a CFProjection.

CFProjection: A set of ConnectionFields mapping from a Sheet into a ProjectionSheet.

CFSheet: A subclass of ProjectionSheet that provides an interface to the underlying ConnectionFields in any projection of type CFProjection.

class topo.base.cf.CFIter(cfprojection, active_units_mask=False, ignore_sheet_mask=False)[source]

Bases: object

Iterator to walk through all ConnectionFields of all neurons in the destination Sheet of the given CFProjection. Each iteration yields the tuple (cf,i) where cf is the ConnectionField at position i in the projection’s flatcfs list.

If active_units_mask is True, inactive units will be skipped. If ignore_sheet_mask is True, even units excluded by the sheet mask will be included.

get_overall_mask()[source]

Return an array indicating whether or not each unit should be processed.

class topo.base.cf.CFPLF_Identity(**params)[source]

Bases: topo.base.cf.CFPLearningFn

CFLearningFunction performing no learning.

param ClassSelector single_cf_fn (allow_None=False, constant=True, default=<IdentityLF IdentityLF01275>, instantiate=True, is_instance=True, pickle_default_value=True, precedence=None, readonly=False)

constant_sum_connection_rate(n_units, learning_rate)

Return the learning rate for a single connection assuming that the total rate is to be divided evenly among all the units in the connection field.

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2b07ab9b28e8>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2b07ab9b2af8>
inspect_value = <functools.partial object at 0x2b07ab9b29f0>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2b07ab9b2aa0>
set_param = <functools.partial object at 0x2b07ab9b2b50>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class topo.base.cf.CFPLF_Plugin(**params)[source]

Bases: topo.base.cf.CFPLearningFn

CFPLearningFunction applying the specified single_cf_fn to each CF.

param ClassSelector single_cf_fn (allow_None=False, constant=False, default=<Hebbian Hebbian01276>, instantiate=True, is_instance=True, pickle_default_value=True, precedence=None, readonly=False)
Accepts a LearningFn that will be applied to each CF individually.
constant_sum_connection_rate(n_units, learning_rate)

Return the learning rate for a single connection assuming that the total rate is to be divided evenly among all the units in the connection field.

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2b07ab9b2a48>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2b07ab9b2838>
inspect_value = <functools.partial object at 0x2b07ab9b2b50>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2b07ab9b2940>
set_param = <functools.partial object at 0x2b07ab9b2ba8>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class topo.base.cf.CFPLearningFn(**params)[source]

Bases: param.parameterized.Parameterized

Compute new CFs for a CFProjection based on input and output activity values.

Objects in this hierarchy of callable function objects compute a new set of CFs when given input and output patterns and a set of ConnectionField objects. Used for updating the weights of one CFProjection.

Objects in this class must support being called as a function with the arguments specified below.

constant_sum_connection_rate(n_units, learning_rate)[source]

Return the learning rate for a single connection assuming that the total rate is to be divided evenly among all the units in the connection field.

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2b07ab9b28e8>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2b07ab9b29f0>
inspect_value = <functools.partial object at 0x2b07ab9b2ba8>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2b07ab9b2c00>
set_param = <functools.partial object at 0x2b07ab9b27e0>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class topo.base.cf.CFPOF_Identity(**params)[source]

Bases: topo.base.cf.CFPOutputFn

CFPOutputFn that leaves the CFs unchanged.

Must never be changed or subclassed, because it might never be called. (I.e., it could simply be tested for and skipped.)

param ClassSelector single_cf_fn (allow_None=False, constant=True, default=<IdentityTF IdentityTF01278>, instantiate=True, is_instance=True, pickle_default_value=True, precedence=None, readonly=False)

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2b07ab9b2838>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2b07ab9b28e8>
inspect_value = <functools.partial object at 0x2b07ab9b27e0>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2b07ab9b2a48>
set_param = <functools.partial object at 0x2b07ab9b2b50>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class topo.base.cf.CFPOF_Plugin(**params)[source]

Bases: topo.base.cf.CFPOutputFn

Applies the specified single_cf_fn to each CF in the CFProjection for which the mask is nonzero.

param ClassSelector single_cf_fn (allow_None=False, constant=False, default=<IdentityTF IdentityTF01277>, instantiate=True, is_instance=True, pickle_default_value=True, precedence=None, readonly=False)
Accepts a TransferFn that will be applied to each CF individually.
debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2b07ab9b29f0>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2b07ab9b2890>
inspect_value = <functools.partial object at 0x2b07ab9b2ba8>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2b07ab9b2af8>
set_param = <functools.partial object at 0x2b07ab9b2998>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class topo.base.cf.CFPOutputFn(**params)[source]

Bases: param.parameterized.Parameterized

Type for an object that applies some operation (typically something like normalization) to all CFs in a CFProjection for which the specified mask (typically the activity at the destination of this projection) is nonzero.

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2b07ab9b29f0>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2b07ab9b28e8>
inspect_value = <functools.partial object at 0x2b07ab9b2940>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2b07ab9b27e0>
set_param = <functools.partial object at 0x2b07ab9b2838>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class topo.base.cf.CFPRF_Plugin(**params)[source]

Bases: topo.base.cf.CFPResponseFn

Generic large-scale response function based on a simple single-CF function.

Applies the single_cf_fn to each CF in turn. For the default single_cf_fn of DotProduct(), does a basic dot product of each CF with the corresponding slice of the input array. This function is likely to be slow to run, but it is easy to extend with any arbitrary single-CF response function.

The single_cf_fn must be a function f(X,W) that takes two identically shaped matrices X (the input) and W (the ConnectionField weights) and computes a scalar activation value based on those weights.

param ClassSelector single_cf_fn (allow_None=False, constant=False, default=<DotProduct DotProduct01274>, instantiate=True, is_instance=True, pickle_default_value=True, precedence=None, readonly=False)
Accepts a ResponseFn that will be applied to each CF individually.
debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2b07ab9b2ba8>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2b07ab9b2890>
inspect_value = <functools.partial object at 0x2b07ab9b2c00>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2b07ab9b2af8>
set_param = <functools.partial object at 0x2b07ab9b2a48>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class topo.base.cf.CFPResponseFn(**params)[source]

Bases: param.parameterized.Parameterized

Map an input activity matrix into an output matrix using the CFs in a CFProjection.

Objects in this hierarchy of callable function objects compute a response matrix when given an input pattern and a set of ConnectionField objects. Typically used as part of the activation function for a neuron, computing activation for one Projection.

Objects in this class must support being called as a function with the arguments specified below, and are assumed to modify the activity matrix in place.

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2b07ab9b27e0>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2b07ab9b2940>
inspect_value = <functools.partial object at 0x2b07ab9b2890>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2b07ab9b2838>
set_param = <functools.partial object at 0x2b07ab9b2aa0>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class topo.base.cf.CFProjection(initialize_cfs=True, **params)[source]

Bases: topo.base.projection.Projection

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_fns (typically none). 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.

param Number precedence (allow_None=False, bounds=None, constant=False, default=0.8, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)

param Boolean private (allow_None=False, bounds=(0, 1), constant=False, default=False, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Set to true if this connection is for internal use only, not to be manipulated by a user.
param Integer seed (allow_None=True, bounds=None, constant=False, default=None, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
The random seed used to determine the randomized weight initialization stream. If not None, equivalent to appending the chosen integer to the hash_format.
param Boolean apply_output_fns_init (allow_None=False, bounds=(0, 1), constant=False, default=True, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Whether to apply the output function to connection fields (e.g. for normalization) when the CFs are first created.
param Parameter dest_port (allow_None=False, constant=False, default=Activity, instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False)
Identifier that can be used to distinguish different types of incoming connections. EventProcessors that accept only a single type of incoming event will typically use a src_port of None. However, if multiple types of communication are meaningful, the EventProcessor can accept other values for dest_port. It is up to the dest EventProcessor to process the data appropriately for each port, and to define what is expected to be sent to that port.
param Number strength (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
Global multiplicative scaling applied to the Activity of this Sheet.
param Parameter src_port (allow_None=False, constant=False, default=Activity, instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False)
Identifier that can be used to distinguish different types of outgoing connections. EventProcessors that generate only a single type of outgoing event will typically use a src_port of None. However, if multiple types of communication are meaningful, the EventProcessor can accept other values for src_port. It is up to the src EventProcessor to deliver appropriate data to each port, and to declare what will be sent over that port.
param Parameter cf_type (allow_None=False, constant=True, default=<class ‘topo.base.cf.ConnectionField’>, instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
Type of ConnectionField to use when creating individual CFs.
param ClassSelector cf_shape (allow_None=False, constant=True, default=<Constant Constant01282>, instantiate=True, is_instance=True, pickle_default_value=True, precedence=None, readonly=False)
Mask pattern to define the shape of the connection fields.
param Boolean plastic (allow_None=False, bounds=(0, 1), constant=False, default=True, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Whether or not to update the internal state on each call. Allows plasticity to be turned off during analysis, and then re-enabled.
param Number delay (allow_None=False, bounds=(0, None), constant=False, default=0.05, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
Simulation time between generation of an Event by the src and delivery to the dest. Should normally be nonzero, to represent a causal with a well-defined ordering of events.
param BoundingRegionParameter nominal_bounds_template (allow_None=False, constant=False, default=BoundingBox(radius=0.1), instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
Bounds defining the Sheet area covered by a prototypical ConnectionField. The true bounds will differ depending on the density (see create_slice_template()).
param ClassSelector response_fn (allow_None=False, constant=False, default=<CFPRF_Plugin CFPRF_Plugin01279>, instantiate=True, is_instance=True, pickle_default_value=True, precedence=None, readonly=False)
Function for computing the Projection response to an input pattern.
param Boolean same_cf_shape_for_all_cfs (allow_None=False, bounds=(0, 1), constant=False, default=True, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
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.
param Parameter activity_group (allow_None=False, constant=False, default=(0.5, <ufunc ‘add’>), instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Grouping and precedence specifier for computing activity from Projections. In a ProjectionSheet, all Projections in the same activity_group will be summed, and then the results from each group will be combined in the order of the activity_group using the operator specified by the activity_operator. For instance, if there are two Projections with activity_group==(0.2,numpy.add) and two with activity_group==(0.6,numpy.divide), activity from the first two will be added together, and the result divided by the sum of the second two.
param ClassSelector coord_mapper (allow_None=False, constant=False, default=<IdentityMF IdentityMF01287>, instantiate=True, is_instance=True, pickle_default_value=True, precedence=None, readonly=False)
Function to map a projected coordinate into the target sheet.
param Number mask_threshold (allow_None=False, bounds=None, constant=True, default=0.5, inclusive_bounds=(True, True), instantiate=True, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
If a unit is above this value in the cf_shape mask, it is included; otherwise it is excluded from the mask.
param Parameter dest (allow_None=True, constant=True, default=None, instantiate=True, pickle_default_value=True, precedence=0.11, readonly=False)
The EventProcessor to which messages are delivered.
param Number learning_rate (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
Amount of learning at each step for this projection, specified in units that are independent of the density of each Sheet.
param Boolean autosize_mask (allow_None=False, bounds=(0, 1), constant=True, default=True, instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
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.
param Boolean allow_null_cfs (allow_None=False, bounds=(0, 1), constant=False, default=False, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Whether or not the projection can have entirely empty CFs
param Integer min_matrix_radius (allow_None=False, bounds=(0, None), constant=False, default=1, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
Enforced minimum for radius of weights matrix. The default of 1 gives a minimum matrix of 3x3. 0 would allow a 1x1 matrix.
param ClassSelector learning_fn (allow_None=False, constant=False, default=<CFPLF_Plugin CFPLF_Plugin01283>, instantiate=True, is_instance=True, pickle_default_value=True, precedence=None, readonly=False)
Function for computing changes to the weights based on one activation step.
param String hash_format (allow_None=False, basestring=<type ‘basestring’>, constant=False, default={name}-{src}-{dest}, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Format string to determine the hash value used to initialize random weight generation. Format keys available include {name} {src} and {dest}.
param Parameter src (allow_None=True, constant=True, default=None, instantiate=True, pickle_default_value=True, precedence=0.1, readonly=False)
The EventProcessor from which messages originate.
param ClassSelector weights_generator (allow_None=False, constant=True, default=<Constant Constant01281>, instantiate=True, is_instance=True, pickle_default_value=True, precedence=None, readonly=False)
Generate initial weights values.
param HookList weights_output_fns (allow_None=False, bounds=(0, None), constant=False, default=[CFPOF_Plugin(name=’CFPOF_Plugin01285’, single_cf_fn=IdentityTF(init_keys=[], name=’IdentityTF01286’, norm_value=None))], instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
Functions applied to each CF after learning.
param HookList input_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
Function(s) applied to the input before the projection activity is computed.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
Function(s) applied to the projection activity after it is computed.
activate(input_activity)[source]

Activate using the specified response_fn and output_fn.

apply_learn_output_fns(active_units_mask=True)[source]

Apply the weights_output_fns to each unit.

If active_units_mask is True, inactive units will be skipped.

cf(r, c)[source]

Return the specified ConnectionField

cf_bounds(r, c)[source]

Return the bounds of the specified ConnectionField.

cf_type

alias of ConnectionField

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2b07ab9b2998>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2b07ab9b2a48>
inspect_value = <functools.partial object at 0x2b07ab9b2c00>
learn()[source]

For a CFProjection, learn consists of calling the learning_fn.

message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

override_plasticity_state(new_plasticity_state)

Temporarily override plasticity of medium and long term internal state.

This function should be implemented by all subclasses so that it preserves the ability of the Projection to compute activity, i.e. to operate over a short time scale, while preventing any lasting changes to the state.

For instance, if new_plasticity_state is False, in a Projection with modifiable connection weights, the values of those weights should temporarily be made fixed and unchanging after this call. For a Projection with automatic normalization, homeostatic plasticity, or other features that depend on a history of events (rather than just the current item being processed), changes in those properties would be disabled temporarily. Setting the plasticity state to False is useful during analysis operations (e.g. map measurement) that would otherwise change the state of the underlying network.

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, this call simply calls override_plasticity_state() on the Projection’s output_fn, and sets the ‘plastic’ parameter to False.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

projection_view(timestamp=None)

Returns the activity in a single projection

remove()

Remove this connection from its src’s list of out_connections and its dest’s list of in_connections.

restore_plasticity_state()

Restore previous plasticity state 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, e.g. to reenable plasticity of any type that was disabled.

script_repr(imports=, []prefix=' ')

Generate a runnable command for creating this connection.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2b07ab9b2b50>
set_param = <functools.partial object at 0x2b07ab9b2cb0>
state_pop()

Pop the most recently pushed activity state of the stack.

state_push()

Push the current activity state onto the stack.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

view(sheet_x, sheet_y, timestamp=None, situated=False, **kwargs)[source]

Return a single connection field Image, for the unit located nearest to sheet coordinate (sheet_x,sheet_y).

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class topo.base.cf.CFSheet(**params)[source]

Bases: topo.base.projection.ProjectionSheet

A ProjectionSheet providing access to the ConnectionFields in its CFProjections.

CFSheet is a Sheet built from units indexed by Sheet coordinates (x,y). Each unit can have one or more ConnectionFields on another Sheet (via this sheet’s CFProjections). Thus CFSheet is a more concrete version of a ProjectionSheet; a ProjectionSheet does not require that there be units or weights of any kind. Unless you need access to the underlying ConnectionFields for visualization or analysis, CFSheet and ProjectionSheet are interchangeable.

param Boolean apply_output_fns (allow_None=False, bounds=(0, 1), constant=False, default=True, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Whether to apply the output_fn after computing an Activity matrix.
param Number precedence (allow_None=False, bounds=None, constant=False, default=0.5, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
Allows a sorting order for Sheets, e.g. in the GUI.
param BoundingRegionParameter nominal_bounds (allow_None=False, constant=True, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
User-specified BoundingBox of the Sheet coordinate area covered by this Sheet. The left and right bounds–if specified–will always be observed, but the top and bottom bounds may be adjusted to ensure the density in the y direction is the same as the density in the x direction. In such a case, the top and bottom bounds are adjusted so that the center y point remains the same, and each bound is as close as possible to its specified value. The actual value of this Parameter is not adjusted, but the true bounds may be found from the ‘bounds’ attribute of this object.
param Parameter mask (allow_None=False, constant=False, default=<SheetMask SheetMask00984>, instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
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.
param Number row_precedence (allow_None=False, bounds=None, constant=False, default=0.5, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
Allows grouping of Sheets before sorting precedence is applied, e.g. for two-dimensional plots in the GUI.
param Boolean plastic (allow_None=False, bounds=(0, 1), constant=False, default=True, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Setting this to False tells the Sheet not to change its permanent state (e.g. any connection weights) based on incoming events.
param Boolean measure_maps (allow_None=False, bounds=(0, 1), constant=False, default=True, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Whether to include this Sheet when measuring various maps to create SheetViews.
param Number nominal_density (allow_None=False, bounds=None, constant=True, default=10, inclusive_bounds=(True, True), instantiate=True, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
User-specified number of processing units per 1.0 distance horizontally or vertically in Sheet coordinates. The actual number may be different because of discretization; the matrix needs to tile the plane exactly, and for that to work the density might need to be adjusted. For instance, an area of 3x2 cannot have a density of 2 in each direction. The true density may be obtained from either the xdensity or ydensity attribute (since these are identical for a Sheet).
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
Output function(s) to apply (if apply_output_fns is true) to this Sheet’s activity.
param Boolean allow_skip_non_responding_units (allow_None=False, bounds=(0, 1), constant=False, default=True, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
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.
param NumericTuple layout_location (allow_None=False, constant=False, default=(-1, -1), instantiate=False, length=2, pickle_default_value=True, precedence=-1, readonly=False)
Location for this Sheet in an arbitrary pixel-based space in which Sheets can be laid out for visualization.
param Dict properties (allow_None=False, constant=False, default={}, instantiate=True, is_instance=True, pickle_default_value=True, precedence=None, readonly=False)
A dictionary of property values associated with the Sheet object. For instance, the dictionary: {‘polarity’:’ON’, ‘eye’:’Left’} could be used to indicate a left, LGN Sheet with ON-surround receptive fields.
activate()

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.

activity_len()

Return the number of items that have been saved by state_push().

closest_cell_center(x, y)

Given arbitary sheet coordinates, return the sheet coordinates of the center of the closest unit.

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

density

The sheet’s true density (i.e. the xdensity, which is equal to the ydensity for a Sheet.)

force_new_dynamic_value = <functools.partial object at 0x2b07ab9b2940>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2b07ab9b2890>
input_event(conn, data)

Accept input from some sheet. Call .present_input() to compute the stimulation from that sheet.

inspect_value = <functools.partial object at 0x2b07ab9b2a48>
learn()

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.

matrix2sheet(float_row, float_col)

Convert a floating-point location (float_row,float_col) in matrix coordinates to its corresponding location (x,y) in sheet coordinates.

Valid for scalar or array float_row and float_col.

Inverse of sheet2matrix().

matrixidx2sheet(row, col)

Return (x,y) where x and y are the floating point coordinates of the center of the given matrix cell (row,col). If the matrix cell represents a 0.2 by 0.2 region, then the center location returned would be 0.1,0.1.

NOTE: This is NOT the strict mathematical inverse of sheet2matrixidx(), because sheet2matrixidx() discards all but the integer portion of the continuous matrix coordinate.

Valid only for scalar or array row and col.

message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

n_bytes()

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.

n_conns()

Count the total size of all incoming projections, in number of connections.

override_plasticity_state(new_plasticity_state)

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

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

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

The sheet’s own activity is not calculated until activate() is called.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

process_current_time()

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.

projections(name=None)

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.

release_sheet_view(view_name)

Delete the dictionary entry with key entry ‘view_name’ to save memory.

row_col_sheetcoords()

Return an array of Y-coordinates corresponding to the rows of the activity matrix of the sheet, and an array of X-coordinates corresponding to the columns.

script_repr(imports=, []prefix=' ')

Generate a runnable command for creating this EventProcessor.

send_output(src_port=None, data=None)

Send some data out to all connections on the given src_port. The data is deepcopied before it is sent out, to ensure that future changes to the data are not reflected in events from the past.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2b07ab9b2db8>
set_param = <functools.partial object at 0x2b07ab9b2e10>
sheet2matrix(x, y)

Convert a point (x,y) in Sheet coordinates to continuous matrix coordinates.

Returns (float_row,float_col), where float_row corresponds to y, and float_col to x.

Valid for scalar or array x and y.

Note about Bounds For a Sheet with BoundingBox(points=((-0.5,-0.5),(0.5,0.5))) and density=3, x=-0.5 corresponds to float_col=0.0 and x=0.5 corresponds to float_col=3.0. float_col=3.0 is not inside the matrix representing this Sheet, which has the three columns (0,1,2). That is, x=-0.5 is inside the BoundingBox but x=0.5 is outside. Similarly, y=0.5 is inside (at row 0) but y=-0.5 is outside (at row 3) (it’s the other way round for y because the matrix row index increases as y decreases).

sheet2matrixidx(x, y)

Convert a point (x,y) in sheet coordinates to the integer row and column index of the matrix cell in which that point falls, given a bounds and density. Returns (row,column).

Note that if coordinates along the right or bottom boundary are passed into this function, the returned matrix coordinate of the boundary will be just outside the matrix, because the right and bottom boundaries are exclusive.

Valid for scalar or array x and y.

sheetcoordinates_of_matrixidx()

Return x,y where x is a vector of sheet coordinates representing the x-center of each matrix cell, and y represents the corresponding y-center of the cell.

sheetcoords_of_idx_grid()

Return an array of x-coordinates and an array of y-coordinates corresponding to the activity matrix of the sheet.

start()

Called by the simulation when the EventProcessor is added to the simulation.

If an EventProcessor needs to have any code run when it is added to the simulation, the code can be put into this method in the subclass.

state_pop()

Subclasses Sheet state_pop to also pop projection activities.

state_push()

Subclasses Sheet state_push to also push projection activities.

update_unit_view(x, y, proj_name='')[source]

Creates the list of UnitView objects for a particular unit in this CFSheet. (There is one UnitView for each Projection to this CFSheet).

Each UnitView is then added to the sheet_views of its source sheet. It returns the list of all UnitViews for the given unit.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

xdensity

The spacing between elements in an underlying matrix representation, in the x direction.

ydensity

The spacing between elements in an underlying matrix representation, in the y direction.

class topo.base.cf.ConnectionField(input_sheet, x=0.0, y=0.0, template=BoundingBox(radius=0.1), weights_generator=Constant(bounds=BoundingBox(radius=0.5), group='Pattern', mask=None, mask_shape=None, name='Constant01272', offset=0.0, orientation=0.0, output_fns=[], position=[0.0, 0.0], scale=1.0, size=1.0, x=0.0, xdensity=256, y=0.0, ydensity=256, z=None), mask=Constant(bounds=BoundingBox(radius=0.5), group='Pattern', mask=None, mask_shape=None, name='Constant01273', offset=0.0, orientation=0.0, output_fns=[], position=[0.0, 0.0], scale=1.0, size=1.0, x=0.0, xdensity=256, y=0.0, ydensity=256, z=None), output_fns=None, min_matrix_radius=1, label=None)[source]

Bases: object

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.

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

topo.base.cf.MaskedCFIter

alias of CFIter

exception topo.base.cf.NullCFError(x, y, input, rows, cols)[source]

Bases: exceptions.ValueError

Error thrown when trying to create an empty CF.

class topo.base.cf.ResizableCFProjection(initialize_cfs=True, **params)[source]

Bases: topo.base.cf.CFProjection

A CFProjection with resizable weights.

param Number precedence (allow_None=False, bounds=None, constant=False, default=0.8, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)

param Boolean private (allow_None=False, bounds=(0, 1), constant=False, default=False, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Set to true if this connection is for internal use only, not to be manipulated by a user.
param Integer seed (allow_None=True, bounds=None, constant=False, default=None, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
The random seed used to determine the randomized weight initialization stream. If not None, equivalent to appending the chosen integer to the hash_format.
param Boolean apply_output_fns_init (allow_None=False, bounds=(0, 1), constant=False, default=True, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Whether to apply the output function to connection fields (e.g. for normalization) when the CFs are first created.
param Parameter dest_port (allow_None=False, constant=False, default=Activity, instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False)
Identifier that can be used to distinguish different types of incoming connections. EventProcessors that accept only a single type of incoming event will typically use a src_port of None. However, if multiple types of communication are meaningful, the EventProcessor can accept other values for dest_port. It is up to the dest EventProcessor to process the data appropriately for each port, and to define what is expected to be sent to that port.
param Number strength (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
Global multiplicative scaling applied to the Activity of this Sheet.
param Parameter src_port (allow_None=False, constant=False, default=Activity, instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False)
Identifier that can be used to distinguish different types of outgoing connections. EventProcessors that generate only a single type of outgoing event will typically use a src_port of None. However, if multiple types of communication are meaningful, the EventProcessor can accept other values for src_port. It is up to the src EventProcessor to deliver appropriate data to each port, and to declare what will be sent over that port.
param Parameter cf_type (allow_None=False, constant=True, default=<class ‘topo.base.cf.ConnectionField’>, instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
Type of ConnectionField to use when creating individual CFs.
param ClassSelector cf_shape (allow_None=False, constant=True, default=<Constant Constant01282>, instantiate=True, is_instance=True, pickle_default_value=True, precedence=None, readonly=False)
Mask pattern to define the shape of the connection fields.
param Boolean plastic (allow_None=False, bounds=(0, 1), constant=False, default=True, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Whether or not to update the internal state on each call. Allows plasticity to be turned off during analysis, and then re-enabled.
param Number delay (allow_None=False, bounds=(0, None), constant=False, default=0.05, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
Simulation time between generation of an Event by the src and delivery to the dest. Should normally be nonzero, to represent a causal with a well-defined ordering of events.
param BoundingRegionParameter nominal_bounds_template (allow_None=False, constant=False, default=BoundingBox(radius=0.1), instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
Bounds defining the Sheet area covered by a prototypical ConnectionField. The true bounds will differ depending on the density (see create_slice_template()).
param ClassSelector response_fn (allow_None=False, constant=False, default=<CFPRF_Plugin CFPRF_Plugin01279>, instantiate=True, is_instance=True, pickle_default_value=True, precedence=None, readonly=False)
Function for computing the Projection response to an input pattern.
param Boolean same_cf_shape_for_all_cfs (allow_None=False, bounds=(0, 1), constant=False, default=True, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
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.
param Parameter activity_group (allow_None=False, constant=False, default=(0.5, <ufunc ‘add’>), instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Grouping and precedence specifier for computing activity from Projections. In a ProjectionSheet, all Projections in the same activity_group will be summed, and then the results from each group will be combined in the order of the activity_group using the operator specified by the activity_operator. For instance, if there are two Projections with activity_group==(0.2,numpy.add) and two with activity_group==(0.6,numpy.divide), activity from the first two will be added together, and the result divided by the sum of the second two.
param ClassSelector coord_mapper (allow_None=False, constant=False, default=<IdentityMF IdentityMF01287>, instantiate=True, is_instance=True, pickle_default_value=True, precedence=None, readonly=False)
Function to map a projected coordinate into the target sheet.
param Number mask_threshold (allow_None=False, bounds=None, constant=True, default=0.5, inclusive_bounds=(True, True), instantiate=True, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
If a unit is above this value in the cf_shape mask, it is included; otherwise it is excluded from the mask.
param Parameter dest (allow_None=True, constant=True, default=None, instantiate=True, pickle_default_value=True, precedence=0.11, readonly=False)
The EventProcessor to which messages are delivered.
param Number learning_rate (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
Amount of learning at each step for this projection, specified in units that are independent of the density of each Sheet.
param Boolean autosize_mask (allow_None=False, bounds=(0, 1), constant=True, default=True, instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
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.
param Boolean allow_null_cfs (allow_None=False, bounds=(0, 1), constant=False, default=False, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Whether or not the projection can have entirely empty CFs
param Integer min_matrix_radius (allow_None=False, bounds=(0, None), constant=False, default=1, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
Enforced minimum for radius of weights matrix. The default of 1 gives a minimum matrix of 3x3. 0 would allow a 1x1 matrix.
param ClassSelector learning_fn (allow_None=False, constant=False, default=<CFPLF_Plugin CFPLF_Plugin01283>, instantiate=True, is_instance=True, pickle_default_value=True, precedence=None, readonly=False)
Function for computing changes to the weights based on one activation step.
param String hash_format (allow_None=False, basestring=<type ‘basestring’>, constant=False, default={name}-{src}-{dest}, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Format string to determine the hash value used to initialize random weight generation. Format keys available include {name} {src} and {dest}.
param Parameter src (allow_None=True, constant=True, default=None, instantiate=True, pickle_default_value=True, precedence=0.1, readonly=False)
The EventProcessor from which messages originate.
param ClassSelector weights_generator (allow_None=False, constant=True, default=<Constant Constant01281>, instantiate=True, is_instance=True, pickle_default_value=True, precedence=None, readonly=False)
Generate initial weights values.
param HookList weights_output_fns (allow_None=False, bounds=(0, None), constant=False, default=[CFPOF_Plugin(name=’CFPOF_Plugin01285’, single_cf_fn=IdentityTF(init_keys=[], name=’IdentityTF01286’, norm_value=None))], instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
Functions applied to each CF after learning.
param HookList input_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
Function(s) applied to the input before the projection activity is computed.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
Function(s) applied to the projection activity after it is computed.
activate(input_activity)

Activate using the specified response_fn and output_fn.

apply_learn_output_fns(active_units_mask=True)

Apply the weights_output_fns to each unit.

If active_units_mask is True, inactive units will be skipped.

cf(r, c)

Return the specified ConnectionField

cf_bounds(r, c)

Return the bounds of the specified ConnectionField.

cf_type

alias of ConnectionField

change_bounds(nominal_bounds_template)[source]

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(new_wt_density)[source]

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

Not yet implemented.

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2b07aba1e100>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2b07aba1e1b0>
inspect_value = <functools.partial object at 0x2b07aba1e208>
learn()

For a CFProjection, learn consists of calling the learning_fn.

message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

override_plasticity_state(new_plasticity_state)

Temporarily override plasticity of medium and long term internal state.

This function should be implemented by all subclasses so that it preserves the ability of the Projection to compute activity, i.e. to operate over a short time scale, while preventing any lasting changes to the state.

For instance, if new_plasticity_state is False, in a Projection with modifiable connection weights, the values of those weights should temporarily be made fixed and unchanging after this call. For a Projection with automatic normalization, homeostatic plasticity, or other features that depend on a history of events (rather than just the current item being processed), changes in those properties would be disabled temporarily. Setting the plasticity state to False is useful during analysis operations (e.g. map measurement) that would otherwise change the state of the underlying network.

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, this call simply calls override_plasticity_state() on the Projection’s output_fn, and sets the ‘plastic’ parameter to False.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

projection_view(timestamp=None)

Returns the activity in a single projection

remove()

Remove this connection from its src’s list of out_connections and its dest’s list of in_connections.

restore_plasticity_state()

Restore previous plasticity state 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, e.g. to reenable plasticity of any type that was disabled.

script_repr(imports=, []prefix=' ')

Generate a runnable command for creating this connection.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2b07aba1e788>
set_param = <functools.partial object at 0x2b07aba1e7e0>
state_pop()

Pop the most recently pushed activity state of the stack.

state_push()

Push the current activity state onto the stack.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

view(sheet_x, sheet_y, timestamp=None, situated=False, **kwargs)

Return a single connection field Image, for the unit located nearest to sheet coordinate (sheet_x,sheet_y).

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

topo.base.cf.simple_vectorize(fn, num_outputs=1, output_type=<type 'object'>, doc='')[source]

Wrapper for Numpy.vectorize to make it work properly with different Numpy versions.

topo.base.cf.weight_type

Specified explicitly when creating weights matrix - required for optimized C functions.

alias of float32


ep Module

Inheritance diagram of topo.base.ep

EventProcessor classes.

An EventProcessor is an object that the Simulation is aware of, and can accept simulation Events. EventProcessors can also generate Events, and will presumably do some computation as well. Most EventProcessors will be in other more specific packages, such as topo.sheet; those here are the remaining uncategorized EventProcessors. Any new EventProcessors classes added to this directory will automatically become available for any model.

class topo.base.ep.PulseGenerator(**params)[source]

Bases: topo.base.simulation.EventProcessor

A simple pulse generator node.

Produces pulses (scalars) of a fixed amplitude at a fixed frequency and phase. Period and phase are in units of simulation time.

param Number phase (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
The time after starting the simulation to wait before sending the first pulse.
param Number amplitude (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
The size of the pulse to generate.
param Number period (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
The period with which to repeat the pulse. Must be greater than zero.
debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2b07aabde628>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2b07aabde9f0>
input_event(conn, data)[source]

On input from self, generate output. Ignore all other inputs.

inspect_value = <functools.partial object at 0x2b07aabde3c0>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

process_current_time()

Called by the simulation before advancing the simulation time. Allows the event processor to do any computation that requires that all events for this time have been delivered. Computations performed in this method should not generate any events with a zero time delay, or else causality could be violated. (By default, does nothing.)

script_repr(imports=, []prefix=' ')

Generate a runnable command for creating this EventProcessor.

send_output(src_port=None, data=None)

Send some data out to all connections on the given src_port. The data is deepcopied before it is sent out, to ensure that future changes to the data are not reflected in events from the past.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2b07aabde4c8>
set_param = <functools.partial object at 0x2b07aabde158>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class topo.base.ep.SumUnit(**params)[source]

Bases: topo.base.simulation.EventProcessor

A simple unit that outputs the running sum of input received thus far.

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2b07aabdec58>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2b07aabde9f0>
inspect_value = <functools.partial object at 0x2b07aabdef18>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Generate a runnable command for creating this EventProcessor.

send_output(src_port=None, data=None)

Send some data out to all connections on the given src_port. The data is deepcopied before it is sent out, to ensure that future changes to the data are not reflected in events from the past.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2b07aabdedb8>
set_param = <functools.partial object at 0x2b07aabde788>
start()

Called by the simulation when the EventProcessor is added to the simulation.

If an EventProcessor needs to have any code run when it is added to the simulation, the code can be put into this method in the subclass.

state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class topo.base.ep.ThresholdUnit(**params)[source]

Bases: topo.base.simulation.EventProcessor

A simple pulse-accumulator threshold node. Accumulates incoming pulses. When the accumulated value rises above threshold, it generates a pulse of a given amplitude and resets the accumulator to zero.

param Number threshold (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
The threshold at which to fire.
param Number initial_accum (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
The initial accumulator value.
param Number amplitude (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
The size of the pulse to generate.
debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2b07aabde2b8>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2b07aabdec58>
inspect_value = <functools.partial object at 0x2b07aabde3c0>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

process_current_time()

Called by the simulation before advancing the simulation time. Allows the event processor to do any computation that requires that all events for this time have been delivered. Computations performed in this method should not generate any events with a zero time delay, or else causality could be violated. (By default, does nothing.)

script_repr(imports=, []prefix=' ')

Generate a runnable command for creating this EventProcessor.

send_output(src_port=None, data=None)

Send some data out to all connections on the given src_port. The data is deepcopied before it is sent out, to ensure that future changes to the data are not reflected in events from the past.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2b07aabf5ec0>
set_param = <functools.partial object at 0x2b07aabf5f18>
start()

Called by the simulation when the EventProcessor is added to the simulation.

If an EventProcessor needs to have any code run when it is added to the simulation, the code can be put into this method in the subclass.

state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.


functionfamily Module

Inheritance diagram of topo.base.functionfamily

Basic function objects.

TransferFns: accept and modify a 2d array ResponseFns: accept two 2d arrays and return a scalar LearningFns: accept two 2d arrays and a scalar, return one of the arrays modified

class topo.base.functionfamily.CoordinateMapperFn(**params)[source]

Bases: param.parameterized.Parameterized

Abstract base class for functions mapping from a 2D coordinate into another one.

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2b07aab21208>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2b07aab21a48>
inspect_value = <functools.partial object at 0x2b07aab21158>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2b07aaac8af8>
set_param = <functools.partial object at 0x2b07aaac8ba8>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class topo.base.functionfamily.DotProduct(**params)[source]

Bases: topo.base.functionfamily.ResponseFn

Return the sum of the element-by-element product of two 2D arrays.

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2b07aab21628>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2b07aab21208>
inspect_value = <functools.partial object at 0x2b07aab214c8>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2b07aaac8ba8>
set_param = <functools.partial object at 0x2b07aaac8d08>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class topo.base.functionfamily.Hebbian(**params)[source]

Bases: topo.base.functionfamily.LearningFn

Basic Hebbian rule; Dayan and Abbott, 2001, equation 8.3.

Increases each weight in proportion to the product of this neuron’s activity and the input activity.

Requires some form of output_fn normalization for stability.

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2b07aab21838>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2b07aab21628>
inspect_value = <functools.partial object at 0x2b07aab21260>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2b07aaac8d08>
set_param = <functools.partial object at 0x2b07aaac8af8>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class topo.base.functionfamily.IdentityLF(**params)[source]

Bases: topo.base.functionfamily.LearningFn

Identity function; does not modify the weights.

For speed, calling this function object is sometimes optimized away entirely. To make this feasible, it is not allowable to derive other classes from this object, modify it to have different behavior, add side effects, or anything of that nature.

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2b07aab21a48>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2b07aab21838>
inspect_value = <functools.partial object at 0x2b07aab21368>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2b07aaac8af8>
set_param = <functools.partial object at 0x2b07aaac8ba8>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class topo.base.functionfamily.IdentityMF(**params)[source]

Bases: topo.base.functionfamily.CoordinateMapperFn

Return the x coordinate of the given coordinate.

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2b07aab21a48>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2b07aab21208>
inspect_value = <functools.partial object at 0x2b07aab21158>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2b07aaac8ba8>
set_param = <functools.partial object at 0x2b07aaac8d08>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class topo.base.functionfamily.LearningFn(**params)[source]

Bases: param.parameterized.Parameterized

Abstract base class for learning functions that plug into CFPLF_Plugin.

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2b07aab213c0>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2b07aab21a48>
inspect_value = <functools.partial object at 0x2b07aab214c8>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2b07aaac8d08>
set_param = <functools.partial object at 0x2b07aaac8af8>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class topo.base.functionfamily.ResponseFn(**params)[source]

Bases: param.parameterized.Parameterized

Abstract base class for response functions that plug into CFPRF_Plugin.

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2b07aab21520>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2b07aab213c0>
inspect_value = <functools.partial object at 0x2b07aab21628>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2b07aaac8af8>
set_param = <functools.partial object at 0x2b07aaac8ba8>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.


generatorsheet Module

Inheritance diagram of topo.base.generatorsheet

GeneratorSheet: a sheet with a pattern generator.

class topo.base.generatorsheet.ChannelGeneratorSheet(**params)[source]

Bases: topo.base.generatorsheet.GeneratorSheet

A GeneratorSheet that handles input patterns with multiple simultaneous channels.

Accepts either a single-channel or an NChannel input_generator. If the input_generator stores separate channel patterns, it is used as-is; if other (single-channel) PatternGenerators are used, the Class behaves like a normal GeneratorSheet.

When a pattern is generated, the average of the channels is sent out on the Activity port as usual for a GeneratorSheet, and channel activities are sent out on the Activity0, Activity1, ..., ActivityN-1 ports. Thus this class can be used just like GeneratorSheet, but with optional color channels available, too.

If the input_generator is NChannel, this GeneratorSheet will handle the separate channels and create the specific output ports. If the input_generator is single-channel (eg, a monochrome image) then this GeneratorSheet will behave as a normal non-NChannel GeneratorSheet.

param Boolean apply_output_fns (allow_None=False, bounds=(0, 1), constant=False, default=True, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Whether to apply the output_fn after computing an Activity matrix.
param Number constant_mean_total_channels_output (allow_None=True, bounds=None, constant=False, default=None, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
If set, it enforces the average of the mean channel values to be fixed. Eg, M = ( activity0+activity1+...+activity(N-1) ).mean() / N = constant_mean_total_channels_output
param Dict channel_output_fns (allow_None=False, constant=False, default={}, instantiate=True, is_instance=True, pickle_default_value=True, precedence=None, readonly=False)
Dictionary with arrays of channel-specific output functions: eg, {0:[fnc1, fnc2],3:[fnc3]}. The dictionary isn’t required to specify every channel, but rather only those required.
param ClassSelector input_generator (allow_None=False, constant=False, default=<Constant Constant01288>, instantiate=True, is_instance=True, pickle_default_value=True, precedence=None, readonly=False)
Specifies a particular PatternGenerator type to use when creating patterns.
param Number precedence (allow_None=False, bounds=None, constant=False, default=0.1, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
Allows a sorting order for Sheets, e.g. in the GUI.
param BoundingRegionParameter nominal_bounds (allow_None=False, constant=True, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
User-specified BoundingBox of the Sheet coordinate area covered by this Sheet. The left and right bounds–if specified–will always be observed, but the top and bottom bounds may be adjusted to ensure the density in the y direction is the same as the density in the x direction. In such a case, the top and bottom bounds are adjusted so that the center y point remains the same, and each bound is as close as possible to its specified value. The actual value of this Parameter is not adjusted, but the true bounds may be found from the ‘bounds’ attribute of this object.
param Number row_precedence (allow_None=False, bounds=None, constant=False, default=0.5, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
Allows grouping of Sheets before sorting precedence is applied, e.g. for two-dimensional plots in the GUI.
param Boolean plastic (allow_None=False, bounds=(0, 1), constant=False, default=True, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Setting this to False tells the Sheet not to change its permanent state (e.g. any connection weights) based on incoming events.
param Number nominal_density (allow_None=False, bounds=None, constant=True, default=10, inclusive_bounds=(True, True), instantiate=True, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
User-specified number of processing units per 1.0 distance horizontally or vertically in Sheet coordinates. The actual number may be different because of discretization; the matrix needs to tile the plane exactly, and for that to work the density might need to be adjusted. For instance, an area of 3x2 cannot have a density of 2 in each direction. The true density may be obtained from either the xdensity or ydensity attribute (since these are identical for a Sheet).
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
Output function(s) to apply (if apply_output_fns is true) to this Sheet’s activity.
param Number period (allow_None=False, bounds=(0, None), constant=True, default=1, inclusive_bounds=(False, True), instantiate=True, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
Delay (in Simulation time) between generating new input patterns.
param Number phase (allow_None=False, bounds=None, constant=False, default=0.05, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
Delay after the start of the Simulation (at time zero) before generating an input pattern. For a clocked, feedforward simulation, one would typically want to use a small nonzero phase and use delays less than the user-visible step size (typically 1.0), so that inputs are generated and processed before this step is complete.
param NumericTuple layout_location (allow_None=False, constant=False, default=(-1, -1), instantiate=False, length=2, pickle_default_value=True, precedence=-1, readonly=False)
Location for this Sheet in an arbitrary pixel-based space in which Sheets can be laid out for visualization.
param Dict properties (allow_None=False, constant=False, default={}, instantiate=True, is_instance=True, pickle_default_value=True, precedence=None, readonly=False)
A dictionary of property values associated with the Sheet object. For instance, the dictionary: {‘polarity’:’ON’, ‘eye’:’Left’} could be used to indicate a left, LGN Sheet with ON-surround receptive fields.
activate()

Collect activity from each projection, combine it to calculate the activity for this sheet, and send the result out.

Subclasses will need to override this method to whatever it means to calculate activity in that subclass.

activity_len()

Return the number of items that have been saved by state_push().

closest_cell_center(x, y)

Given arbitary sheet coordinates, return the sheet coordinates of the center of the closest unit.

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

density

The sheet’s true density (i.e. the xdensity, which is equal to the ydensity for a Sheet.)

force_new_dynamic_value = <functools.partial object at 0x2b07aa86bc00>
generate()[source]

Works as in the superclass, but also generates NChannel output and sends it out on the Activity0, Activity1, ..., ActivityN ports.

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2b07aa86bb50>
inspect_value = <functools.partial object at 0x2b07aa86b9f0>
matrix2sheet(float_row, float_col)

Convert a floating-point location (float_row,float_col) in matrix coordinates to its corresponding location (x,y) in sheet coordinates.

Valid for scalar or array float_row and float_col.

Inverse of sheet2matrix().

matrixidx2sheet(row, col)

Return (x,y) where x and y are the floating point coordinates of the center of the given matrix cell (row,col). If the matrix cell represents a 0.2 by 0.2 region, then the center location returned would be 0.1,0.1.

NOTE: This is NOT the strict mathematical inverse of sheet2matrixidx(), because sheet2matrixidx() discards all but the integer portion of the continuous matrix coordinate.

Valid only for scalar or array row and col.

message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

n_bytes()

Return a lower bound for the memory taken by this sheet, in bytes.

Typically, this number will include the activity array and any similar arrays, plus any other significant data owned (in some sense) by this Sheet. 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.

Subclasses should reimplement this method if they store a significant amount of data other than in the activity array.

override_plasticity_state(new_plasticity_state)

Temporarily override plasticity of medium and long term internal state.

This function should be implemented by all subclasses so that it preserves the ability of the Sheet to compute activity, i.e. to operate over a short time scale, while preventing any lasting changes to the state (if new_plasticity_state=False).

Any operation 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, simply saves a copy of the plastic flag to an internal stack (so that it can be restored by restore_plasticity_state()), and then sets plastic to new_plasticity_state.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pop_input_generator()

Discard the current input_generator, and retrieve the previous one from the stack.

Warns if no input_generator is available on the stack.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

process_current_time()

Called by the simulation before advancing the simulation time. Allows the event processor to do any computation that requires that all events for this time have been delivered. Computations performed in this method should not generate any events with a zero time delay, or else causality could be violated. (By default, does nothing.)

push_input_generator()

Push the current input_generator onto a stack for future retrieval.

release_sheet_view(view_name)

Delete the dictionary entry with key entry ‘view_name’ to save memory.

restore_plasticity_state()

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.

row_col_sheetcoords()

Return an array of Y-coordinates corresponding to the rows of the activity matrix of the sheet, and an array of X-coordinates corresponding to the columns.

script_repr(imports=, []prefix=' ')

Generate a runnable command for creating this EventProcessor.

send_output(src_port=None, data=None)

Send some data out to all connections on the given src_port. The data is deepcopied before it is sent out, to ensure that future changes to the data are not reflected in events from the past.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2b07aa7dab50>
set_input_generator(new_ig, push_existing=False)[source]

If single-channel generators are used, the Class reverts to a simple GeneratorSheet behavior. If NChannel inputs are used, it will update the number of channels of the ChannelGeneratorSheet to match those of the input. If the number of channels doesn’t change, there’s no need to reset.

set_param = <functools.partial object at 0x2b07aa7da730>
sheet2matrix(x, y)

Convert a point (x,y) in Sheet coordinates to continuous matrix coordinates.

Returns (float_row,float_col), where float_row corresponds to y, and float_col to x.

Valid for scalar or array x and y.

Note about Bounds For a Sheet with BoundingBox(points=((-0.5,-0.5),(0.5,0.5))) and density=3, x=-0.5 corresponds to float_col=0.0 and x=0.5 corresponds to float_col=3.0. float_col=3.0 is not inside the matrix representing this Sheet, which has the three columns (0,1,2). That is, x=-0.5 is inside the BoundingBox but x=0.5 is outside. Similarly, y=0.5 is inside (at row 0) but y=-0.5 is outside (at row 3) (it’s the other way round for y because the matrix row index increases as y decreases).

sheet2matrixidx(x, y)

Convert a point (x,y) in sheet coordinates to the integer row and column index of the matrix cell in which that point falls, given a bounds and density. Returns (row,column).

Note that if coordinates along the right or bottom boundary are passed into this function, the returned matrix coordinate of the boundary will be just outside the matrix, because the right and bottom boundaries are exclusive.

Valid for scalar or array x and y.

sheetcoordinates_of_matrixidx()

Return x,y where x is a vector of sheet coordinates representing the x-center of each matrix cell, and y represents the corresponding y-center of the cell.

sheetcoords_of_idx_grid()

Return an array of x-coordinates and an array of y-coordinates corresponding to the activity matrix of the sheet.

state_pop()

Pop the most recently saved state off the stack.

See state_push() for more details.

state_push()

Save the current state of this sheet to an internal stack.

This method is used by operations that need to test the response of the sheet without permanently altering its state, e.g. for measuring maps or probing the current behavior non-invasively. By default, only the activity pattern of this sheet is saved, but subclasses should add saving for any additional state that they maintain, or strange bugs are likely to occur. The state can be restored using state_pop().

Note that Sheets that do learning need not save the values of all connection weights, if any, because plasticity can be turned off explicitly. Thus this method is intended only for shorter-term state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

xdensity

The spacing between elements in an underlying matrix representation, in the x direction.

ydensity

The spacing between elements in an underlying matrix representation, in the y direction.

class topo.base.generatorsheet.GeneratorSheet(**params)[source]

Bases: topo.base.sheet.Sheet

Sheet for generating a series of 2D patterns.

Typically generates the patterns by choosing parameters from a random distribution, but can use any mechanism.

param Boolean apply_output_fns (allow_None=False, bounds=(0, 1), constant=False, default=True, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Whether to apply the output_fn after computing an Activity matrix.
param ClassSelector input_generator (allow_None=False, constant=False, default=<Constant Constant01288>, instantiate=True, is_instance=True, pickle_default_value=True, precedence=None, readonly=False)
Specifies a particular PatternGenerator type to use when creating patterns.
param Number precedence (allow_None=False, bounds=None, constant=False, default=0.1, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
Allows a sorting order for Sheets, e.g. in the GUI.
param BoundingRegionParameter nominal_bounds (allow_None=False, constant=True, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
User-specified BoundingBox of the Sheet coordinate area covered by this Sheet. The left and right bounds–if specified–will always be observed, but the top and bottom bounds may be adjusted to ensure the density in the y direction is the same as the density in the x direction. In such a case, the top and bottom bounds are adjusted so that the center y point remains the same, and each bound is as close as possible to its specified value. The actual value of this Parameter is not adjusted, but the true bounds may be found from the ‘bounds’ attribute of this object.
param Number row_precedence (allow_None=False, bounds=None, constant=False, default=0.5, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
Allows grouping of Sheets before sorting precedence is applied, e.g. for two-dimensional plots in the GUI.
param Boolean plastic (allow_None=False, bounds=(0, 1), constant=False, default=True, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Setting this to False tells the Sheet not to change its permanent state (e.g. any connection weights) based on incoming events.
param Number nominal_density (allow_None=False, bounds=None, constant=True, default=10, inclusive_bounds=(True, True), instantiate=True, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
User-specified number of processing units per 1.0 distance horizontally or vertically in Sheet coordinates. The actual number may be different because of discretization; the matrix needs to tile the plane exactly, and for that to work the density might need to be adjusted. For instance, an area of 3x2 cannot have a density of 2 in each direction. The true density may be obtained from either the xdensity or ydensity attribute (since these are identical for a Sheet).
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
Output function(s) to apply (if apply_output_fns is true) to this Sheet’s activity.
param Number period (allow_None=False, bounds=(0, None), constant=True, default=1, inclusive_bounds=(False, True), instantiate=True, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
Delay (in Simulation time) between generating new input patterns.
param Number phase (allow_None=False, bounds=None, constant=False, default=0.05, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
Delay after the start of the Simulation (at time zero) before generating an input pattern. For a clocked, feedforward simulation, one would typically want to use a small nonzero phase and use delays less than the user-visible step size (typically 1.0), so that inputs are generated and processed before this step is complete.
param NumericTuple layout_location (allow_None=False, constant=False, default=(-1, -1), instantiate=False, length=2, pickle_default_value=True, precedence=-1, readonly=False)
Location for this Sheet in an arbitrary pixel-based space in which Sheets can be laid out for visualization.
param Dict properties (allow_None=False, constant=False, default={}, instantiate=True, is_instance=True, pickle_default_value=True, precedence=None, readonly=False)
A dictionary of property values associated with the Sheet object. For instance, the dictionary: {‘polarity’:’ON’, ‘eye’:’Left’} could be used to indicate a left, LGN Sheet with ON-surround receptive fields.
activate()

Collect activity from each projection, combine it to calculate the activity for this sheet, and send the result out.

Subclasses will need to override this method to whatever it means to calculate activity in that subclass.

activity_len()

Return the number of items that have been saved by state_push().

closest_cell_center(x, y)

Given arbitary sheet coordinates, return the sheet coordinates of the center of the closest unit.

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

density

The sheet’s true density (i.e. the xdensity, which is equal to the ydensity for a Sheet.)

force_new_dynamic_value = <functools.partial object at 0x2b07aa86b6d8>
generate()[source]

Generate the output and send it out the Activity port.

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2b07aa86bba8>
inspect_value = <functools.partial object at 0x2b07aa86be10>
matrix2sheet(float_row, float_col)

Convert a floating-point location (float_row,float_col) in matrix coordinates to its corresponding location (x,y) in sheet coordinates.

Valid for scalar or array float_row and float_col.

Inverse of sheet2matrix().

matrixidx2sheet(row, col)

Return (x,y) where x and y are the floating point coordinates of the center of the given matrix cell (row,col). If the matrix cell represents a 0.2 by 0.2 region, then the center location returned would be 0.1,0.1.

NOTE: This is NOT the strict mathematical inverse of sheet2matrixidx(), because sheet2matrixidx() discards all but the integer portion of the continuous matrix coordinate.

Valid only for scalar or array row and col.

message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

n_bytes()

Return a lower bound for the memory taken by this sheet, in bytes.

Typically, this number will include the activity array and any similar arrays, plus any other significant data owned (in some sense) by this Sheet. 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.

Subclasses should reimplement this method if they store a significant amount of data other than in the activity array.

override_plasticity_state(new_plasticity_state)

Temporarily override plasticity of medium and long term internal state.

This function should be implemented by all subclasses so that it preserves the ability of the Sheet to compute activity, i.e. to operate over a short time scale, while preventing any lasting changes to the state (if new_plasticity_state=False).

Any operation 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, simply saves a copy of the plastic flag to an internal stack (so that it can be restored by restore_plasticity_state()), and then sets plastic to new_plasticity_state.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pop_input_generator()[source]

Discard the current input_generator, and retrieve the previous one from the stack.

Warns if no input_generator is available on the stack.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

process_current_time()

Called by the simulation before advancing the simulation time. Allows the event processor to do any computation that requires that all events for this time have been delivered. Computations performed in this method should not generate any events with a zero time delay, or else causality could be violated. (By default, does nothing.)

push_input_generator()[source]

Push the current input_generator onto a stack for future retrieval.

release_sheet_view(view_name)

Delete the dictionary entry with key entry ‘view_name’ to save memory.

restore_plasticity_state()

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.

row_col_sheetcoords()

Return an array of Y-coordinates corresponding to the rows of the activity matrix of the sheet, and an array of X-coordinates corresponding to the columns.

script_repr(imports=, []prefix=' ')

Generate a runnable command for creating this EventProcessor.

send_output(src_port=None, data=None)

Send some data out to all connections on the given src_port. The data is deepcopied before it is sent out, to ensure that future changes to the data are not reflected in events from the past.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2b07aa86bb50>
set_input_generator(new_ig, push_existing=False)[source]

Set the input_generator, overwriting the existing one by default.

If push_existing is false, the existing input_generator is discarded permanently. Otherwise, the existing one is put onto a stack, and can later be restored by calling pop_input_generator.

set_param = <functools.partial object at 0x2b07aa86b8e8>
sheet2matrix(x, y)

Convert a point (x,y) in Sheet coordinates to continuous matrix coordinates.

Returns (float_row,float_col), where float_row corresponds to y, and float_col to x.

Valid for scalar or array x and y.

Note about Bounds For a Sheet with BoundingBox(points=((-0.5,-0.5),(0.5,0.5))) and density=3, x=-0.5 corresponds to float_col=0.0 and x=0.5 corresponds to float_col=3.0. float_col=3.0 is not inside the matrix representing this Sheet, which has the three columns (0,1,2). That is, x=-0.5 is inside the BoundingBox but x=0.5 is outside. Similarly, y=0.5 is inside (at row 0) but y=-0.5 is outside (at row 3) (it’s the other way round for y because the matrix row index increases as y decreases).

sheet2matrixidx(x, y)

Convert a point (x,y) in sheet coordinates to the integer row and column index of the matrix cell in which that point falls, given a bounds and density. Returns (row,column).

Note that if coordinates along the right or bottom boundary are passed into this function, the returned matrix coordinate of the boundary will be just outside the matrix, because the right and bottom boundaries are exclusive.

Valid for scalar or array x and y.

sheetcoordinates_of_matrixidx()

Return x,y where x is a vector of sheet coordinates representing the x-center of each matrix cell, and y represents the corresponding y-center of the cell.

sheetcoords_of_idx_grid()

Return an array of x-coordinates and an array of y-coordinates corresponding to the activity matrix of the sheet.

state_pop()

Pop the most recently saved state off the stack.

See state_push() for more details.

state_push()

Save the current state of this sheet to an internal stack.

This method is used by operations that need to test the response of the sheet without permanently altering its state, e.g. for measuring maps or probing the current behavior non-invasively. By default, only the activity pattern of this sheet is saved, but subclasses should add saving for any additional state that they maintain, or strange bugs are likely to occur. The state can be restored using state_pop().

Note that Sheets that do learning need not save the values of all connection weights, if any, because plasticity can be turned off explicitly. Thus this method is intended only for shorter-term state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

xdensity

The spacing between elements in an underlying matrix representation, in the x direction.

ydensity

The spacing between elements in an underlying matrix representation, in the y direction.


projection Module

Inheritance diagram of topo.base.projection

Projection and related classes.

class topo.base.projection.AndMask(sheet=None, **params)[source]

Bases: topo.base.projection.CompositeSheetMask

A composite SheetMask that computes its value as the logical AND (i.e. intersection) of its sub-masks.

param List submasks (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=None, readonly=False)

data

Ensure that whenever somebody accesses the data they are not None.

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2b07aa4e8890>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2b07aa4e8e68>
inspect_value = <functools.partial object at 0x2b07aa4e8d08>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2b07aa4e82b8>
set_param = <functools.partial object at 0x2b07aa44f730>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class topo.base.projection.CompositeSheetMask(sheet=None, **params)[source]

Bases: topo.base.projection.SheetMask

A SheetMask that computes its value from other SheetMasks.

param List submasks (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=None, readonly=False)

data

Ensure that whenever somebody accesses the data they are not None.

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2b07aa4e8838>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2b07aa4e86d8>
inspect_value = <functools.partial object at 0x2b07aa4e8310>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2b07aa44f628>
set_param = <functools.partial object at 0x2b07aa44f730>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class topo.base.projection.NeighborhoodMask(sheet, **params)[source]

Bases: topo.base.projection.SheetMask

A SheetMask where the mask includes a neighborhood around active neurons.

Given a radius and a threshold, considers a neuron active if at least one neuron in the radius is over the threshold.

param Number threshold (allow_None=False, bounds=(0, None), constant=False, default=1e-05, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
Threshold for considering a neuron active. This value should be small to avoid discarding significantly active neurons.
param Number radius (allow_None=False, bounds=(0, None), constant=False, default=0.05, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
Radius in Sheet coordinates around active neurons to consider neighbors active as well. Using a larger radius ensures that the calculation will be unaffected by the mask, but it will reduce any computational benefit from the mask.
data

Ensure that whenever somebody accesses the data they are not None.

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2b07aa4e80a8>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2b07aa4e8ba8>
inspect_value = <functools.partial object at 0x2b07aa4e89f0>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

reset()

Initialize mask to default value (with no neurons masked out).

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2b07aa44ff70>
set_param = <functools.partial object at 0x2b07aa44f680>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

update()

Update the current mask based on the current activity and a previous mask.

Should be called only if calculate() has already been called since the last reset(); potentially faster to compute than redoing the entire calculate().

Subclasses should override this method to compute some non-default mask.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class topo.base.projection.OrMask(sheet=None, **params)[source]

Bases: topo.base.projection.CompositeSheetMask

A composite SheetMask that computes its value as the logical OR (i.e. union) of its sub-masks.

param List submasks (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=None, readonly=False)

data

Ensure that whenever somebody accesses the data they are not None.

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2b07aa4e8100>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2b07aa4e8e68>
inspect_value = <functools.partial object at 0x2b07aa4e87e0>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2b07aa44ffc8>
set_param = <functools.partial object at 0x2b07aa44fa48>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class topo.base.projection.Projection(**params)[source]

Bases: topo.base.simulation.EPConnection

A projection from a Sheet into a ProjectionSheet.

Projections are required to support the activate() method, which will construct a matrix the same size as the target ProjectionSheet, from an input matrix of activity from the source Sheet. Other than that, a Projection may be of any type.

param Parameter src (allow_None=True, constant=True, default=None, instantiate=True, pickle_default_value=True, precedence=0.1, readonly=False)
The EventProcessor from which messages originate.

param Number strength (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)

param Parameter src_port (allow_None=False, constant=False, default=Activity, instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False)
Identifier that can be used to distinguish different types of outgoing connections. EventProcessors that generate only a single type of outgoing event will typically use a src_port of None. However, if multiple types of communication are meaningful, the EventProcessor can accept other values for src_port. It is up to the src EventProcessor to deliver appropriate data to each port, and to declare what will be sent over that port.

param Number precedence (allow_None=False, bounds=None, constant=False, default=0.5, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)

param Parameter dest (allow_None=True, constant=True, default=None, instantiate=True, pickle_default_value=True, precedence=0.11, readonly=False)
The EventProcessor to which messages are delivered.
param HookList input_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
Function(s) applied to the input before the projection activity is computed.
param Boolean private (allow_None=False, bounds=(0, 1), constant=False, default=False, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Set to true if this connection is for internal use only, not to be manipulated by a user.
param Boolean plastic (allow_None=False, bounds=(0, 1), constant=False, default=True, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Whether or not to update the internal state on each call. Allows plasticity to be turned off during analysis, and then re-enabled.
param Number delay (allow_None=False, bounds=(0, None), constant=False, default=0.05, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
Simulation time between generation of an Event by the src and delivery to the dest. Should normally be nonzero, to represent a causal with a well-defined ordering of events.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
Function(s) applied to the projection activity after it is computed.
param Parameter activity_group (allow_None=False, constant=False, default=(0.5, <ufunc ‘add’>), instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Grouping and precedence specifier for computing activity from Projections. In a ProjectionSheet, all Projections in the same activity_group will be summed, and then the results from each group will be combined in the order of the activity_group using the operator specified by the activity_operator. For instance, if there are two Projections with activity_group==(0.2,numpy.add) and two with activity_group==(0.6,numpy.divide), activity from the first two will be added together, and the result divided by the sum of the second two.
param Parameter dest_port (allow_None=False, constant=False, default=Activity, instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False)
Identifier that can be used to distinguish different types of incoming connections. EventProcessors that accept only a single type of incoming event will typically use a src_port of None. However, if multiple types of communication are meaningful, the EventProcessor can accept other values for dest_port. It is up to the dest EventProcessor to process the data appropriately for each port, and to define what is expected to be sent to that port.
activate(input_activity)[source]

Compute an activity matrix for output, based on the specified input_activity.

Subclasses must override this method to whatever it means to calculate activity in that subclass.

apply_learn_output_fns(active_units_mask=True)[source]

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 active_units_mask argument determines whether or not to apply the output_fn to non-responding units.

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2b07aa4e8310>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2b07aa4e8418>
inspect_value = <functools.partial object at 0x2b07aa4e84c8>
learn()[source]

This function has to be re-implemented by sub-classes, if they wish to support learning.

message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

n_bytes()[source]

Estimate the memory bytes taken by this Projection.

By default, counts only the activity array, but subclasses should implement this method to include also the bytes taken by weight arrays and any similar arrays, as a rough lower bound from which memory requirements and memory usage patterns can be estimated.

n_conns()[source]

Return the size of this projection, in number of connections.

Must be implemented by subclasses, if only to declare that no connections are stored.

override_plasticity_state(new_plasticity_state)[source]

Temporarily override plasticity of medium and long term internal state.

This function should be implemented by all subclasses so that it preserves the ability of the Projection to compute activity, i.e. to operate over a short time scale, while preventing any lasting changes to the state.

For instance, if new_plasticity_state is False, in a Projection with modifiable connection weights, the values of those weights should temporarily be made fixed and unchanging after this call. For a Projection with automatic normalization, homeostatic plasticity, or other features that depend on a history of events (rather than just the current item being processed), changes in those properties would be disabled temporarily. Setting the plasticity state to False is useful during analysis operations (e.g. map measurement) that would otherwise change the state of the underlying network.

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, this call simply calls override_plasticity_state() on the Projection’s output_fn, and sets the ‘plastic’ parameter to False.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

projection_view(timestamp=None)[source]

Returns the activity in a single projection

remove()

Remove this connection from its src’s list of out_connections and its dest’s list of in_connections.

restore_plasticity_state()[source]

Restore previous plasticity state 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, e.g. to reenable plasticity of any type that was disabled.

script_repr(imports=, []prefix=' ')

Generate a runnable command for creating this connection.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2b07aa44fdb8>
set_param = <functools.partial object at 0x2b07aa44faf8>
state_pop()[source]

Pop the most recently pushed activity state of the stack.

state_push()[source]

Push the current activity state onto the stack.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class topo.base.projection.ProjectionSheet(**params)[source]

Bases: topo.base.sheet.Sheet

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.

param Boolean apply_output_fns (allow_None=False, bounds=(0, 1), constant=False, default=True, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Whether to apply the output_fn after computing an Activity matrix.
param Number precedence (allow_None=False, bounds=None, constant=False, default=0.1, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
Allows a sorting order for Sheets, e.g. in the GUI.
param BoundingRegionParameter nominal_bounds (allow_None=False, constant=True, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
User-specified BoundingBox of the Sheet coordinate area covered by this Sheet. The left and right bounds–if specified–will always be observed, but the top and bottom bounds may be adjusted to ensure the density in the y direction is the same as the density in the x direction. In such a case, the top and bottom bounds are adjusted so that the center y point remains the same, and each bound is as close as possible to its specified value. The actual value of this Parameter is not adjusted, but the true bounds may be found from the ‘bounds’ attribute of this object.
param Parameter mask (allow_None=False, constant=False, default=<SheetMask SheetMask00984>, instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
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.
param Number row_precedence (allow_None=False, bounds=None, constant=False, default=0.5, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
Allows grouping of Sheets before sorting precedence is applied, e.g. for two-dimensional plots in the GUI.
param Boolean plastic (allow_None=False, bounds=(0, 1), constant=False, default=True, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Setting this to False tells the Sheet not to change its permanent state (e.g. any connection weights) based on incoming events.
param Number nominal_density (allow_None=False, bounds=None, constant=True, default=10, inclusive_bounds=(True, True), instantiate=True, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
User-specified number of processing units per 1.0 distance horizontally or vertically in Sheet coordinates. The actual number may be different because of discretization; the matrix needs to tile the plane exactly, and for that to work the density might need to be adjusted. For instance, an area of 3x2 cannot have a density of 2 in each direction. The true density may be obtained from either the xdensity or ydensity attribute (since these are identical for a Sheet).
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
Output function(s) to apply (if apply_output_fns is true) to this Sheet’s activity.
param Boolean allow_skip_non_responding_units (allow_None=False, bounds=(0, 1), constant=False, default=True, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
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.
param NumericTuple layout_location (allow_None=False, constant=False, default=(-1, -1), instantiate=False, length=2, pickle_default_value=True, precedence=-1, readonly=False)
Location for this Sheet in an arbitrary pixel-based space in which Sheets can be laid out for visualization.
param Dict properties (allow_None=False, constant=False, default={}, instantiate=True, is_instance=True, pickle_default_value=True, precedence=None, readonly=False)
A dictionary of property values associated with the Sheet object. For instance, the dictionary: {‘polarity’:’ON’, ‘eye’:’Left’} could be used to indicate a left, LGN Sheet with ON-surround receptive fields.
activate()[source]

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.

activity_len()

Return the number of items that have been saved by state_push().

closest_cell_center(x, y)

Given arbitary sheet coordinates, return the sheet coordinates of the center of the closest unit.

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

density

The sheet’s true density (i.e. the xdensity, which is equal to the ydensity for a Sheet.)

force_new_dynamic_value = <functools.partial object at 0x2b07aa4e8788>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2b07aa4e8f18>
input_event(conn, data)[source]

Accept input from some sheet. Call .present_input() to compute the stimulation from that sheet.

inspect_value = <functools.partial object at 0x2b07aa44fcb0>
learn()[source]

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.

matrix2sheet(float_row, float_col)

Convert a floating-point location (float_row,float_col) in matrix coordinates to its corresponding location (x,y) in sheet coordinates.

Valid for scalar or array float_row and float_col.

Inverse of sheet2matrix().

matrixidx2sheet(row, col)

Return (x,y) where x and y are the floating point coordinates of the center of the given matrix cell (row,col). If the matrix cell represents a 0.2 by 0.2 region, then the center location returned would be 0.1,0.1.

NOTE: This is NOT the strict mathematical inverse of sheet2matrixidx(), because sheet2matrixidx() discards all but the integer portion of the continuous matrix coordinate.

Valid only for scalar or array row and col.

message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

n_bytes()[source]

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.

n_conns()[source]

Count the total size of all incoming projections, in number of connections.

override_plasticity_state(new_plasticity_state)[source]

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

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

present_input(input_activity, conn)[source]

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.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

process_current_time()[source]

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.

projections(name=None)[source]

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.

release_sheet_view(view_name)

Delete the dictionary entry with key entry ‘view_name’ to save memory.

row_col_sheetcoords()

Return an array of Y-coordinates corresponding to the rows of the activity matrix of the sheet, and an array of X-coordinates corresponding to the columns.

script_repr(imports=, []prefix=' ')

Generate a runnable command for creating this EventProcessor.

send_output(src_port=None, data=None)

Send some data out to all connections on the given src_port. The data is deepcopied before it is sent out, to ensure that future changes to the data are not reflected in events from the past.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2b07aa3cf890>
set_param = <functools.partial object at 0x2b07aa3cf9f0>
sheet2matrix(x, y)

Convert a point (x,y) in Sheet coordinates to continuous matrix coordinates.

Returns (float_row,float_col), where float_row corresponds to y, and float_col to x.

Valid for scalar or array x and y.

Note about Bounds For a Sheet with BoundingBox(points=((-0.5,-0.5),(0.5,0.5))) and density=3, x=-0.5 corresponds to float_col=0.0 and x=0.5 corresponds to float_col=3.0. float_col=3.0 is not inside the matrix representing this Sheet, which has the three columns (0,1,2). That is, x=-0.5 is inside the BoundingBox but x=0.5 is outside. Similarly, y=0.5 is inside (at row 0) but y=-0.5 is outside (at row 3) (it’s the other way round for y because the matrix row index increases as y decreases).

sheet2matrixidx(x, y)

Convert a point (x,y) in sheet coordinates to the integer row and column index of the matrix cell in which that point falls, given a bounds and density. Returns (row,column).

Note that if coordinates along the right or bottom boundary are passed into this function, the returned matrix coordinate of the boundary will be just outside the matrix, because the right and bottom boundaries are exclusive.

Valid for scalar or array x and y.

sheetcoordinates_of_matrixidx()

Return x,y where x is a vector of sheet coordinates representing the x-center of each matrix cell, and y represents the corresponding y-center of the cell.

sheetcoords_of_idx_grid()

Return an array of x-coordinates and an array of y-coordinates corresponding to the activity matrix of the sheet.

start()

Called by the simulation when the EventProcessor is added to the simulation.

If an EventProcessor needs to have any code run when it is added to the simulation, the code can be put into this method in the subclass.

state_pop()[source]

Subclasses Sheet state_pop to also pop projection activities.

state_push()[source]

Subclasses Sheet state_push to also push projection activities.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

xdensity

The spacing between elements in an underlying matrix representation, in the x direction.

ydensity

The spacing between elements in an underlying matrix representation, in the y direction.

class topo.base.projection.SheetMask(sheet=None, **params)[source]

Bases: param.parameterized.Parameterized

An abstract class that defines a mask over a ProjectionSheet object.

This class is typically used for optimization, where mask indicates which neurons are active and should be processed further. A mask can also be used for lesion experiments, to specify which units should be kept inactive.

See the code for CFProjection and CFResponseFn to see how this class can be used to restrict the computation to only those neurons that the Mask lists as active.

calculate()[source]

Calculate a new mask based on the activity of the sheet.

For instance, in an algorithm like LISSOM that is based on a process of feedforward activation followed by lateral settling, the calculation is done at the beginning of each iteration after the feedforward activity has been calculated.

Subclasses should override this method to compute some non-default mask.

data

Ensure that whenever somebody accesses the data they are not None.

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2b07aa44fdb8>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2b07aa44faf8>
inspect_value = <functools.partial object at 0x2b07aa44ff18>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

reset()[source]

Initialize mask to default value (with no neurons masked out).

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2b07aa4e8890>
set_param = <functools.partial object at 0x2b07aa4e82b8>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

update()[source]

Update the current mask based on the current activity and a previous mask.

Should be called only if calculate() has already been called since the last reset(); potentially faster to compute than redoing the entire calculate().

Subclasses should override this method to compute some non-default mask.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.


sheet Module

Inheritance diagram of topo.base.sheet

Neural sheet objects and associated functions.

The Sheet class is the base class for EventProcessors that simulate topographically mapped sheets of units (neurons or columns). A Sheet is an EventProcessor that maintains a rectangular array of activity values, and sends the contents of this array as the data element in events.

The Sheet itself is a SheetCoordinateSystem, so that units may be accessed by sheet or matrix coordinates. In general, however, sheets should be thought of as having arbitrary density and sheet coordinates should be used wherever possible, except when the code needs direct access to a specific unit. By adhering to this convention, one should be able to write and debug a simulation at a low density, and then scale it up to run at higher densities (or down for lower densities) simply by changing e.g. Sheet.nominal_density.

class topo.base.sheet.Sheet(**params)[source]

Bases: topo.base.simulation.EventProcessor, holoviews.core.sheetcoords.SheetCoordinateSystem

The generic base class for neural sheets.

See SheetCoordinateSystem for how Sheet represents space, and EventProcessor for how Sheet handles time.

output_fns are functions that take an activity matrix and produce an identically shaped output matrix. The default is having no output_fns.

param Boolean apply_output_fns (allow_None=False, bounds=(0, 1), constant=False, default=True, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Whether to apply the output_fn after computing an Activity matrix.
param Number precedence (allow_None=False, bounds=None, constant=False, default=0.1, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
Allows a sorting order for Sheets, e.g. in the GUI.
param BoundingRegionParameter nominal_bounds (allow_None=False, constant=True, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
User-specified BoundingBox of the Sheet coordinate area covered by this Sheet. The left and right bounds–if specified–will always be observed, but the top and bottom bounds may be adjusted to ensure the density in the y direction is the same as the density in the x direction. In such a case, the top and bottom bounds are adjusted so that the center y point remains the same, and each bound is as close as possible to its specified value. The actual value of this Parameter is not adjusted, but the true bounds may be found from the ‘bounds’ attribute of this object.
param Number row_precedence (allow_None=False, bounds=None, constant=False, default=0.5, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
Allows grouping of Sheets before sorting precedence is applied, e.g. for two-dimensional plots in the GUI.
param Boolean plastic (allow_None=False, bounds=(0, 1), constant=False, default=True, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Setting this to False tells the Sheet not to change its permanent state (e.g. any connection weights) based on incoming events.
param Number nominal_density (allow_None=False, bounds=None, constant=True, default=10, inclusive_bounds=(True, True), instantiate=True, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
User-specified number of processing units per 1.0 distance horizontally or vertically in Sheet coordinates. The actual number may be different because of discretization; the matrix needs to tile the plane exactly, and for that to work the density might need to be adjusted. For instance, an area of 3x2 cannot have a density of 2 in each direction. The true density may be obtained from either the xdensity or ydensity attribute (since these are identical for a Sheet).
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
Output function(s) to apply (if apply_output_fns is true) to this Sheet’s activity.
param NumericTuple layout_location (allow_None=False, constant=False, default=(-1, -1), instantiate=False, length=2, pickle_default_value=True, precedence=-1, readonly=False)
Location for this Sheet in an arbitrary pixel-based space in which Sheets can be laid out for visualization.
param Dict properties (allow_None=False, constant=False, default={}, instantiate=True, is_instance=True, pickle_default_value=True, precedence=None, readonly=False)
A dictionary of property values associated with the Sheet object. For instance, the dictionary: {‘polarity’:’ON’, ‘eye’:’Left’} could be used to indicate a left, LGN Sheet with ON-surround receptive fields.
activate()[source]

Collect activity from each projection, combine it to calculate the activity for this sheet, and send the result out.

Subclasses will need to override this method to whatever it means to calculate activity in that subclass.

activity_len()[source]

Return the number of items that have been saved by state_push().

closest_cell_center(x, y)

Given arbitary sheet coordinates, return the sheet coordinates of the center of the closest unit.

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

density

The sheet’s true density (i.e. the xdensity, which is equal to the ydensity for a Sheet.)

force_new_dynamic_value = <functools.partial object at 0x2b07ab47ab50>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2b07ab47ad08>
input_event(conn, data)

Called by the simulation when an EPConnectionEvent is delivered; the EventProcessor should process the data somehow.

inspect_value = <functools.partial object at 0x2b07ab47adb8>
matrix2sheet(float_row, float_col)

Convert a floating-point location (float_row,float_col) in matrix coordinates to its corresponding location (x,y) in sheet coordinates.

Valid for scalar or array float_row and float_col.

Inverse of sheet2matrix().

matrixidx2sheet(row, col)

Return (x,y) where x and y are the floating point coordinates of the center of the given matrix cell (row,col). If the matrix cell represents a 0.2 by 0.2 region, then the center location returned would be 0.1,0.1.

NOTE: This is NOT the strict mathematical inverse of sheet2matrixidx(), because sheet2matrixidx() discards all but the integer portion of the continuous matrix coordinate.

Valid only for scalar or array row and col.

message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

n_bytes()[source]

Return a lower bound for the memory taken by this sheet, in bytes.

Typically, this number will include the activity array and any similar arrays, plus any other significant data owned (in some sense) by this Sheet. 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.

Subclasses should reimplement this method if they store a significant amount of data other than in the activity array.

override_plasticity_state(new_plasticity_state)[source]

Temporarily override plasticity of medium and long term internal state.

This function should be implemented by all subclasses so that it preserves the ability of the Sheet to compute activity, i.e. to operate over a short time scale, while preventing any lasting changes to the state (if new_plasticity_state=False).

Any operation 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, simply saves a copy of the plastic flag to an internal stack (so that it can be restored by restore_plasticity_state()), and then sets plastic to new_plasticity_state.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

process_current_time()

Called by the simulation before advancing the simulation time. Allows the event processor to do any computation that requires that all events for this time have been delivered. Computations performed in this method should not generate any events with a zero time delay, or else causality could be violated. (By default, does nothing.)

release_sheet_view(view_name)[source]

Delete the dictionary entry with key entry ‘view_name’ to save memory.

restore_plasticity_state()[source]

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.

row_col_sheetcoords()[source]

Return an array of Y-coordinates corresponding to the rows of the activity matrix of the sheet, and an array of X-coordinates corresponding to the columns.

script_repr(imports=, []prefix=' ')

Generate a runnable command for creating this EventProcessor.

send_output(src_port=None, data=None)

Send some data out to all connections on the given src_port. The data is deepcopied before it is sent out, to ensure that future changes to the data are not reflected in events from the past.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2b07ab47ae68>
set_param = <functools.partial object at 0x2b07ab47af18>
sheet2matrix(x, y)

Convert a point (x,y) in Sheet coordinates to continuous matrix coordinates.

Returns (float_row,float_col), where float_row corresponds to y, and float_col to x.

Valid for scalar or array x and y.

Note about Bounds For a Sheet with BoundingBox(points=((-0.5,-0.5),(0.5,0.5))) and density=3, x=-0.5 corresponds to float_col=0.0 and x=0.5 corresponds to float_col=3.0. float_col=3.0 is not inside the matrix representing this Sheet, which has the three columns (0,1,2). That is, x=-0.5 is inside the BoundingBox but x=0.5 is outside. Similarly, y=0.5 is inside (at row 0) but y=-0.5 is outside (at row 3) (it’s the other way round for y because the matrix row index increases as y decreases).

sheet2matrixidx(x, y)

Convert a point (x,y) in sheet coordinates to the integer row and column index of the matrix cell in which that point falls, given a bounds and density. Returns (row,column).

Note that if coordinates along the right or bottom boundary are passed into this function, the returned matrix coordinate of the boundary will be just outside the matrix, because the right and bottom boundaries are exclusive.

Valid for scalar or array x and y.

sheetcoordinates_of_matrixidx()

Return x,y where x is a vector of sheet coordinates representing the x-center of each matrix cell, and y represents the corresponding y-center of the cell.

sheetcoords_of_idx_grid()[source]

Return an array of x-coordinates and an array of y-coordinates corresponding to the activity matrix of the sheet.

start()

Called by the simulation when the EventProcessor is added to the simulation.

If an EventProcessor needs to have any code run when it is added to the simulation, the code can be put into this method in the subclass.

state_pop()[source]

Pop the most recently saved state off the stack.

See state_push() for more details.

state_push()[source]

Save the current state of this sheet to an internal stack.

This method is used by operations that need to test the response of the sheet without permanently altering its state, e.g. for measuring maps or probing the current behavior non-invasively. By default, only the activity pattern of this sheet is saved, but subclasses should add saving for any additional state that they maintain, or strange bugs are likely to occur. The state can be restored using state_pop().

Note that Sheets that do learning need not save the values of all connection weights, if any, because plasticity can be turned off explicitly. Thus this method is intended only for shorter-term state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

xdensity

The spacing between elements in an underlying matrix representation, in the x direction.

ydensity

The spacing between elements in an underlying matrix representation, in the y direction.


sheetview Module

Inheritance diagram of topo.base.sheetview

Topographica SheetView objects and its subclasses.

For use with the Topographica plotting and data analysis mechanisms. A Sheet object has its internal data which remains hidden, but it will create views of this data depending on the Sheet defaults or the information requested. This way there can be multiple views recorded for a single sheet, and a view can be passed around independent of the originating source object.

class topo.base.sheetview.SheetView((data, bounds), src_name=None, precedence=0.0, timestamp=-1, row_precedence=0.5, **params)[source]

Bases: param.parameterized.Parameterized

Class provided for backward compatibility with earlier SheetView component.

param Number precedence (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)

param Boolean cyclic (allow_None=False, bounds=(0, 1), constant=False, default=False, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
If cyclic is True, this value is the cyclic range.
param Number timestamp (allow_None=True, bounds=None, constant=False, default=None, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
The initial timestamp. If None, the SheetView will not all slicing of a time interval and record method will be disabled.

param Number row_precedence (allow_None=False, bounds=None, constant=False, default=0.5, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)

param Parameter bounds (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
The bounds of the two dimensional coordinate system in which the data resides.

param String src_name (allow_None=True, basestring=<type ‘basestring’>, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)

param Parameter cyclic_range (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2b07abec5208>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2b07abec51b0>
inspect_value = <functools.partial object at 0x2b07abec52b8>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2b07abec5260>
set_param = <functools.partial object at 0x2b07abec53c0>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

view()[source]

Return the requested view as a (data, bbox) tuple. Provided for backward compatibility with the original Topographica SheetView model. It is now easier to access the data and bounds attributes directly.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

topo.base.sheetview.UnitView((data, bounds), x, y, projection, timestamp, **params)[source]

Function for backward compatibility with earlier UnitView component. Original docstring for UnitView:

Consists of an X,Y position for the unit that this View is created for. Returns an appropriately defined SheetView.

UnitViews should be stored in Sheets via a tuple (‘Weights’,Sheet,Projection,X,Y). The dictionary in Sheets can be accessed by any valid key.


simulation Module

Inheritance diagram of topo.base.simulation

A general-purpose Simulation class for discrete events.

The Simulation object is the central object of a simulation. It handles the simulation clock time and maintains communication between the components of the simulation.

A simulation is structured as a directed graph of event-processing nodes called EventProcessors (EPs). EventProcessors generate data-carrying Events, which are routed through the graph to other EventProcessors via delayed connections. Most objects in the simulation will be a subclass of EventProcessor, customized to provide some specific behavior.

There are different subclasses of Event, each doing different types of computation, and each can contain any arbitrary Python data. A simulation begins by giving each EventProcessor an opportunity to send any initial events. It then proceeds by processing and delivering events to EventProcessors in time order. After all events for the current time are processed, the simulation gives each EventProcessor a chance to do any final computation, after which simulation time skips to the time of the earliest event remaining in the queue.

PORTS

All connections between EPs are tagged with a source port and a destination port. Ports are internal addresses that EPs can use to distinguish between inputs and outputs. A port specifier can be any hashable Python object. If not specified, the input and output ports for a connection default to None.

src_ports distinguish different types of output that an EP may produce. When sending output, the EP must call self.send_output() separately for each port. dest_ports distinguish different types of input an EP may receive and process. The EP is free to interpret the input port designation on an incoming event in any way it chooses.

An example dest_port might be for an EP that receives ‘ordinary’ neural activity on the default port, and receives a separate modulatory signal that influences learning. The originator of the modulatory signal might have a connection to the EP with dest_port = ‘Modulation’. Multiple ports can be grouped by a dest EP by assuming a convention that the keys are tuples, e.g. (‘JointNormalize’,’Group1’), (‘JointNormalize’,’Group2’).

An example src_port use might be an EP that sends different events to itself than it sends out to other EPs. In this case the self connections might have src_port = ‘Recurrent’, and probably also a special dest_port.

class topo.base.simulation.CommandEvent(time, command_string)[source]

Bases: topo.base.simulation.Event

An Event consisting of a command string to execute.

script_repr(imports=, []prefix=' ')[source]

Generate a runnable command for creating this CommandEvent.

class topo.base.simulation.EPConnection(**params)[source]

Bases: param.parameterized.Parameterized

EPConnection stores basic information for a connection between two EventProcessors.

param Parameter src (allow_None=True, constant=True, default=None, instantiate=True, pickle_default_value=True, precedence=0.1, readonly=False)
The EventProcessor from which messages originate.
param Parameter src_port (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False)
Identifier that can be used to distinguish different types of outgoing connections. EventProcessors that generate only a single type of outgoing event will typically use a src_port of None. However, if multiple types of communication are meaningful, the EventProcessor can accept other values for src_port. It is up to the src EventProcessor to deliver appropriate data to each port, and to declare what will be sent over that port.
param Parameter dest (allow_None=True, constant=True, default=None, instantiate=True, pickle_default_value=True, precedence=0.11, readonly=False)
The EventProcessor to which messages are delivered.
param Boolean private (allow_None=False, bounds=(0, 1), constant=False, default=False, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Set to true if this connection is for internal use only, not to be manipulated by a user.
param Number delay (allow_None=False, bounds=(0, None), constant=False, default=0.05, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
Simulation time between generation of an Event by the src and delivery to the dest. Should normally be nonzero, to represent a causal with a well-defined ordering of events.
param Parameter dest_port (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False)
Identifier that can be used to distinguish different types of incoming connections. EventProcessors that accept only a single type of incoming event will typically use a src_port of None. However, if multiple types of communication are meaningful, the EventProcessor can accept other values for dest_port. It is up to the dest EventProcessor to process the data appropriately for each port, and to define what is expected to be sent to that port.
debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2b07aa049d08>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2b07aa049e10>
inspect_value = <functools.partial object at 0x2b07aa049e68>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

remove()[source]

Remove this connection from its src’s list of out_connections and its dest’s list of in_connections.

script_repr(imports=, []prefix=' ')[source]

Generate a runnable command for creating this connection.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2b07aacb42b8>
set_param = <functools.partial object at 0x2b07aacb4310>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class topo.base.simulation.EPConnectionEvent(time, conn, data=None, deep_copy=True)[source]

Bases: topo.base.simulation.Event

An Event for delivery to an EPConnection.

Provides access to a data field, which can be used for anything the src wants to provide, and a link to the connection over which it has arrived, so that the dest can determine what to do with the data.

By default, the data is deepcopied before being added to this instance for safety (e.g. so that future changes to data structures do not affect messages arriving from the past). However, if you can ensure that the copying is not necessary (e.g. if you deepcoy before sending a set of identical messages), then you can pass deep_copy=False to avoid the copy.

class topo.base.simulation.Event(time)[source]

Bases: object

Hierarchy of classes for storing simulation events of various types.

class topo.base.simulation.EventProcessor(**params)[source]

Bases: param.parameterized.Parameterized

Base class for EventProcessors, i.e. objects that can accept and handle events. This base class handles the basic mechanics of connections and sending events, and stores both incoming and outgoing connections.

The dest_ports attribute specifies which dest_ports are supported by this class; subclasses can augment or change this list if they wish. The special value dest_ports=None means to accept connections to any dest_port, while dest_ports=[None,’Trigger’] means that only connections to port None or port ‘Trigger’ are accepted.

Similarly, the src_ports attribute specifies which src_ports will be given output by this class.

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2b07aa049a48>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2b07aa049b50>
input_event(conn, data)[source]

Called by the simulation when an EPConnectionEvent is delivered; the EventProcessor should process the data somehow.

inspect_value = <functools.partial object at 0x2b07ab54b0a8>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

process_current_time()[source]

Called by the simulation before advancing the simulation time. Allows the event processor to do any computation that requires that all events for this time have been delivered. Computations performed in this method should not generate any events with a zero time delay, or else causality could be violated. (By default, does nothing.)

script_repr(imports=, []prefix=' ')[source]

Generate a runnable command for creating this EventProcessor.

send_output(src_port=None, data=None)[source]

Send some data out to all connections on the given src_port. The data is deepcopied before it is sent out, to ensure that future changes to the data are not reflected in events from the past.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2b07ab54b520>
set_param = <functools.partial object at 0x2b07ab54b578>
start()[source]

Called by the simulation when the EventProcessor is added to the simulation.

If an EventProcessor needs to have any code run when it is added to the simulation, the code can be put into this method in the subclass.

state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

topo.base.simulation.EventProcessorParameter[source]

Parameter whose value can be any EventProcessor instance.

class topo.base.simulation.EventSequence(time, sequence)[source]

Bases: topo.base.simulation.Event

Event that contains a sequence of other events to be scheduled and executed.

The .time attributes of the events in the sequence are interpreted as offsets relative to the start time of the sequence itself.

class topo.base.simulation.FunctionEvent(time, fn, *args, **kw)[source]

Bases: topo.base.simulation.Event

Event that executes a given function function(*args,**kw).

class topo.base.simulation.PeriodicEventSequence(time, period, sequence)[source]

Bases: topo.base.simulation.EventSequence

An EventSequence that reschedules itself periodically

Takes a period argument that determines how often the sequence will be scheduled. If the length of the sequence is longer than the period, then the length of the sequence will be used as the period.

class topo.base.simulation.RealTimeSimulation(**params)[source]

Bases: topo.base.simulation.Simulation

A (quasi) real-time simulation object.

This subclass of Simulation attempts to maintain a correspondence between simulation time and real time, as defined by the timescale parameter. Real time simulation instances still maintain a nominal, discrete simulation time that determines the order of event delivery.

At the beginning of each simulation time epoch, the simulation marks the actual wall clock time. After event delivery for that epoch has ended, the simulation calculates the amount of computation time used for event processing, and executes a real sleep for the remainder of the epoch. If the computation time for the epoch exceeded the real time, a warning is issued and processing proceeds immediately to the next simulation time epoch.

RUN HOOKS

The simulation includes as parameters two lists of functions/callables, run_start_hooks and run_stop_hooks, that will be called immediately before and after event processing during a call to .run(). This allows, for example, starting and stopping of real-time devices that might use resources while the simulation is not running.

param HookList run_start_hooks (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
A list of callable objects to be called on entry to .run(), before any events are processed.
param String time_printing_format (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=%(_time)09.2f, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Format string to be used when the simulation time must be formatted as a string, e.g. for display or for basename(). When the string is evaluated, the time will be available as the attribute ‘_time’.
param Number timescale (allow_None=False, bounds=(0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
The desired real length of one simulation time unit, in milliseconds.
param Boolean register (allow_None=False, bounds=(0, 1), constant=True, default=True, instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
Whether or not to register this Simulation. If True, this Simulation (when created explicitly or when unpickled) will replace any existing registered Simulation (if one exists). Thus only one Simulation with register=True can exist at any one time, which makes it simpler to handle defining and reloading a series of simulations without polluting the memory space with unused simulations.
param String basename_format (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=%(name)s_%(timestr)s, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Format string to be used by the basename() function. When the string is evaluated, the formatted time from time_printing_format will be available as the attribute ‘timestr’.
param Callable time (allow_None=False, constant=False, default=<Time Time00001>, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
The time object is a callable that can be set, incremented and decremented with a chosen numeric type as necessary.
param Parameter startup_commands (allow_None=False, constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
List of string commands that will be exec’d in __main__.__dict__ (i.e. as if they were entered at the command prompt) every time this simulation is unpickled (and will be executed before the simulation is itself unpickled). For example, allows items to be imported before scheduled_commands are run.
param HookList run_stop_hooks (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
A list of callable objects to be called on exit from .run() after all events are processed.
basename()

Return a string suitable for labeling an object created by the current simulation at the current time. By default this is simply the name of the simulation + ” ” + the result from evaluating the time_printing_format parameter.

connect(src, dest, connection_type=<class 'topo.base.simulation.EPConnection'>, **conn_params)

Connect the src EventProcessor to the dest EventProcessor.

The src and dest should be string names of existing EPs. Returns the connection that was created. If the connection hasn’t been given a name, it defaults to ‘srcTodest’.

connections()

Return a list of all unique connections to or from any object.

convert_to_time_type(time)

Convert the supplied time to the Simulation’s time_type.

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

enqueue_event(event)

Enqueue an Event at an absolute simulation clock time.

event_clear(event_type=<class 'topo.base.simulation.EPConnectionEvent'>)

Clear out all scheduled events of the specified type.

For instance, with event_type=EPConnectionEvent, this function can be used to ensure that no pending EPConnectionEvents will remain on the queue during some analysis or measurement operation. One will usually want to do a state_push before using this function, then clear out the events that should be deleted, do the measurement or analysis, and then do state_pop to restore the original state.

event_pop()

Pop the most recently saved events queue off the stack.

Same as state_pop(), but does not restore EventProcessors’ state.

event_push()

Save a copy of the events queue for later restoration.

Same as state_push(), but does not ask EventProcessors to save their state.

force_new_dynamic_value = <functools.partial object at 0x2b07ab54b368>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2b07ab54b520>
grid_layout(objgrid, xstart=100, xstep=150, ystart=100, ystep=150, item_scale=1.0)

Set the layout_location of simulation objects in a grid pattern.

Takes a list of lists of simulation objects, or names of simulation objects, and positions them with layout_locations left-to-right, top-to-bottom, starting at (xstart,ystart) and advancing by xstep and ystep.

The object None can be placed in the grid to skip a grid space.

inspect_value = <functools.partial object at 0x2b07ab54b4c8>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

objects(baseclass=<class 'topo.base.simulation.EventProcessor'>)

Return a dictionary of simulation objects having the specified base class. All simulation objects have a base class of EventProcessor, and so the baseclass must be either EventProcessor or one of its subclasses.

If there is a simulator called s, you can type e.g. s.objects().keys() to see a list of the names of all objects.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

schedule_command(times, command_string)

Add a command to execute in __main__.__dict__ at the specified time.

The command should be a string and times may be either a single time value or a list of times.

script_repr(imports=, []prefix=' ')

Return a nearly runnable script recreating this simulation.

Needs some work to make the result truly runnable.

Only scheduled commands that have not yet been executed are included, because executed commands are not kept around.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2b07ab54baa0>
set_param = <functools.partial object at 0x2b07ab54baf8>
sleep(delay)[source]

Sleep for the number of real milliseconds seconds corresponding to the given delay, subtracting off the amount of time elapsed since the last sleep.

state_pop()

Pop the most recently saved state off the stack.

See state_push() for more details.

state_push()

Save a copy of the current state of the simulation for later restoration.

The saved copy includes all the events on the simulator stack (saved using event_push()). Each EventProcessor is also asked to save its own state. This operation is useful for testing something while being able to roll back to the original state.

timestr(specified_time=None)

Returns the specified time (or the current time, if none specified) formatted using time.time_printing_format, which allows users to control how much precision, etc. is used for time displays.

timestr_prop

A property that simply returns self.timestr(); useful for setting the interactive command-line prompt.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class topo.base.simulation.Simulation(*args, **params)[source]

Bases: param.parameterized.Parameterized, topo.base.simulation.OptionalSingleton

A simulation class that uses a simple sorted event list (instead of e.g. a sched.scheduler object) to manage events and dispatching.

Simulation is a singleton: there is only one instance of Simulation, no matter how many times it is instantiated.

param String time_printing_format (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=%(_time)09.2f, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Format string to be used when the simulation time must be formatted as a string, e.g. for display or for basename(). When the string is evaluated, the time will be available as the attribute ‘_time’.
param Boolean register (allow_None=False, bounds=(0, 1), constant=True, default=True, instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
Whether or not to register this Simulation. If True, this Simulation (when created explicitly or when unpickled) will replace any existing registered Simulation (if one exists). Thus only one Simulation with register=True can exist at any one time, which makes it simpler to handle defining and reloading a series of simulations without polluting the memory space with unused simulations.
param String basename_format (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=%(name)s_%(timestr)s, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Format string to be used by the basename() function. When the string is evaluated, the formatted time from time_printing_format will be available as the attribute ‘timestr’.
param Callable time (allow_None=False, constant=False, default=<Time Time00001>, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
The time object is a callable that can be set, incremented and decremented with a chosen numeric type as necessary.
param Parameter startup_commands (allow_None=False, constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
List of string commands that will be exec’d in __main__.__dict__ (i.e. as if they were entered at the command prompt) every time this simulation is unpickled (and will be executed before the simulation is itself unpickled). For example, allows items to be imported before scheduled_commands are run.
basename()[source]

Return a string suitable for labeling an object created by the current simulation at the current time. By default this is simply the name of the simulation + ” ” + the result from evaluating the time_printing_format parameter.

connect(src, dest, connection_type=<class 'topo.base.simulation.EPConnection'>, **conn_params)[source]

Connect the src EventProcessor to the dest EventProcessor.

The src and dest should be string names of existing EPs. Returns the connection that was created. If the connection hasn’t been given a name, it defaults to ‘srcTodest’.

connections()[source]

Return a list of all unique connections to or from any object.

convert_to_time_type(time)[source]

Convert the supplied time to the Simulation’s time_type.

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

enqueue_event(event)[source]

Enqueue an Event at an absolute simulation clock time.

event_clear(event_type=<class 'topo.base.simulation.EPConnectionEvent'>)[source]

Clear out all scheduled events of the specified type.

For instance, with event_type=EPConnectionEvent, this function can be used to ensure that no pending EPConnectionEvents will remain on the queue during some analysis or measurement operation. One will usually want to do a state_push before using this function, then clear out the events that should be deleted, do the measurement or analysis, and then do state_pop to restore the original state.

event_pop()[source]

Pop the most recently saved events queue off the stack.

Same as state_pop(), but does not restore EventProcessors’ state.

event_push()[source]

Save a copy of the events queue for later restoration.

Same as state_push(), but does not ask EventProcessors to save their state.

force_new_dynamic_value = <functools.partial object at 0x2b07ab54b310>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2b07ab54b418>
grid_layout(objgrid, xstart=100, xstep=150, ystart=100, ystep=150, item_scale=1.0)[source]

Set the layout_location of simulation objects in a grid pattern.

Takes a list of lists of simulation objects, or names of simulation objects, and positions them with layout_locations left-to-right, top-to-bottom, starting at (xstart,ystart) and advancing by xstep and ystep.

The object None can be placed in the grid to skip a grid space.

inspect_value = <functools.partial object at 0x2b07ab54b470>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

objects(baseclass=<class 'topo.base.simulation.EventProcessor'>)[source]

Return a dictionary of simulation objects having the specified base class. All simulation objects have a base class of EventProcessor, and so the baseclass must be either EventProcessor or one of its subclasses.

If there is a simulator called s, you can type e.g. s.objects().keys() to see a list of the names of all objects.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

run(duration=Infinity(), until=Infinity())[source]

Process simulation events for the specified duration or until the specified time.

Arguments:

duration = length of simulation time to run. Default: run indefinitely while there are still events in the event_queue.

until = maximum simulation time to simulate. Default: run indefinitely while there are still events in the event queue.

If both duration and until are used, the one that is reached first will apply.

Note that duration and until should be specified in a format suitable for conversion (coercion?) into the Simulation’s _time_type.

schedule_command(times, command_string)[source]

Add a command to execute in __main__.__dict__ at the specified time.

The command should be a string and times may be either a single time value or a list of times.

script_repr(imports=, []prefix=' ')[source]

Return a nearly runnable script recreating this simulation.

Needs some work to make the result truly runnable.

Only scheduled commands that have not yet been executed are included, because executed commands are not kept around.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2b07ab54bba8>
set_param = <functools.partial object at 0x2b07ab54bcb0>
sleep(delay)[source]

Advance the simulator time by the specified amount. By default simply increments the _time value, but subclasses can override this method as they wish, e.g. to wait for an external real time clock to advance first.

state_pop()[source]

Pop the most recently saved state off the stack.

See state_push() for more details.

state_push()[source]

Save a copy of the current state of the simulation for later restoration.

The saved copy includes all the events on the simulator stack (saved using event_push()). Each EventProcessor is also asked to save its own state. This operation is useful for testing something while being able to roll back to the original state.

timestr(specified_time=None)[source]

Returns the specified time (or the current time, if none specified) formatted using time.time_printing_format, which allows users to control how much precision, etc. is used for time displays.

timestr_prop[source]

A property that simply returns self.timestr(); useful for setting the interactive command-line prompt.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class topo.base.simulation.SomeTimer(**params)[source]

Bases: param.parameterized.Parameterized

Provides a countdown timer for functions that run repeatedly.

There are two distinct ways to use the timer.

The first, via call_and_time(), is for calling some function every specified number of steps for a specified duration. Currently call_and_time() is used for timing calls to simulation.run() every 1.0 steps for 100 iterations. See the Simulation class for an example of using the timer in this way.

The second, via call_fixed_num_times(), is for calling some function repeatedly a specified number of times. A case to use call_fixed_num_times() would be timing pattern presentations, where the number of times the pattern_presenter will be called is known in advance. Additionally, this method allows a list of arguments to be passed to the function (in this case, the permutation for each call).

param Parameter real_time_fn (allow_None=False, constant=False, default=<built-in function time>, instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
Function that returns the wallclock time.
param Number estimate_interval (allow_None=False, bounds=None, constant=False, default=50, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=True, time_fn=<Time Time00001>)
Interval in simulation time between estimates.
param Boolean stop (allow_None=False, bounds=(0, 1), constant=False, default=False, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
If set to True, execution of func (and timing) will cease at the end of the current iteration.
param Parameter simulation_time_fn (allow_None=True, constant=False, default=None, instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
Function that returns the simulation time.
param Parameter step (allow_None=False, constant=False, default=2, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Only relevant with call_and_time(), not call_fixed_num_times(). Each iteration, func is called as func(step). For example, step=1 with func set to topo.sim.time would cause the simulation time to advance once per iteration. The default value (None) gives 50 iterations for any value of simulation_duration passed to call_and_time(simulation_duration).
param Parameter func (allow_None=True, constant=False, default=None, instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
Function to be timed.
param Parameter receive_info (allow_None=False, constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
List of objects that will receive timing information. Each must have a timing_info() method.
call_and_time(fduration)[source]

Call self.func(self.step or fduration/50.0) for fduration.

call_fixed_num_times(args_for_iterations)[source]

Call self.func(args_for_iterations[i]) for all i in args_for_iterations.

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2b07ab54b100>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2b07ab54b368>
inspect_value = <functools.partial object at 0x2b07ab54b310>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

real_time_fn()

time() -> floating point number

Return the current time in seconds since the Epoch. Fractions of a second may be present if the system clock provides them.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2b07ab54b838>
set_param = <functools.partial object at 0x2b07ab54b5d0>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.