ObjectiveFunctions

Functions that return a scalar evaluation of their input.

class psyneulink.core.components.functions.objectivefunctions.ObjectiveFunction(default_variable, params, function=None, owner=None, name=None, prefs=None, context=None)

Abstract class of Function used for evaluating states.

class psyneulink.core.components.functions.objectivefunctions.Stability(default_variable=None, matrix='HollowMatrix', metric: <typecheck.tc_predicates.any object at 0x1073ada90> = 'energy', transfer_fct: <typecheck.framework.optional object at 0x1073adb00> = None, normalize: bool = False, params=None, owner=None, prefs: <function is_pref_set at 0x104c13840> = None)

Stability( default_variable=None, matrix=HOLLOW_MATRIX, metric=ENERGY transfer_fct=None normalize=False, params=None, owner=None, prefs=None )

Return the stability of variable based on a state transformation matrix.

The value of variable is passed through the matrix, transformed using the transfer_fct (if specified), and then compared with its initial value using the distance metric specified by metric. If normalize is True, the result is normalized by the length of (number of elements in) variable.

variable : list of numbers or 1d np.array : Default class_defaults.variable
the array for which stability is calculated.
matrix : list, np.ndarray, np.matrix, function keyword, or MappingProjection : default HOLLOW_MATRIX
specifies the matrix of recurrent weights; must be a square matrix with the same width as the length of variable.
metric : keyword in DistanceMetrics : Default ENERGY
specifies a metric from DistanceMetrics used to compute stability.
transfer_fct : function or method : Default None
specifies the function used to transform output of weight matrix.
normalize : bool : Default False
specifies whether to normalize the stability value by the length of variable.
params : Dict[param keyword: param value] : default None
a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.
owner : Component
component to which to assign the Function.
name : str : default see name
specifies the name of the Function.
prefs : PreferenceSet or specification dict : default Function.classPreferences
specifies the PreferenceSet for the Function (see prefs for details).
variable : 1d np.array
array for which stability is calculated.
matrix : list, np.ndarray, np.matrix, function keyword, or MappingProjection : default HOLLOW_MATRIX
weight matrix from each element of variable to each other; if a matrix other than HOLLOW_MATRIX is assigned, it is convolved with HOLLOW_MATRIX to eliminate self-connections from the stability calculation.
metric : keyword in DistanceMetrics
metric used to compute stability; must be a DistanceMetrics keyword. The Distance Function is used to compute the stability of variable with respect to its value after its transformation by matrix and transfer_fct.
transfer_fct : function or method
function used to transform output of weight matrix prior to computing stability.
normalize : bool
if True, result of stability calculation is normalized by the length of variable.
params : Dict[param keyword: param value] : default None
a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.
owner : Component
component to which to assign the Function.
prefs : PreferenceSet or specification dict : default Function.classPreferences
specifies the PreferenceSet for the Function (see prefs for details).
function(variable=None, execution_id=None, params=None, context=None)

Calculate the stability of variable.

Compare the value of variable with its value after transformation by matrix and transfer_fct (if specified), using the specified metric. If normalize is True, the result is divided by the length of variable.

Returns:stability
Return type:scalar
class psyneulink.core.components.functions.objectivefunctions.Distance(default_variable=None, metric=EUCLIDEAN normalize=False, params=None, owner=None, prefs=None)

Return the distance between the vectors in the two items of variable using the distance metric specified in the metric attribute. If normalize is True, the result is normalized by the length of (number of elements in) variable.

Parameters:
  • variable (2d np.array with two items : Default class_defaults.variable) – the arrays between which the distance is calculated.
  • metric (keyword in DistancesMetrics : Default EUCLIDEAN) – specifies a distance metric used to compute the distance between the two items in variable.
  • normalize (bool : Default False) – specifies whether to normalize the distance by the length of variable.
  • params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.
  • owner (Component) – component to which to assign the Function.
  • name (str : default see name) – specifies the name of the Function.
  • prefs (PreferenceSet or specification dict : default Function.classPreferences) – specifies the PreferenceSet for the Function (see prefs for details).
variable

2d np.array with two items – contains the arrays between which the distance is calculated.

metric

keyword in DistanceMetrics – determines the metric used to compute the distance between the two items in variable.

normalize

bool – determines whether the distance is normalized by the length of variable.

params

Dict[param keyword: param value] : default None – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.

owner

Componentcomponent to which to assign the Function.

prefs

PreferenceSet or specification dict : default Function.classPreferences – specifies the PreferenceSet for the Function (see prefs for details).

function(variable=None, execution_id=None, params=None, context=None)

Calculate the distance between the two vectors in variable.

Use the distance metric specified in metric to calculate the distance. If normalize is True, the result is divided by the length of variable.

Returns:distance
Return type:scalar