public final class IdEmbedding extends AbstractBlock
Modifier and Type | Class and Description |
---|---|
static class |
IdEmbedding.Builder
The Builder to construct an
IdEmbedding type of Block . |
children, inputNames, inputShapes, parameters, version
Modifier and Type | Method and Description |
---|---|
protected NDList |
forwardInternal(ParameterStore ps,
NDList inputs,
boolean training,
ai.djl.util.PairList<java.lang.String,java.lang.Object> params)
A helper for
Block.forward(ParameterStore, NDList, boolean, PairList) after
initialization. |
Shape[] |
getOutputShapes(Shape[] inputShapes)
Returns the expected output shapes of the block for the specified input shapes.
|
NDArray |
getValue(ParameterStore ps,
Device device,
boolean training)
Quick hack for bert model to acces embedding table, replace by a proper function to calculate
raw logits from embeddings.
|
void |
initializeChildBlocks(NDManager manager,
DataType dataType,
Shape... inputShapes)
Initializes the Child blocks of this block.
|
NDArray |
probabilities(ParameterStore parameterStore,
NDArray input,
boolean training)
Turns an array of embeddings of shape (d0 ...
|
addChildBlock, addParameter, beforeInitialize, cast, clear, describeInput, forward, forward, forwardInternal, getChildren, getDirectParameters, getParameters, initialize, isInitialized, loadMetadata, loadParameters, prepare, readInputShapes, saveInputShapes, saveMetadata, saveParameters, setInitializer, setInitializer, setInitializer, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forward, validateLayout
public Shape[] getOutputShapes(Shape[] inputShapes)
inputShapes
- the shapes of the inputsprotected NDList forwardInternal(ParameterStore ps, NDList inputs, boolean training, ai.djl.util.PairList<java.lang.String,java.lang.Object> params)
Block.forward(ParameterStore, NDList, boolean, PairList)
after
initialization.forwardInternal
in class AbstractBlock
ps
- the parameter storeinputs
- the input NDListtraining
- true for a training forward passparams
- optional parameterspublic NDArray probabilities(ParameterStore parameterStore, NDArray input, boolean training)
parameterStore
- the parameters storeinput
- the embeddings to create log probabilities fortraining
- true for a training forward passpublic NDArray getValue(ParameterStore ps, Device device, boolean training)
ps
- the parameter storedevice
- device to get internal table fortraining
- true for a training forward passpublic void initializeChildBlocks(NDManager manager, DataType dataType, Shape... inputShapes)
AbstractBlock
initializeChildBlocks
in class AbstractBlock
manager
- the manager to use for initializationdataType
- the requested data typeinputShapes
- the expected input shapes for this block