Skip to content

add_sample_class_mlpAddSampleClassMlpAddSampleClassMlpadd_sample_class_mlpT_add_sample_class_mlp🔗

Short description🔗

add_sample_class_mlpAddSampleClassMlpAddSampleClassMlpadd_sample_class_mlpT_add_sample_class_mlp — Add a training sample to the training data of a multilayer perceptron.

Signature🔗

add_sample_class_mlp( class_mlp MLPHandle, real Features, number Target )void AddSampleClassMlp( const HTuple& MLPHandle, const HTuple& Features, const HTuple& Target )static void HOperatorSet.AddSampleClassMlp( HTuple MLPHandle, HTuple features, HTuple target )def add_sample_class_mlp( mlphandle: HHandle, features: Sequence[float], target: MaybeSequence[Union[int, float]] ) -> None

Herror T_add_sample_class_mlp( const Htuple MLPHandle, const Htuple Features, const Htuple Target )

void HClassMlp::AddSampleClassMlp( const HTuple& Features, const HTuple& Target ) const

void HClassMlp::AddSampleClassMlp( const HTuple& Features, Hlong Target ) const

void HClassMlp.AddSampleClassMlp( HTuple features, HTuple target )

void HClassMlp.AddSampleClassMlp( HTuple features, int target )

Description🔗

add_sample_class_mlpAddSampleClassMlp adds a training sample to the multilayer perceptron (MLP) given by MLPHandleMLPHandlemlphandle. The training sample is given by Featuresfeaturesfeatures and Targettargettarget. Featuresfeaturesfeatures is the feature vector of the sample, and consequently must be a real vector of length NumInputnumInputnum_input, as specified in create_class_mlpCreateClassMlp. Targettargettarget is the target vector of the sample, which must have the length NumOutputnumOutputnum_output (see create_class_mlpCreateClassMlp) for all three types of activation functions of the MLP (exception: see below). If the MLP is used for regression (function approximation), i.e., if OutputFunctionoutputFunctionoutput_function \(=\) 'linear'"linear", Targettargettarget is the value of the function at the coordinate Featuresfeaturesfeatures. In this case, Targettargettarget can contain arbitrary real numbers. For OutputFunctionoutputFunctionoutput_function \(=\) 'logistic'"logistic", Targettargettarget can only contain the values 0.00.0 and 1.01.0. A value of 1.01.0 specifies that the attribute in question is present, while a value of 0.00.0 specifies that the attribute is absent. Because in this case the attributes are independent, arbitrary combinations of 0.00.0 and 1.01.0 can be passed. For OutputFunctionoutputFunctionoutput_function \(=\) 'softmax'"softmax", Targettargettarget also can only contain the values 0.00.0 and 1.01.0. In contrast to OutputFunctionoutputFunctionoutput_function \(=\) 'logistic'"logistic", the value 1.01.0 must be present for exactly one element of the tuple Targettargettarget. The location in the tuple designates the class of the sample. For ease of use, a single integer value may be passed if OutputFunctionoutputFunctionoutput_function \(=\) 'softmax'"softmax". This value directly designates the class of the sample, which is counted from 0, i.e., the class must be an integer between 0 and NumOutputnumOutputnum_output \(-\) 1. The class is converted to a target vector of length NumOutputnumOutputnum_output internally.

Before the MLP can be trained with train_class_mlpTrainClassMlp, all training samples must be added to the MLP with add_sample_class_mlpAddSampleClassMlp.

The number of currently stored training samples can be queried with get_sample_num_class_mlpGetSampleNumClassMlp. Stored training samples can be read out again with get_sample_class_mlpGetSampleClassMlp.

Normally, it is useful to save the training samples in a file with write_samples_class_mlpWriteSamplesClassMlp to facilitate reusing the samples, and to facilitate that, if necessary, new training samples can be added to the data set, and hence to facilitate that a newly created MLP can be trained anew with the extended data set.

Execution information🔗

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Processed without parallelization.

This operator modifies the state of the following input parameter:

During execution of this operator, access to the value of this parameter must be synchronized if it is used across multiple threads.

Parameters🔗

MLPHandleMLPHandlemlphandle (input_control, state is modified) class_mlp → (handle)HTuple (HHandle)HClassMlp, HTuple (IntPtr)HHandleHtuple (handle)

MLP handle.

Featuresfeaturesfeatures (input_control) real-array → (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Feature vector of the training sample to be stored.

Targettargettarget (input_control) number(-array) → (integer / real)HTuple (Hlong / double)HTuple (int / long / double)MaybeSequence[Union[int, float]]Htuple (Hlong / double)

Class or target vector of the training sample to be stored.

Result🔗

If the parameters are valid, the operator add_sample_class_mlpAddSampleClassMlp returns the value 2 (H_MSG_TRUE). If necessary, an exception is raised.

Combinations with other operators🔗

Combinations

Possible predecessors

create_class_mlpCreateClassMlp

Possible successors

train_class_mlpTrainClassMlp, write_samples_class_mlpWriteSamplesClassMlp

Alternatives

read_samples_class_mlpReadSamplesClassMlp

See also

clear_samples_class_mlpClearSamplesClassMlp, get_sample_num_class_mlpGetSampleNumClassMlp, get_sample_class_mlpGetSampleClassMlp

Module🔗

Foundation