tf.contrib.layers.bow_encoder(
ids,
vocab_size,
embed_dim,
sparse_lookup=True,
initializer=None,
regularizer=None,
trainable=True,
scope=None,
reuse=None
)
Defined in tensorflow/contrib/layers/python/layers/encoders.py.
Maps a sequence of symbols to a vector per example by averaging embeddings.
Args:
ids:[batch_size, doc_length]TensororSparseTensorof typeint32orint64with symbol ids.vocab_size: Integer number of symbols in vocabulary.embed_dim: Integer number of dimensions for embedding matrix.sparse_lookup:bool, ifTrue, converts ids to aSparseTensorand performs a sparse embedding lookup. This is usually faster, but not desirable if padding tokens should have an embedding. Empty rows are assigned a special embedding.initializer: An initializer for the embeddings, ifNonedefault for current scope is used.regularizer: Optional regularizer for the embeddings.trainable: IfTruealso add variables to the graph collectionGraphKeys.TRAINABLE_VARIABLES(see tf.Variable).scope: Optional string specifying the variable scope for the op, required ifreuse=True.reuse: IfTrue, variables inside the op will be reused.
Returns:
Encoding Tensor [batch_size, embed_dim] produced by
averaging embeddings.
Raises:
ValueError: Ifembed_dimorvocab_sizeare not specified.