ClassesClasses | | Operators

set_regularization_params_ocr_class_mlpset_regularization_params_ocr_class_mlpSetRegularizationParamsOcrClassMlpSetRegularizationParamsOcrClassMlp (Operator)

Name

set_regularization_params_ocr_class_mlpset_regularization_params_ocr_class_mlpSetRegularizationParamsOcrClassMlpSetRegularizationParamsOcrClassMlp — Set the regularization parameters of an OCR classifier.

Signature

set_regularization_params_ocr_class_mlp( : : OCRHandle, GenParamName, GenParamValue : )

Herror set_regularization_params_ocr_class_mlp(const Hlong OCRHandle, const char* GenParamName, double GenParamValue)

Herror T_set_regularization_params_ocr_class_mlp(const Htuple OCRHandle, const Htuple GenParamName, const Htuple GenParamValue)

void SetRegularizationParamsOcrClassMlp(const HTuple& OCRHandle, const HTuple& GenParamName, const HTuple& GenParamValue)

void HOCRMlp::SetRegularizationParamsOcrClassMlp(const HString& GenParamName, const HTuple& GenParamValue) const

void HOCRMlp::SetRegularizationParamsOcrClassMlp(const HString& GenParamName, double GenParamValue) const

void HOCRMlp::SetRegularizationParamsOcrClassMlp(const char* GenParamName, double GenParamValue) const

static void HOperatorSet.SetRegularizationParamsOcrClassMlp(HTuple OCRHandle, HTuple genParamName, HTuple genParamValue)

void HOCRMlp.SetRegularizationParamsOcrClassMlp(string genParamName, HTuple genParamValue)

void HOCRMlp.SetRegularizationParamsOcrClassMlp(string genParamName, double genParamValue)

Description

set_regularization_params_ocr_class_mlpset_regularization_params_ocr_class_mlpSetRegularizationParamsOcrClassMlpSetRegularizationParamsOcrClassMlpSetRegularizationParamsOcrClassMlp sets the regularization parameters of the OCR classifier passed in OCRHandleOCRHandleOCRHandleOCRHandleOCRHandle. The regularization parameter to be set is specified with GenParamNameGenParamNameGenParamNameGenParamNamegenParamName. Its value is specified with GenParamValueGenParamValueGenParamValueGenParamValuegenParamValue.

As described at create_class_mlpcreate_class_mlpCreateClassMlpCreateClassMlpCreateClassMlp, it may be desirable to regularize the OCR classifier (i.e., the MLP of the OCR classifier) to enforce a smoother transition of the confidences between the different classes and to prevent overfitting of the OCR classifier to the training data. To achieve this, a penalty for large MLP weights (which are the main reason for very sharp transitions between classes) can be added to the training of the OCR classifier in trainf_ocr_class_mlptrainf_ocr_class_mlpTrainfOcrClassMlpTrainfOcrClassMlpTrainfOcrClassMlp by setting GenParamNameGenParamNameGenParamNameGenParamNamegenParamName to 'weight_prior'"weight_prior""weight_prior""weight_prior""weight_prior" and setting GenParamValueGenParamValueGenParamValueGenParamValuegenParamValue to a value > 0. Furthermore, the regularization parameters can be determined automatically. For details, see set_regularization_params_class_mlpset_regularization_params_class_mlpSetRegularizationParamsClassMlpSetRegularizationParamsClassMlpSetRegularizationParamsClassMlp. If the regularization parameters should be determined automatically, please carefully note the advice in set_regularization_params_class_mlpset_regularization_params_class_mlpSetRegularizationParamsClassMlpSetRegularizationParamsClassMlpSetRegularizationParamsClassMlp on how to select the parameters NumHiddenNumHiddenNumHiddenNumHiddennumHidden of the MLP and 'num_outer_iterations'"num_outer_iterations""num_outer_iterations""num_outer_iterations""num_outer_iterations" and on the memory and runtime implications of automatically determining the regularization parameters on the runtime of the training of the OCR classifier.

Execution Information

This operator modifies the state of the following input parameter:

The value of this parameter may not be shared across multiple threads without external synchronization.

Parameters

OCRHandleOCRHandleOCRHandleOCRHandleOCRHandle (input_control, state is modified)  ocr_mlp HOCRMlp, HTupleHTupleHtuple (integer) (IntPtr) (Hlong) (Hlong)

Handle of the OCR classifier.

GenParamNameGenParamNameGenParamNameGenParamNamegenParamName (input_control)  string HTupleHTupleHtuple (string) (string) (HString) (char*)

Name of the regularization parameter to return.

Default value: 'weight_prior' "weight_prior" "weight_prior" "weight_prior" "weight_prior"

List of values: 'num_inner_iterations'"num_inner_iterations""num_inner_iterations""num_inner_iterations""num_inner_iterations", 'num_outer_iterations'"num_outer_iterations""num_outer_iterations""num_outer_iterations""num_outer_iterations", 'weight_prior'"weight_prior""weight_prior""weight_prior""weight_prior"

GenParamValueGenParamValueGenParamValueGenParamValuegenParamValue (input_control)  number(-array) HTupleHTupleHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong)

Value of the regularization parameter.

Default value: 1.0

Suggested values: 0.01, 0.1, 1.0, 10.0, 100.0, 0, 1, 2, 3, 5, 10, 15, 20

Example (HDevelop)

* This example shows how to determine the regularization parameters
* automatically without examining the convergence of the
* regularization parameters.
* Create the OCR classifier.
read_ocr_trainf_names ('ocr.trf', CharacterNames, CharacterCount)
create_ocr_class_mlp (8, 10, 'constant', 'default', CharacterNames, \
                      40, 'none', |CharacterNames|, 42, OCRHandle)
* Set up the automatic determination of the regularization
* parameters.
set_regularization_params_ocr_class_mlp (OCRHandle, 'weight_prior', \
                                         [0.01,0.01,0.01,0.01])
set_regularization_params_ocr_class_mlp (OCRHandle, \
                                         'num_outer_iterations', 10)
* Train the classifier.
trainf_ocr_class_mlp (OCRHandle, 'ocr.trf', 100, 1, 0.01, Error, \
                      ErrorLog)
* Read out the estimate of the number of well-determined
* parameters.
get_regularization_params_ocr_class_mlp (OCRHandle, \
                                         'fraction_well_determined_params', \
                                          FractionParams)
* If FractionParams differs substantially from 1, consider reducing
* NumHidden appropriately and consider performing a preprocessing that
* reduces the number of input variables to the net, i.e., canonical
* variates or principal components.
write_ocr_class_mlp (OCRHandle, 'ocr.omc')
clear_ocr_class_mlp (OCRHandle)



* This example shows how to determine the regularization parameters
* automatically while examining the convergence of the
* regularization parameters.
* Create the OCR classifier.
read_ocr_trainf_names ('ocr.trf', CharacterNames, CharacterCount)
create_ocr_class_mlp (8, 10, 'constant', 'default', CharacterNames, \
                      40, 'none', |CharacterNames|, 42, OCRHandle)
* Set up the automatic determination of the regularization
* parameters.
set_regularization_params_ocr_class_mlp (OCRHandle, 'weight_prior', \
                                         [0.01,0.01,0.01,0.01])
set_regularization_params_ocr_class_mlp (OCRHandle, \
                                         'num_outer_iterations', 1)
for OuterIt := 1 to 10 by 1
    * Train the classifier.
    trainf_ocr_class_mlp (OCRHandle, 'ocr.trf', 100, 1, 0.01, Error, \
                          ErrorLog)
    * Read out the regularization parameters
    get_regularization_params_ocr_class_mlp (OCRHandle, \
                                             'weight_prior', \
                                             WeightPrior)
    * Inspect the regularization parameters manually for
    * convergence and exit the loop manually if they have
    * converged.
    * [...]
endfor
* Read out the estimate of the number of well-determined
* parameters.
get_regularization_params_ocr_class_mlp (OCRHandle, \
                                         'fraction_well_determined_params', \
                                          FractionParams)
* If FractionParams differs substantially from 1, consider reducing
* NumHidden appropriately and consider performing a preprocessing that
* reduces the number of input variables to the net, i.e., canonical
* variates or principal components.
write_ocr_class_mlp (OCRHandle, 'ocr.omc')
clear_ocr_class_mlp (OCRHandle)

Result

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

Possible Predecessors

create_ocr_class_mlpcreate_ocr_class_mlpCreateOcrClassMlpCreateOcrClassMlpCreateOcrClassMlp

Possible Successors

get_regularization_params_ocr_class_mlpget_regularization_params_ocr_class_mlpGetRegularizationParamsOcrClassMlpGetRegularizationParamsOcrClassMlpGetRegularizationParamsOcrClassMlp, trainf_ocr_class_mlptrainf_ocr_class_mlpTrainfOcrClassMlpTrainfOcrClassMlpTrainfOcrClassMlp

Module

OCR/OCV


ClassesClasses | | Operators