public class BertPretrainingBlock extends AbstractBlock
children, inputNames, inputShapes, parameters, parameterShapeCallbacks, version
Constructor and Description |
---|
BertPretrainingBlock(BertBlock.Builder builder)
Creates a new Bert pretraining block fitting the given bert configuration.
|
Modifier and Type | Method and Description |
---|---|
NDList |
forward(ParameterStore ps,
NDArray tokenIds,
NDArray typeIds,
NDArray sequenceMasks,
NDArray maskedIndices,
boolean training)
Applies one bert pretraining step.
|
NDList |
forward(ParameterStore ps,
NDList inputs,
boolean training)
Applies the operating function of the block once.
|
protected NDList |
forwardInternal(ParameterStore ps,
NDList inputs,
boolean training,
ai.djl.util.PairList<java.lang.String,java.lang.Object> params) |
Shape[] |
getOutputShapes(NDManager manager,
Shape[] inputShapes)
Returns the expected output shapes of the block for the specified input shapes.
|
void |
initializeChildBlocks(NDManager manager,
DataType dataType,
Shape... inputShapes)
Initializes the Child blocks of this block.
|
addChildBlock, addParameter, addParameter, addParameter, beforeInitialize, cast, clear, describeInput, forward, getChildren, getDirectParameters, getParameters, getParameterShape, initialize, isInitialized, loadMetadata, loadParameters, readInputShapes, saveInputShapes, saveMetadata, saveParameters, setInitializer, setInitializer, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forward, validateLayout
public BertPretrainingBlock(BertBlock.Builder builder)
builder
- a builder with a bert configurationpublic void initializeChildBlocks(NDManager manager, DataType dataType, Shape... inputShapes)
initializeChildBlocks
in class AbstractBlock
manager
- the manager to use for initializationdataType
- the requested data typeinputShapes
- the expected input shapes for this blockprotected NDList forwardInternal(ParameterStore ps, NDList inputs, boolean training, ai.djl.util.PairList<java.lang.String,java.lang.Object> params)
forwardInternal
in class AbstractBlock
public NDList forward(ParameterStore ps, NDList inputs, boolean training)
ps
- the parameter storeinputs
- the input NDListtraining
- true for a training forward passpublic NDList forward(ParameterStore ps, NDArray tokenIds, NDArray typeIds, NDArray sequenceMasks, NDArray maskedIndices, boolean training)
ps
- the parameter storetokenIds
- int, (B, S)typeIds
- int, (B, S)sequenceMasks
- int, (B, S)maskedIndices
- int, (B, I)training
- true=apply dropout etc.