machine-learning - Caffe 嵌入层输入

标签 machine-learning neural-network deep-learning caffe word-embedding

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

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

那么单个句子的一个热向量的阶数为 N x M

这是否意味着输入的 dim 参数将为 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 维空间中:

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了解更多信息。

关于machine-learning - Caffe 嵌入层输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42722048/

相关文章:

python - 在 SVM 中使用特征之前如何对特征使用 L2 归一化

machine-learning - 增强拓扑的 NeuroEvolution (NEAT) 和全局创新数量

python-2.7 - 在 Python Pandas 中进行机器学习时出现内存错误

neural-network - 在 Pytorch 数据加载器中使用数据改组的影响

python-3.x - tf.gradients() 是如何工作的?

neural-network - 在 kNN 分类器中评估神经网络嵌入的性能

machine-learning - 同时训练两个子图时如何处理梯度

python - 如何解决这个问题(Pytorch RuntimeError : 1D target tensor expected, multi-target not supported)

python - 了解 Keras 层的形状