Handler designed to simplify the process of model validation for the user by eliminating the need to manually prescribe a sequence of actions. It is a kind of a wrapper function around the operations on data.
In handlers, depending on the location of the data, splitting can be performed in the following ways:
- data is placed on the disk: first, data is split into macrobatches - blocks that are entirely placed in the GPU, whereafter the macrobatch is split into smaller batches, which are then fed directly to the model input;
- data has already been placed in the GPU: it is split into batches, which are then fed directly to the input of the model.
def __init__(self, mod, cost, onBatchFinish=None, batchsize=128):
|mod||Module||Trainable neural network||-|
|onBatchFinish||callable||Function that will be called upon completion processing of a data batch||None|
|batchsize||int||Size of a data batch||128|
All the basic methods of handlers can be found in the documentation for the parent class Handler.
def validateFromHost(self, data, target, macroBatchSize=10000, onMacroBatchFinish=None):
Wrapper function around the handleFromHost() method of the Handlerparent class, taking into account the specifics of the validation process: the model is switched to inference mode (some network layers can behave differently in the training and inference modes), whereafter the error is calculated on the transmitted data. Returns the error value
|target||tensor||Tensor of data corresponding labels||None|
|macroBatchSize||int||Size of a macrobatch. The data will be split into macrobatches sized macrobatchSize||10000|
|onMacroBatchFinish||callable||Function that will be called upon completion of processing of a macrobatch||None|
def validate(self, data, target):
Wrapper function around the handle() method of the Handler parent class, taking into account the specifics of the validation process: the model is switched to inference mode (some network layers can behave differently in the training and inference modes), whereafter the error is calculated on the transmitted data. Returns the error value.
|data||GPUArray||Data tensor placed in the GPU||-|
|target||GPUArray||Tensor of data corresponding labels, placed in the GPU||None|
def handleBatch(self, batch, idx, resid, state):
Root method of the validation handler. Calculates the error value on the batch.
|batch||list||List of two elements:
|idx||int||Index number of the data batch||-|
|state||dict||Dictionary containing information about the total error||-|