Package ai.djl.nn
Class Blocks
java.lang.Object
ai.djl.nn.Blocks
Utility class that provides some useful blocks.
-
Method Summary
Modifier and TypeMethodDescriptionstatic NDArraybatchFlatten(NDArray array) static NDArraybatchFlatten(NDArray array, long size) static BlockCreates aBlockwhose forward function applies thebatchFlattenmethod.static BlockbatchFlattenBlock(long size) Creates aBlockwhose forward function applies thebatchFlattenmethod.static StringReturns a string representation of the passedBlockdescribing the input axes, output axes, and the block's children.static BlockCreates aLambdaBlockthat performs the identity function.static BlockCreates aLambdaBlockthat return all-ones NDList.
-
Method Details
-
batchFlatten
-
batchFlatten
- Parameters:
array- a array to be flattenedsize- the input size- Returns:
- a
NDListthat contains the inflatedNDArray - Throws:
IndexOutOfBoundsException- if the inputNDListhas more than oneNDArray
-
batchFlattenBlock
Creates aBlockwhose forward function applies thebatchFlattenmethod.- Returns:
- a
Blockwhose forward function applies thebatchFlattenmethod
-
batchFlattenBlock
Creates aBlockwhose forward function applies thebatchFlattenmethod. The size of input to the block returned must be batch_size * size.- Parameters:
size- the expected size of each input- Returns:
- a
Blockwhose forward function applies thebatchFlattenmethod
-
identityBlock
Creates aLambdaBlockthat performs the identity function.- Returns:
- an identity
Block
-
onesBlock
Creates aLambdaBlockthat return all-ones NDList.- Returns:
- an all-ones
Block
-
describe
Returns a string representation of the passedBlockdescribing the input axes, output axes, and the block's children.- Parameters:
block- the block to describeblockName- the name to be used for the passed block, ornullif its class name is to be usedbeginAxis- skips all axes before this axis; use0to print all axes and1to skip the batch axis.- Returns:
- the string representation
-