def __init__(
            self,
            default_variable=None,
            size=None,
            function=Linear,
            # selection_function=OneHot(mode=MAX_INDICATOR),  # RE-INSTATE WHEN IMPLEMENT NHot function
            integrator_function=AdaptiveIntegrator,
            initial_value=None,
            noise: is_numeric_or_none = 0.0,
            integration_rate: is_numeric_or_none = 0.5,
            integrator_mode=False,
            clip=None,
            enable_learning=True,
            learning_rate: tc.optional(tc.any(parameter_spec, bool)) = None,
            learning_function: is_function_type = Kohonen(
                distance_function=GAUSSIAN),
            learned_projection: tc.optional(MappingProjection) = None,
            additional_output_ports: tc.optional(tc.any(str, Iterable)) = None,
            name=None,
            prefs: is_pref_set = None,
            **kwargs):
        # # Default output_ports is specified in constructor as a string rather than a list
        # # to avoid "gotcha" associated with mutable default arguments
        # # (see: bit.ly/2uID3s3 and http://docs.python-guide.org/en/latest/writing/gotchas/)
        # if output_ports is None:
        #     output_ports = [RESULT]

        output_ports = [
            RESULT, {
                NAME: INPUT_PATTERN,
                VARIABLE: OWNER_VARIABLE
            }
        ]
        if additional_output_ports:
            if isinstance(additional_output_ports, list):
                output_ports += additional_output_ports
            else:
                output_ports.append(additional_output_ports)

        self._learning_enabled = enable_learning
        self._learning_enable_deferred = False

        super().__init__(default_variable=default_variable,
                         size=size,
                         function=function,
                         integrator_function=integrator_function,
                         integrator_mode=integrator_mode,
                         learning_rate=learning_rate,
                         learning_function=learning_function,
                         learned_projection=learned_projection,
                         enable_learning=enable_learning,
                         initial_value=initial_value,
                         noise=noise,
                         integration_rate=integration_rate,
                         clip=clip,
                         output_ports=output_ports,
                         params=params,
                         name=name,
                         prefs=prefs,
                         **kwargs)
示例#2
0
    class Parameters(TransferMechanism.Parameters):
        """
            Attributes
            ----------

                enable_learning
                    see `enable_learning <KohonenMechanism.enable_learning>`

                    :default value: True
                    :type: ``bool``

                learning_function
                    see `learning_function <KohonenMechanism.learning_function>`

                    :default value: `Kohonen`
                    :type: `Function`

                learning_rate
                    see `learning_rate <KohonenMechanism.learning_rate>`

                    :default value: None
                    :type:

                matrix
                    see `matrix <KohonenMechanism.matrix>`

                    :default value: `AUTO_ASSIGN_MATRIX`
                    :type: ``str``

                output_ports
                    see `output_ports <KohonenMechanism.output_ports>`

                    :default value: [`RESULT`, "{name: INPUT_PATTERN, variable: OWNER_VARIABLE}"]
                    :type: ``list``
                    :read only: True
        """
        learning_function = Parameter(Kohonen(distance_function=GAUSSIAN),
                                      stateful=False,
                                      loggable=False,
                                      reference=True)
        learning_rate = Parameter(None, modulable=True)
        enable_learning = True
        matrix = DEFAULT_MATRIX

        output_ports = Parameter(
            [RESULT, {
                NAME: INPUT_PATTERN,
                VARIABLE: OWNER_VARIABLE
            }],
            stateful=False,
            loggable=False,
            read_only=True,
            structural=True,
        )
示例#3
0
    class Parameters(TransferMechanism.Parameters):
        """
            Attributes
            ----------

                enable_learning
                    see `enable_learning <KohonenMechanism.enable_learning>`

                    :default value: True
                    :type: bool

                learning_function
                    see `learning_function <KohonenMechanism.learning_function>`

                    :default value: `Kohonen`(distance_function=gaussian, learning_rate=0.05)
                    :type: `Function`

                learning_rate
                    see `learning_rate <KohonenMechanism.learning_rate>`

                    :default value: None
                    :type:

                matrix
                    see `matrix <KohonenMechanism.matrix>`

                    :default value: `AUTO_ASSIGN_MATRIX`
                    :type: str

        """
        learning_function = Parameter(Kohonen(distance_function=GAUSSIAN),
                                      stateful=False,
                                      loggable=False)

        learning_rate = Parameter(None, modulable=True)

        enable_learning = True
        matrix = DEFAULT_MATRIX