Class Embedding¶
Defined in File embedding.h
Inheritance Relationships¶
Base Types¶
public marian::LayerBase
(Class LayerBase)public marian::IEmbeddingLayer
(Struct IEmbeddingLayer)
Class Documentation¶
-
class
Embedding
: public marian::LayerBase, public marian::IEmbeddingLayer¶ A regular embedding layer.
Note that this also applies dropout if the option is passed (pass 0 when in inference mode). It is best to not use Embedding directly, but rather via getEmbeddingLayer() in EncoderDecoderLayerBase, which knows to pass on all required parameters from options.
Public Functions
-
Embedding
(Ptr<ExpressionGraph> graph, Ptr<Options> options)¶ Construct a regular embedding layer in the graph.
- Parameters
graph
: The expression graph.options
: The options used for this embedding layer.
-
std::tuple<Expr, Expr>
apply
(Ptr<data::SubBatch> subBatch) const¶ Apply/Link this embedding layer (with the given batch of sentences) to the expression graph.
- Return
The expression tuple holding the embedding layer and the masking layer
- Parameters
subBatch
: The batch of sentences
-
Expr
apply
(const Words &words, const Shape &shape) const¶ Apply/Link this embedding layer (with the given words and shape) to the expression graph.
- Return
The expression holding the embedding layer
- Parameters
words
: Sequence of vocabulary itemsshape
: Shape of the words
-
Expr
applyIndices
(const std::vector<WordIndex> &embIdx, const Shape &shape) const¶ Apply/Link this embedding layer (with the given WordIndex vector and shape) to the expression graph.
- Return
The expression holding the embedding layer
- Parameters
embIdx
: The vector of WordIndex objectsshape
: Shape of the WordIndex vector
-