Package ai.djl.nn
Class Blocks
- java.lang.Object
-
- ai.djl.nn.Blocks
-
public final class Blocks extends java.lang.ObjectUtility class that provides some useful blocks.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static NDArraybatchFlatten(NDArray array)static NDArraybatchFlatten(NDArray array, long size)static BlockbatchFlattenBlock()Creates aBlockwhose forward function applies thebatchFlattenmethod.static BlockbatchFlattenBlock(long size)Creates aBlockwhose forward function applies thebatchFlattenmethod.static java.lang.Stringdescribe(Block block, java.lang.String blockName, int beginAxis)Returns a string representation of the passedBlockdescribing the input axes, output axes, and the block's children.static BlockidentityBlock()Creates aLambdaBlockthat performs the identity function.
-
-
-
Method Detail
-
batchFlattenBlock
public static Block batchFlattenBlock()
Creates aBlockwhose forward function applies thebatchFlattenmethod.- Returns:
- a
Blockwhose forward function applies thebatchFlattenmethod
-
batchFlattenBlock
public static Block batchFlattenBlock(long size)
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
public static Block identityBlock()
Creates aLambdaBlockthat 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 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
-
-