How To Use Rejection Classes in MVTec HALCON
In a previous support article we described the use of regularisation during the training of a multilayer perceptron (MLP) to enhance its capabilities of generalisation to unknown data. In some cases, however, samples that substantially differ from the training samples should not be assigned to any of the training classes, but to a rejection class instead. For the MLP classifier, HALCON offers the possibility to add such a rejection class during the training of an MLP. During the training of an MLP the rejection class is treated like regular classes, but training samples for the rejection class are generated automatically by HALCON using one of several sampling strategies.
The first step when using a rejection class is to increase the number of classes by one when creating the classifier with the operator create_class_mlp. Next, the sampling strategy for the rejection class samples needs to be set with the operator set_rejection_params_class_mlp to ‘hyperbox_around_all_classes’, ‘hyperbox_around_each_class’, or ‘hyperbox_ring_around_each_class’. This parameter determines the section of the feature space where rejection class samples are generated.
When using ‘hyperbox_around_all_classes’ the bounding box of all training samples is calculated and the rejection class samples are generated outside of this box. For ‘hyperbox_around_each_class’ separate bounding boxes for all classes are used. For the third choice, ‘hyperbox_ring_around_each_class’, again separate bounding boxes around the classes are used, but in contrast to the previous strategy, samples are only generated in a ring around these boxes.
The parameter ‘hyperbox_tolerance’ can be used to influence how close the generated rejection class samples should be to the bounding box (or boxes) of the training data. The smaller ‘hyperbox_tolerance’ is chosen, the closer the decision boundary of the trained MLP will be to the training samples of the real classes.
Finally, the parameter ‘rejection_sample_factor’ controls how many samples should be generated for the rejection class. When changing this parameter, please keep in mind that the time needed for training scales linearly with the total number of samples, i.e., the number of training samples plus the generated samples.