| Customize Help
| Save Settings

MclassHookFunction



Function Map
Synopsis
Hook a function to an event that occurs using classification objects.
Syntax
void MclassHookFunction(
MIL_ID ClassifierOrTrainingContextId, //in
MIL_INT64 HookType, //in
MIL_CLASS_HOOK_FUNCTION_PTR HookHandlerPtr, //in
void *UserDataPtr //in-out
)
Description

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.

Note that this function reference has not been updated for a MIL system added during a MIL update. Refer to the MIL system's release note to see if there is complementary information.
Parameters
This function is not supported on the selected boards.
Parameters
ClassifierOrTrainingContextId

Specifies the identifier of the classification object (classifier context or training context) onto which to attach a hook handler.

function map For specifying the identifier of the classification object (classifier context or training context)
Click to summarizeValue Description
Click to summarize 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)
Click to summarize 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)
HookType

Specifies the event type. This parameter can be set to one of the following values.

function map For specifying the event type
Click to summarizeValue Description
Click to summarize 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)
Click to summarize 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)
Click to summarize 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)
Click to summarize 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)
Combination value for any of the possible values of the HookType parameter.

You can add the following value to the above-mentioned values to set whether to detach the hook-handler function.

function map For the HookType parameter
Click to summarizeCombination value Description
Click to summarize M_UNHOOK

Detaches (that is, unhooks) the hook-handler function.

HookHandlerPtr

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:

MIL_INT MFTYPE HookHandler(
MIL_INT HookType,
MIL_ID EventId,
void *UserDataPtr
)

Parameters
HookType

Specifies the type of event that generated the call.

EventId

Event identifier to pass to MclassGetHookInfo() when inquiring about the hooked event.

UserDataPtr

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.

UserDataPtr

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.

Compilation information
Header Include mil.h.
Library Use mil.lib; milclass.lib.
DLL Requires mil.dll; milclass.dll.
EPOCH TRAINED MINI BATCH TRAINED PREDICT ENTRY TREE TRAINED UNHOOK