tf.contrib.layers.embed_sequence_tensorflow

來源:互聯網
上載者:User
簡介

一般用於sequence2sequence網路,可完成對輸入序列資料的嵌入工作。一般只需給出前三個參數。

tf.contrib.layers.embed_sequence(ids, vocab_size,  embed_dim)

ids: 形狀為[batch_size, doc_length]的int32或int64張量,也就是經過預先處理的輸入資料。

vocab_size: 輸入資料的總詞彙量,指的是總共有多少類詞彙,不是總個數

embed_dim:想要得到的嵌入矩陣的維度


tensorflow官網原文

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.


See 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 be 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, will first 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 (see tf.Variable).
scope: Optional string specifying the variable scope for the op, required if reuse=True.
reuse: If True, variables inside the op will 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.


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.