【问题标题】:Output of the Embedding layer in Decoder(Neural machine translation)Decoder 中嵌入层的输出(神经机器翻译)
【发布时间】:2020-11-26 02:08:29
【问题描述】:

我正在尝试使用以下教程 https://www.tensorflow.org/tutorials/text/nmt_with_attention 了解注意力模型

在解码器部分是这样写的:

# x shape after passing through embedding == (batch_size, 1, embedding_dim)
    x = self.embedding(x)

我不明白为什么嵌入输出是 (batch_size, 1, embedding_dim)。根据文档(https://www.tensorflow.org/api_docs/python/tf/keras/layers/Embedding),输出必须是(batch_size, input_length, output_dim),在教程的情况下是(batch_size, max_len,embedding_dim)。

问题:为什么seccode维度=1,而不是max_len?

【问题讨论】:

    标签: tensorflow deep-learning


    【解决方案1】:

    本教程中的模型是一个序列到序列。所以在每一步模型接收整个文本的一个单词。这就是为什么 (batch_size, max_len,embedding_dim) 中的 max_len 等于 1。每个单词由一个 size = embedding_dim 的向量表示

    【讨论】:

      猜你喜欢
      • 2021-02-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-23
      • 2017-11-18
      • 2021-12-27
      • 1970-01-01
      • 2018-08-24
      相关资源
      最近更新 更多