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=None, name=None, prefs=None, context=None, **kwargs)¶
Functions that selects a particular value to maintain or transform, while nulling the others.
- class psyneulink.core.components.functions.selectionfunctions.OneHot(default_variable=None, mode=None, seed=None, params=None, owner=None, prefs=None)¶
Return an array with one non-zero value.
function
returns an array the same length as the first item invariable
, with all of its values zeroed except one identified in first itemvariable
as specified bymode
:MAX_VAL: signed value of the element with the maximum signed value;
MAX_ABS_VAL: absolute value of the 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: signed value of the element with the minimum signed value;
MIN_ABS_VAL: absolute value of 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: value of 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,) –
MIN_ABS_INDICATOR (default MAX_VAL) – specifies the nature of the single non-zero value in the array returned by
function
(seemode
for details).PROB_INDICATOR (PROB or) – specifies the nature of the single non-zero 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¶
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.- Type
number or np.array
- mode¶
- Type
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).
- random_state¶
private pseudorandom number generator
- Type
numpy.RandomState
- name¶
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).
- Type
str
- prefs¶
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 Preferences for details).- Type
PreferenceSet or specification dict : Function.classPreferences
- _validate_params(request_set, target_set=None, context=None)¶
Validate params and assign validated values to targets,
This performs top-level type validation of params
This can be overridden by a subclass to perform more detailed checking (e.g., range, recursive, etc.) It is called only if the parameter_validation attribute is
True
(which it is by default)- IMPLEMENTATION NOTES:
future versions should add recursive and content (e.g., range) checking
should method return validated param set?
- Parameters
validated (dict (target_set) - repository of params that have been) –
validated –
- Return none
- _function(variable=None, context=None, params=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 non-zero value – specified by
mode
.- Return type
np.array