MIL_ID ClassifierOrTrainingContextId, | //in |
MIL_INT64 HookType, | //in |
MIL_CLASS_HOOK_FUNCTION_PTR HookHandlerPtr, | //in |
void *UserDataPtr | //in-out |
This function allows you to attach or detach a user-defined function to a classification object event (for example, during the execution of MclassTrain() or MclassPredict()). Once a hook-handler function is defined and hooked to an event, it is automatically called when the event occurs.
You can hook more than one function to an event by making separate calls to MclassHookFunction() for each function that you want to hook. MIL automatically chains and keeps an internal list of all these hooked functions. When a function is hooked, this new function is added to the end of the list. When the event happens, all user-defined functions in the list will be executed in the same order that they were hooked to the event. You can also remove any function from the list; in this case, MIL preserves the order of the remaining functions in the list.
You can obtain information concerning the event, using MclassGetHookInfo(), and take appropriate action before returning control to the application.
Specifies the identifier of the classification object (classifier context or training context) onto which to attach a hook handler.
For specifying the identifier of the classification
object (classifier context or training context)
|
|||||||||||||||||||||||||||||||||||||||
Value | Description | ||||||||||||||||||||||||||||||||||||||
ContextClassifierId |
Specifies the identifier of a predefined CNN or tree ensemble classifier context. These contexts must have been previously allocated on the required system using MclassAlloc() with M_CLASSIFIER_CNN_PREDEFINED or M_CLASSIFIER_TREE_ENSEMBLE. (summarize)Specifies the identifier of a predefined CNN or tree ensemble classifier context. (more details...) |
||||||||||||||||||||||||||||||||||||||
ContextTrainId |
Specifies the identifier of a CNN or tree ensemble training context. These contexts must have been previously allocated on the required system using MclassAlloc() with M_TRAIN_CNN or M_TRAIN_TREE_ENSEMBLE. (summarize)Specifies the identifier of a CNN or tree ensemble training context. (more details...) |
Specifies the event type. This parameter can be set to one of the following values.
For specifying the event type
|
|||||||||||||||||||||||||||||||||||||||
Value | Description | ||||||||||||||||||||||||||||||||||||||
M_EPOCH_TRAINED + |
Calls the hook-handler function each time the training process is completed for an epoch. This is typically used to plot a graph of the training process. You can use M_EPOCH_TRAINED when training a CNN classifier. (summarize)Calls the hook-handler function each time the training process is completed for an epoch. (more details...) |
||||||||||||||||||||||||||||||||||||||
M_MINI_BATCH_TRAINED + |
Calls the hook-handler function each time the training process is completed for a given mini-batch within the current epoch. You can use M_MINI_BATCH_TRAINED when training a CNN classifier. (summarize)Calls the hook-handler function each time the training process is completed for a given mini-batch within the current epoch. (more details...) |
||||||||||||||||||||||||||||||||||||||
M_PREDICT_ENTRY + |
Calls the hook-handler function each time the prediction is completed for a dataset entry. You can use M_PREDICT_ENTRY when performing a prediction with a trained CNN or tree ensemble classifier and an images or features dataset. (summarize)Calls the hook-handler function each time the prediction is completed for a dataset entry. (more details...) |
||||||||||||||||||||||||||||||||||||||
M_TREE_TRAINED + |
Calls the hook-handler function each time the training process is completed for a tree. You can use M_TREE_TRAINED when training a tree ensemble classifier. (summarize)Calls the hook-handler function each time the training process is completed for a tree. (more details...) |
You can add the following value to the above-mentioned values to set whether to detach the hook-handler function.
For the HookType parameter
|
|||||||||||||||||||||||||||||||||||||||
Combination value | Description | ||||||||||||||||||||||||||||||||||||||
M_UNHOOK |
Detaches (that is, unhooks) the hook-handler function. |
Specifies the address of the function that should be called when an event occurs.
The hook-handler function, pointed to by HookHandlerPtr, must be declared as follows:
Specifies the type of event that generated the call.
Event identifier to pass to MclassGetHookInfo() when inquiring about the hooked event.
User data pointer that was passed to the UserDataPr parameter of MclassHookFunction().
Upon successful completion, the hook-handler function should return M_NULL. Note, MFTYPE and MIL_CLASS_HOOK_FUNCTION_PTR are reserved MIL predefined types for functions and data pointers, respectively.
Specifies the address of the user data that you want to make available to the hook-handler function. This address is passed to the hook-handler function, through its UserDataPtr parameter, when the specified event occurs. Set this parameter to M_NULL if user data is not required.
Header | Include mil.h. |
Library | Use mil.lib; milclass.lib. |
DLL | Requires mil.dll; milclass.dll. |