trainf_ocr_class_mlpT_trainf_ocr_class_mlpTrainfOcrClassMlpTrainfOcrClassMlptrainf_ocr_class_mlp (算子)
名称
trainf_ocr_class_mlpT_trainf_ocr_class_mlpTrainfOcrClassMlpTrainfOcrClassMlptrainf_ocr_class_mlp — 训练 OCR 分类器。
签名
void TrainfOcrClassMlp(const HTuple& OCRHandle, const HTuple& TrainingFile, const HTuple& MaxIterations, const HTuple& WeightTolerance, const HTuple& ErrorTolerance, HTuple* Error, HTuple* ErrorLog)
double HOCRMlp::TrainfOcrClassMlp(const HTuple& TrainingFile, Hlong MaxIterations, double WeightTolerance, double ErrorTolerance, HTuple* ErrorLog) const
double HOCRMlp::TrainfOcrClassMlp(const HString& TrainingFile, Hlong MaxIterations, double WeightTolerance, double ErrorTolerance, HTuple* ErrorLog) const
double HOCRMlp::TrainfOcrClassMlp(const char* TrainingFile, Hlong MaxIterations, double WeightTolerance, double ErrorTolerance, HTuple* ErrorLog) const
double HOCRMlp::TrainfOcrClassMlp(const wchar_t* TrainingFile, Hlong MaxIterations, double WeightTolerance, double ErrorTolerance, HTuple* ErrorLog) const
(
Windows only)
static void HOperatorSet.TrainfOcrClassMlp(HTuple OCRHandle, HTuple trainingFile, HTuple maxIterations, HTuple weightTolerance, HTuple errorTolerance, out HTuple error, out HTuple errorLog)
double HOCRMlp.TrainfOcrClassMlp(HTuple trainingFile, int maxIterations, double weightTolerance, double errorTolerance, out HTuple errorLog)
double HOCRMlp.TrainfOcrClassMlp(string trainingFile, int maxIterations, double weightTolerance, double errorTolerance, out HTuple errorLog)
描述
trainf_ocr_class_mlptrainf_ocr_class_mlpTrainfOcrClassMlpTrainfOcrClassMlpTrainfOcrClassMlptrainf_ocr_class_mlp trains the OCR classifier
OCRHandleOCRHandleOCRHandleOCRHandleOCRHandleocrhandle with the training characters stored in the OCR
training files given by TrainingFileTrainingFileTrainingFileTrainingFiletrainingFiletraining_file. The training files
must have been created, e.g., using write_ocr_trainfwrite_ocr_trainfWriteOcrTrainfWriteOcrTrainfWriteOcrTrainfwrite_ocr_trainf, before
calling trainf_ocr_class_mlptrainf_ocr_class_mlpTrainfOcrClassMlpTrainfOcrClassMlpTrainfOcrClassMlptrainf_ocr_class_mlp.
The remaining parameters have the same meaning as in
train_class_mlptrain_class_mlpTrainClassMlpTrainClassMlpTrainClassMlptrain_class_mlp and are described in detail with
train_class_mlptrain_class_mlpTrainClassMlpTrainClassMlpTrainClassMlptrain_class_mlp。A regularization of the OCR classifier and
an automatic determination of the regularization parameters (see
set_regularization_params_ocr_class_mlpset_regularization_params_ocr_class_mlpSetRegularizationParamsOcrClassMlpSetRegularizationParamsOcrClassMlpSetRegularizationParamsOcrClassMlpset_regularization_params_ocr_class_mlp) is taken into
account during the training. Furthermore, if a rejection class has
been specified using set_rejection_params_ocr_class_mlpset_rejection_params_ocr_class_mlpSetRejectionParamsOcrClassMlpSetRejectionParamsOcrClassMlpSetRejectionParamsOcrClassMlpset_rejection_params_ocr_class_mlp,
before the actual training the samples for the rejection class are
generated.
Please note that training characters that have no corresponding
class in the classifier OCRHandleOCRHandleOCRHandleOCRHandleOCRHandleocrhandle are discarded.
执行信息
- 多线程类型:可重入(与非独占算子并行运行)。
- 多线程作用域:全局(可从任何线程调用)。
- 在内部数据级别上自动并行化。
此算子修改后续输入参数的状态:
在执行此算子时,若该参数值需在多个线程间使用,则必须对其访问进行同步。
参数
OCRHandleOCRHandleOCRHandleOCRHandleOCRHandleocrhandle (输入控制,状态被修改) ocr_mlp → HOCRMlp, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)
Handle of the OCR classifier.
TrainingFileTrainingFileTrainingFileTrainingFiletrainingFiletraining_file (输入控制) filename.read(-array) → HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)
Names of the training files.
默认值:
'ocr.trf'
"ocr.trf"
"ocr.trf"
"ocr.trf"
"ocr.trf"
"ocr.trf"
File extension:
.trf, .otr
MaxIterationsMaxIterationsMaxIterationsMaxIterationsmaxIterationsmax_iterations (输入控制) integer → HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)
Maximum number of iterations of the
optimization algorithm.
默认值:
200
建议值:
20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300
WeightToleranceWeightToleranceWeightToleranceWeightToleranceweightToleranceweight_tolerance (输入控制) real → HTuplefloatHTupleHtuple (real) (double) (double) (double)
Threshold for the difference of the weights of
the MLP between two iterations of the
optimization algorithm.
默认值:
1.0
建议值:
1.0, 0.1, 0.01, 0.001, 0.0001, 0.00001
限制:
WeightTolerance >= 1.0e-8
ErrorToleranceErrorToleranceErrorToleranceErrorToleranceerrorToleranceerror_tolerance (输入控制) real → HTuplefloatHTupleHtuple (real) (double) (double) (double)
Threshold for the difference of the mean error
of the MLP on the training data between two
iterations of the optimization algorithm.
默认值:
0.01
建议值:
1.0, 0.1, 0.01, 0.001, 0.0001, 0.00001
限制:
ErrorTolerance >= 1.0e-8
ErrorErrorErrorErrorerrorerror (输出控制) real → HTuplefloatHTupleHtuple (real) (double) (double) (double)
Mean error of the MLP on the training data.
ErrorLogErrorLogErrorLogErrorLogerrorLogerror_log (输出控制) real-array → HTupleSequence[float]HTupleHtuple (real) (double) (double) (double)
Mean error of the MLP on the training data as a
function of the number of iterations of the
optimization algorithm.
示例(HDevelop)
* Train an OCR classifier
read_ocr_trainf_names ('ocr.trf', CharacterNames, CharacterCount)
create_ocr_class_mlp (8, 10, 'constant', 'default', CharacterNames, 80, \
'none', 81, 42, OCRHandle)
trainf_ocr_class_mlp (OCRHandle, 'ocr.trf', 100, 1, 0.01, Error, ErrorLog)
write_ocr_class_mlp (OCRHandle, 'ocr.omc')
结果
如果参数有效,算子
trainf_ocr_class_mlptrainf_ocr_class_mlpTrainfOcrClassMlpTrainfOcrClassMlpTrainfOcrClassMlptrainf_ocr_class_mlp 返回值 2 ( H_MSG_TRUE )。如有必要,则抛出异常。
trainf_ocr_class_mlptrainf_ocr_class_mlpTrainfOcrClassMlpTrainfOcrClassMlpTrainfOcrClassMlptrainf_ocr_class_mlp may return the error 9211 (Matrix is
not positive definite) if PreprocessingPreprocessingPreprocessingPreprocessingpreprocessingpreprocessing =
'canonical_variates'"canonical_variates""canonical_variates""canonical_variates""canonical_variates""canonical_variates" is used. This typically indicates
that not enough training samples have been stored for each class.
In this case we recommend to change PreprocessingPreprocessingPreprocessingPreprocessingpreprocessingpreprocessing to
'normalization'"normalization""normalization""normalization""normalization""normalization". Another solution can be to add more
training samples.
可能的前趋
create_ocr_class_mlpcreate_ocr_class_mlpCreateOcrClassMlpCreateOcrClassMlpCreateOcrClassMlpcreate_ocr_class_mlp,
write_ocr_trainfwrite_ocr_trainfWriteOcrTrainfWriteOcrTrainfWriteOcrTrainfwrite_ocr_trainf,
append_ocr_trainfappend_ocr_trainfAppendOcrTrainfAppendOcrTrainfAppendOcrTrainfappend_ocr_trainf,
write_ocr_trainf_imagewrite_ocr_trainf_imageWriteOcrTrainfImageWriteOcrTrainfImageWriteOcrTrainfImagewrite_ocr_trainf_image,
set_regularization_params_ocr_class_mlpset_regularization_params_ocr_class_mlpSetRegularizationParamsOcrClassMlpSetRegularizationParamsOcrClassMlpSetRegularizationParamsOcrClassMlpset_regularization_params_ocr_class_mlp
可能的后继
do_ocr_single_class_mlpdo_ocr_single_class_mlpDoOcrSingleClassMlpDoOcrSingleClassMlpDoOcrSingleClassMlpdo_ocr_single_class_mlp,
do_ocr_multi_class_mlpdo_ocr_multi_class_mlpDoOcrMultiClassMlpDoOcrMultiClassMlpDoOcrMultiClassMlpdo_ocr_multi_class_mlp,
write_ocr_class_mlpwrite_ocr_class_mlpWriteOcrClassMlpWriteOcrClassMlpWriteOcrClassMlpwrite_ocr_class_mlp
替代
read_ocr_class_mlpread_ocr_class_mlpReadOcrClassMlpReadOcrClassMlpReadOcrClassMlpread_ocr_class_mlp
另见
train_class_mlptrain_class_mlpTrainClassMlpTrainClassMlpTrainClassMlptrain_class_mlp
模块
光学字符识别/光学字符验证