# SelectionFunctions¶

Functions that selects a subset of elements to maintain or transform, while nulling the others.

class psyneulink.core.components.functions.selectionfunctions.SelectionFunction(default_variable, params, owner, prefs, context)

Functions that selects a particular value to maintain or transform, while nulling the others.

class psyneulink.core.components.functions.selectionfunctions.OneHot(default_variable, mode=MAX_VAL, params=None, owner=None, name=None, prefs=None)

Return an array with one non-zero value.

function returns an array the same length as the first item in variable, with all of its values zeroed except one as specified by mode:

• MAX_ABS_VAL: element with the maximum absolute value;
• MAX_INDICATOR: 1 in place of the element with the maximum signed value;
• MAX_ABS_INDICATOR: 1 in place of the element with the maximum absolute value;
• MIN_ABS_VAL: element with the minimum absolute value;
• MIN_INDICATOR: 1 in place of the element with the minimum signed value;
• MIN_ABS_INDICATOR: 1 in place of the element with the minimum absolute value;
• PROB: probabilistically chosen element based on probabilities passed in second item of variable;
• PROB_INDICATOR: same as PROB but chosen item is assigned a value of 1.
Parameters: variable (2d np.array : default class_defaults.variable) – First (possibly only) item specifies a template for the array to be transformed; if mode is PROB then a 2nd item must be included that is a probability distribution with same length as 1st item. mode (MAX_VAL, MAX_ABS_VAL, MAX_INDICATOR, MAX_ABS_INDICATOR, MIN_VAL, MIN_ABS_VAL, MIN_INDICATOR,) – PROB or PROB_INDICATOR (MIN_ABS_INDICATOR,) – specifies the nature of the single non-zero value in the array returned by function (see mode for details). 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. bounds (None) – 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

number or np.array – 1st item contains value to be transformed; if mode is PROB, 2nd item is a probability distribution, each element of which specifies the probability for selecting the corresponding element of the 1st item.

mode

MAX_VAL, MAX_ABS_VAL, MAX_INDICATOR, MAX_ABS_INDICATOR, MIN_VAL, MIN_ABS_VAL, MIN_INDICATOR,

MIN_ABS_INDICATOR, PROB or PROB_INDICATOR

determines the nature of the single non-zero value in the array returned by function (see above for options).

owner

Componentcomponent to which the Function has been assigned.

name

str – the name of the Function; if it is not specified in the name argument of the constructor, a default is assigned by FunctionRegistry (see Naming for conventions used for default and duplicate names).

prefs

PreferenceSet or specification dict : Function.classPreferences – the PreferenceSet for function; if it is not specified in the prefs argument of the Function’s constructor, a default is assigned using classPreferences defined in __init__.py (see PreferenceSet for details).

function(variable=None, execution_id=None, params=None, context=None)
Parameters: variable (2d np.array : default class_defaults.variable) – 1st item is an array to be transformed; if mode is PROB, 2nd item must be an array of probabilities (i.e., elements between 0 and 1) of equal length to the 1st item. 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. array with single non-zero value – specified by mode. np.array