Package ai.djl.translate
Interface Batchifier
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
PaddingStackBatchifier
,SimplePaddingStackBatchifier
,StackBatchifier
An interface for different strategies to convert between
Record
NDList
s and Batch
NDList
.
Different implementations of Batchifier
represent different ways of creating batches.
The most common would be the StackBatchifier
that batchifies by creating a new batch axis
as axis 0. Another implementation could be a concatenated batchifier for sequence elements that
will concatenate the data elements along the time axis.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic Batchifier
fromString
(String name) Returns a batchifier from a batchifier name.default NDList[]
NDList[]
unbatchify
(NDList inputs)
-
Field Details
-
STACK
-
-
Method Details
-
fromString
Returns a batchifier from a batchifier name.- Parameters:
name
- the batchifier name- Returns:
- the batchifier with the given name
- Throws:
IllegalArgumentException
- if an invalid name is given
-
batchify
-
unbatchify
Splits a combinedBatch
NDList
into it's constituentRecord
NDList
s.This reverses the
batchify
operation.- Parameters:
inputs
- theNDList
that 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 givenBatch
NDList
into multipleBatch
lists 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
.
-