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 nonzero value.
function
returns an array the same length as the first item invariable
, with all of its values zeroed except one as specified bymode
: MAX_VAL: element with the maximum signed value in first item of
variable
;
 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_VAL: element with the minimum signed value in first item of
variable
;
 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 nonzero value in the array returned by
function
(seemode
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 (seeprefs
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 nonzero value in the array returned by
function
(see above for options).

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 usingclassPreferences
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.
Returns: array with single nonzero value – specified by
mode
.Return type: np.array
 variable (2d np.array : default class_defaults.variable) – 1st item is an array to be transformed; if
 MAX_VAL: element with the maximum signed value in first item of