Operator Reference

add_sample_class_mlpT_add_sample_class_mlpAddSampleClassMlpAddSampleClassMlpadd_sample_class_mlp (Operator)

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

Signature

add_sample_class_mlp( : : MLPHandle, Features, Target : )

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

void AddSampleClassMlp(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

static void HOperatorSet.AddSampleClassMlp(HTuple MLPHandle, HTuple features, HTuple target)

void HClassMlp.AddSampleClassMlp(HTuple features, HTuple target)

void HClassMlp.AddSampleClassMlp(HTuple features, int target)

def add_sample_class_mlp(mlphandle: HHandle, features: Sequence[float], target: MaybeSequence[Union[int, float]]) -> None

Description

add_sample_class_mlpadd_sample_class_mlpAddSampleClassMlpAddSampleClassMlpadd_sample_class_mlp adds a training sample to the multilayer perceptron (MLP) given by MLPHandleMLPHandleMLPHandleMLPHandlemlphandle. The training sample is given by FeaturesFeaturesFeaturesfeaturesfeatures and TargetTargetTargettargettarget. FeaturesFeaturesFeaturesfeaturesfeatures is the feature vector of the sample, and consequently must be a real vector of length NumInputNumInputNumInputnumInputnum_input, as specified in create_class_mlpcreate_class_mlpCreateClassMlpCreateClassMlpcreate_class_mlp. TargetTargetTargettargettarget is the target vector of the sample, which must have the length NumOutputNumOutputNumOutputnumOutputnum_output (see create_class_mlpcreate_class_mlpCreateClassMlpCreateClassMlpcreate_class_mlp) 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 OutputFunctionOutputFunctionOutputFunctionoutputFunctionoutput_function = 'linear'"linear""linear""linear""linear", TargetTargetTargettargettarget is the value of the function at the coordinate FeaturesFeaturesFeaturesfeaturesfeatures. In this case, TargetTargetTargettargettarget can contain arbitrary real numbers. For OutputFunctionOutputFunctionOutputFunctionoutputFunctionoutput_function = 'logistic'"logistic""logistic""logistic""logistic", TargetTargetTargettargettarget can only contain the values 0.0 and 1.0. A value of 1.0 specifies that the attribute in question is present, while a value of 0.0 specifies that the attribute is absent. Because in this case the attributes are independent, arbitrary combinations of 0.0 and 1.0 can be passed. For OutputFunctionOutputFunctionOutputFunctionoutputFunctionoutput_function = 'softmax'"softmax""softmax""softmax""softmax", TargetTargetTargettargettarget also can only contain the values 0.0 and 1.0. In contrast to OutputFunctionOutputFunctionOutputFunctionoutputFunctionoutput_function = 'logistic'"logistic""logistic""logistic""logistic", the value 1.0 must be present for exactly one element of the tuple TargetTargetTargettargettarget. The location in the tuple designates the class of the sample. For ease of use, a single integer value may be passed if OutputFunctionOutputFunctionOutputFunctionoutputFunctionoutput_function = 'softmax'"softmax""softmax""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 NumOutputNumOutputNumOutputnumOutputnum_output - 1. The class is converted to a target vector of length NumOutputNumOutputNumOutputnumOutputnum_output internally.

Before the MLP can be trained with train_class_mlptrain_class_mlpTrainClassMlpTrainClassMlptrain_class_mlp, all training samples must be added to the MLP with add_sample_class_mlpadd_sample_class_mlpAddSampleClassMlpAddSampleClassMlpadd_sample_class_mlp.

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

Normally, it is useful to save the training samples in a file with write_samples_class_mlpwrite_samples_class_mlpWriteSamplesClassMlpWriteSamplesClassMlpwrite_samples_class_mlp 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

  • 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

MLPHandleMLPHandleMLPHandleMLPHandlemlphandle (input_control, state is modified)  class_mlp HClassMlp, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

MLP handle.

FeaturesFeaturesFeaturesfeaturesfeatures (input_control)  real-array HTupleSequence[float]HTupleHtuple (real) (double) (double) (double)

Feature vector of the training sample to be stored.

TargetTargetTargettargettarget (input_control)  number(-array) HTupleMaybeSequence[Union[int, float]]HTupleHtuple (integer / real) (int / long / double) (Hlong / double) (Hlong / double)

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

Result

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

Possible Predecessors

create_class_mlpcreate_class_mlpCreateClassMlpCreateClassMlpcreate_class_mlp

Possible Successors

train_class_mlptrain_class_mlpTrainClassMlpTrainClassMlptrain_class_mlp, write_samples_class_mlpwrite_samples_class_mlpWriteSamplesClassMlpWriteSamplesClassMlpwrite_samples_class_mlp

Alternatives

read_samples_class_mlpread_samples_class_mlpReadSamplesClassMlpReadSamplesClassMlpread_samples_class_mlp

See also

clear_samples_class_mlpclear_samples_class_mlpClearSamplesClassMlpClearSamplesClassMlpclear_samples_class_mlp, get_sample_num_class_mlpget_sample_num_class_mlpGetSampleNumClassMlpGetSampleNumClassMlpget_sample_num_class_mlp, get_sample_class_mlpget_sample_class_mlpGetSampleClassMlpGetSampleClassMlpget_sample_class_mlp

Module

Foundation