Package ai.djl.nn
Class Blocks
- java.lang.Object
-
- ai.djl.nn.Blocks
-
public final class Blocks extends java.lang.Object
Utility class that provides some useful blocks.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static NDArray
batchFlatten(NDArray array)
static NDArray
batchFlatten(NDArray array, long size)
static Block
batchFlattenBlock()
Creates aBlock
whose forward function applies thebatchFlatten
method.static Block
batchFlattenBlock(long size)
Creates aBlock
whose forward function applies thebatchFlatten
method.static java.lang.String
describe(Block block, java.lang.String blockName, int beginAxis)
Returns a string representation of the passedBlock
describing the input axes, output axes, and the block's children.static Block
identityBlock()
Creates aLambdaBlock
that performs the identity function.
-
-
-
Method Detail
-
batchFlattenBlock
public static Block batchFlattenBlock()
Creates aBlock
whose forward function applies thebatchFlatten
method.- Returns:
- a
Block
whose forward function applies thebatchFlatten
method
-
batchFlattenBlock
public static Block batchFlattenBlock(long size)
Creates aBlock
whose forward function applies thebatchFlatten
method. The size of input to the block returned must be batch_size * size.- Parameters:
size
- the expected size of each input- Returns:
- a
Block
whose forward function applies thebatchFlatten
method
-
identityBlock
public static Block identityBlock()
Creates aLambdaBlock
that performs the identity function.- Returns:
- an identity
Block
-
describe
public static java.lang.String describe(Block block, java.lang.String blockName, int beginAxis)
Returns a string representation of the passedBlock
describing 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, ornull
if its class name is to be usedbeginAxis
- skips all axes before this axis; use0
to print all axes and1
to skip the batch axis.- Returns:
- the string representation
-
-