Interface Batchifier

  • All Known Implementing Classes:
    PaddingStackBatchifier, StackBatchifier

    public interface Batchifier
    An interface that provides methods to convert an un-batched NDList into a batched NDList and vice versa.

    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.

    • Method Detail

      • fromString

        static Batchifier fromString​(java.lang.String name)
        Returns a batchifier from a batchifier name.
        Parameters:
        name - the batchifier name
        Returns:
        the batchifier with the given name
        Throws:
        java.lang.IllegalArgumentException - if an invalid name is given
      • batchify

        NDList batchify​(NDList[] inputs)
        Converts an array of NDList into an NDList.

        The size of the input array is the batch size. The data in each of the NDList are assumed to be the same, and are batched together to form one batched NDList.

        Parameters:
        inputs - the input array of NDList where each element is a
        Returns:
        the batchified NDList
      • unbatchify

        NDList[] unbatchify​(NDList inputs)
        Reverses the batchify operation.
        Parameters:
        inputs - the NDList 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

        default NDList[] split​(NDList list,
                               int numOfSlices,
                               boolean evenSplit)
        Splits the given NDList into the given number of slices.

        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 of NDList.

        Parameters:
        list - the NDList that needs to be split
        numOfSlices - the number of slices the list must be sliced into
        evenSplit - whether each slice must have the same shape
        Returns:
        an array of NDList that contains all the slices