Package ai.djl.translate
Class SimplePaddingStackBatchifier
java.lang.Object
ai.djl.translate.SimplePaddingStackBatchifier
- All Implemented Interfaces:
Batchifier,Serializable
A simpler version of the
PaddingStackBatchifier that pads all dimensions rather than
specific ones.- See Also:
-
Field Summary
Fields inherited from interface ai.djl.translate.Batchifier
STACK -
Constructor Summary
ConstructorsConstructorDescriptionA simpleBatchifierthat pads all arrays to same shape (with padding 0) and then stacks them.SimplePaddingStackBatchifier(float padding) A simpleBatchifierthat pads all arrays to same shape and then stacks them. -
Method Summary
-
Constructor Details
-
SimplePaddingStackBatchifier
public SimplePaddingStackBatchifier(float padding) A simpleBatchifierthat pads all arrays to same shape and then stacks them.- Parameters:
padding- the number of pad with
-
SimplePaddingStackBatchifier
public SimplePaddingStackBatchifier()A simpleBatchifierthat pads all arrays to same shape (with padding 0) and then stacks them.
-
-
Method Details
-
batchify
Converts an array ofRecordNDLists into a combinedBatchNDList.The size of the input array is the batch size. The data in each of the
NDListare assumed to be the same, and are batched together to form one batchedNDList.- Specified by:
batchifyin interfaceBatchifier- Parameters:
inputs- the input array ofNDListwhere each element is a- Returns:
- the batchified
NDList
-
unbatchify
Splits a combinedBatchNDListinto it's constituentRecordNDLists.This reverses the
batchifyoperation.- Specified by:
unbatchifyin interfaceBatchifier- Parameters:
inputs- theNDListthat needs to be 'unbatchified'- Returns:
- an array of NDLists, of size equal to batch size, where each NDList is one element from the batch of inputs
-
split
Partitions the givenBatchNDListinto multipleBatchlists with smaller batch size.As an example, this function might be used for multi-GPU training where it takes the main batch and splits it into sub-batches that can be run on each GPU.
This function unbatchifies the input
NDList, redistributes them into the given number of slices, and then batchify each of the slices to form an array ofNDList.- Specified by:
splitin interfaceBatchifier- Parameters:
list- theNDListthat needs to be splitnumOfSlices- the number of slices the list must be sliced intoevenSplit- whether each slice must have the same shape- Returns:
- an array of
NDListthat contains all the slices
-