【问题标题】:What's the meaning of tf.nn.embedding_lookup_sparse in TensorFlow?TensorFlow 中的 tf.nn.embedding_lookup_sparse 是什么意思?
【发布时间】:2016-08-11 10:16:30
【问题描述】:

我们花了很多时间阅读tf.nn.embedding_lookup_sparse的API文档。 embedding_lookup_sparse 的含义很混乱,似乎和embedding_lookup 有很大的不同。

这是我的想法,如果我错了,请纠正我。宽深模型示例使用contrib.layers API 并调用embedding_lookup_sparse 用于稀疏特征列。如果它获得 SparseTensor(例如,国家,它是稀疏的),它会创建实际上用于单主机编码的嵌入。然后调用to_weights_sumembedding_lookup_sparse 的结果返回为prediction,并将嵌入返回为variable

embedding_lookup_sparse 的结果加上bias 成为损失函数和训练操作的logits。这意味着embedding_lookup_sparse 对密集张量执行类似w * xy = w * x + b 的一部分)的操作。

可能对于 one-hot encoding 或 SparseTensor,embedding_lookup_sparse 中的 weight 实际上是 w * x 的值,因为查找数据始终为 1,无需添加其他 0s。

我说的也很混乱。谁能帮忙详细解释一下?

【问题讨论】:

    标签: python tensorflow embedding


    【解决方案1】:

    embedding lookup 和 embedding lookup sparse 的主要区别在于,sparse 版本要求 id 和 weights 的类型为 SparseTensor。

    嵌入查找的工作原理:

    您传入某个大小的张量,embedding_lookup_sparse 会将张量的切片(由 sp_ids 参数引用的切片)乘以某个权重(也作为 sp_weight 传入;默认值为 1),然后返回新切片.

    没有偏见项。您可以通过引用多个要包含在输出中的元素来将张量的切片添加在一起。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-04
      • 2020-02-08
      • 2023-03-19
      • 1970-01-01
      相关资源
      最近更新 更多