Caffe 嵌入层输入

Caffe Embed Layer Inputs

Caffe 中的嵌入层接受什么类型的输入? 它是否采用已经编码为一种热形式的单词?

假设,N = 输入句子中的单词数; M = 词汇量

那么单个句子的一个热向量将是N x M阶

这是否意味着输入的暗淡参数将为 N?

最后,为了让Caffe嵌入层能够正确读取,句子应该以什么格式保存?

请参阅"Embed"层的文档:

A layer for learning "embeddings" of one-hot vector input. Equivalent to an InnerProductLayer with one-hot vectors as input, but for efficiency the input is the "hot" index of each column itself.

因此,您的输入不是表示单词(或字符或“项目”)的“热向量”,而是单词的紧凑表示:字典中单词的整数索引。

所以,如果你的字典中有 M=1000 个单词,并且你想学习嵌入到 100 维 space:

layer {
  name: "embed1000_to_100"
  type: "Embed"
  bottom: "compact_one_hot_dim1000"
  top: "embed1000_to_100"
  embed_param {
    num_output: 100 # output dimension
    input_dim: 1000
  }
}

注意"compact_one_hot_dim1000"的数据应该是(0..999)范围内的整数。

有关详细信息,请参阅 caffe.help