为什么 CNTK 对解码器使用嵌入维度?

Why is CNTK using the embedding dimension for the decoder?

我已经训练了一个很好的序列到序列模型,我已经在我的本地盒子上测试过,但现在我正在尝试评估很多查询。不过,我看到了这个错误:

02/08/2017 00:50:54: EXCEPTION occurred: Node 'decoderInput._' (If operation): Input dimensions [100] and [57408 x 3] are not compatible.

57408 是词汇量。我猜 100 来自嵌入维度的数量,它设置为 100。

我很困惑为什么这不起作用,因为输入和输出是 "sparse" 的事实是在 "cntkReaderInputDef."

中设置的
cntkReaderInputDef = { rawInput = { alias = "S0" ; dim = $inputVocabSize$ ; format = "sparse" } ; rawLabels = { alias = "S1" ;  dim = $labelVocabSize$ ;  format = "sparse" } }

William Darling 发表:

因为您使用的是嵌入,所以您需要使用 CNTK.core.bs 文件的修改版本。在第1515行,目前有:

decoderFeedback = /*EmbedLabels*/ (tokens.word) # [embeddingDim x Dnew]

下一行是您的错误来源:

delayedDecoderFeedback = Boolean.If (Loop.IsFirst (labelSentenceStartEmbeddedScattered), labelSentenceStartEmbeddedScattered, Loop.Previous (decoderFeedback))

decoderFeedback 的形状为 [W x Dnew],但 labelSentenceStartEmbeddedScattered 的形状为 [E],其中 E 是嵌入维度。在 BrainScript 中,没有很好的方法来传递模型定义中使用的嵌入宏,因此您需要明确地将其写出来。因此,将第 1515 行更改为:

decoderFeedback = TransposeTimes(modelAsTrained.Einput, tokens.word)

这会将您的 decoderFeedback 表示转换为与嵌入形状兼容的东西。

顺便说一句,reader 定义的 format = sparse 仅与您格式化 CTF 输入文件的方式有关。使用稀疏格式意味着你有像 7:1 这样的东西,这意味着有一个 one-hot 向量在位置 7 处有一个 1 而不是必须写出一大堆零(你会用密集格式)。

克里斯·巴索格鲁说:

实际上,您应该可以将 CNTK.core.bs 文件复制到您自己的配置文件旁边。它应该首先查看该文件夹。