Brief introduction
Generally used in Sequence2sequence network, can complete the input sequence data embedding work. Generally, you only need to give the first three parameters.
Tf.contrib.layers.embed_sequence (IDs, Vocab_size, Embed_dim)
IDS: The Int32 or Int64 tensor of the shape [Batch_size, Doc_length], which is the preprocessed input data.
Vocab_size: The total vocabulary of the input data, refers to the total number of words, not the total number
Embed_dim: The dimension of the embedded matrix you want to get
TensorFlow Official Website Original
Tf.contrib.layers.embed_sequence
Embed_sequence (
Ids
Vocab_size=none,
Embed_dim=none,
Unique=false,
Initializer=none,
Regularizer=none,
Trainable=true,
Scope=none,
Reuse=none
)
Defined in tensorflow/contrib/layers/python/layers/encoders.py.
The Guide:layers (contrib) > Higher level OPS for building neural network Layers
Maps a sequence of symbols to a sequence of embeddings.
Typical use case would is reusing embeddings between an encoder and decoder.
Args:
IDS: [Batch_size, Doc_length] Tensor of type int32 or int64 with symbol IDs.
Vocab_size:integer number of symbols in vocabulary.
Embed_dim:integer number of dimensions for embedding matrix.
Unique:if True, would compute the unique set of indices, and then lookup each embedding once, repeating them in the Output as needed.
Initializer:an initializer for the embeddings, if None default for current scope is used.
Regularizer:optional Regularizer for the embeddings.
Trainable:if True also add variables to the graph collection graphkeys.trainable_variables. Variable).
Scope:optional string specifying the variable scope for the OP, required if reuse=true.
Reuse:if True, variables inside the OP would be reused.
Returns:
Tensor of [Batch_size, Doc_length, Embed_dim] with embedded sequences.
Raises:
Valueerror:if Embed_dim or vocab_size are not specified when reuse is None or False.