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]
Tensor
orSparseTensor
of typeint32
orint64
with 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 aSparseTensor
and 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, ifNone
default for current scope is used.regularizer
: Optional regularizer for the embeddings.trainable
: IfTrue
also 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_dim
orvocab_size
are not specified.