Loading...
Searching...
No Matches
embedding_layer.h
Go to the documentation of this file.
52 void set_add_positional_encoding(bool enabled) { embedding_lookup.add_positional_encoding = enabled; }
void set_scale_embedding(bool enabled)
Enables or disables embedding scaling by sqrt(embedding_dimension).
Definition embedding_layer.h:49
void set_dropout_rate(float rate)
Sets the dropout rate applied to the embedding output.
Definition embedding_layer.h:55
void read_JSON_body(const Json *) override
Reads the layer configuration from a JSON node.
Embedding(const Shape &={0, 0}, Index=0, const string &="embedding_layer")
Constructs an embedding layer.
Shape get_input_shape() const override
Returns the input tensor shape (sequence_length of token ids).
Definition embedding_layer.h:31
Index get_sequence_length() const
Definition embedding_layer.h:37
void set(Index=0, Index=0, Index=0, const string &="embedding_layer")
Reconfigures the layer with vocabulary size, sequence length, embedding dimension and name.
void set_add_positional_encoding(bool enabled)
Enables or disables sinusoidal positional encoding added to the embeddings.
Definition embedding_layer.h:52
vector< TensorSpec > get_backward_specs(Index) const override
Returns the tensor specs of the backward workspace; empty for non-trainable layers.
Definition embedding_layer.h:40
Index get_vocabulary_size() const
Definition embedding_layer.h:36
Index get_embedding_dimension() const
Definition embedding_layer.h:38
Shape get_output_shape() const override
Returns the output tensor shape (sequence_length, embedding_dimension).
void write_JSON_body(JsonWriter &) const override
Writes the layer configuration to a JSON writer.
Definition json.h:85
Definition json.h:23
Layer()=default
Definition adaptive_moment_estimation.h:14
Inverted dropout: at training time zeros activations with probability rate and rescales survivors.
Definition operators.h:122
Token embedding lookup with optional scaling and additive positional encoding.
Definition operators.h:947
Fixed-capacity small-vector describing tensor dimensions (rank up to MaxRank).
Definition tensor_utilities.h:42