用tensorflow实现LDA(latent dirichlet allocation)的优势

Advantages to implement LDA(latent dirichlet allocation) with tensorflow

想用tensorflow实现LDA作为实践,我觉得tensorflow版本可能有以下优点:

虽然我检查了一些 python 的 lda 实现(例如,https://github.com/ariddell/lda/),但我不知道可以使用哪些 tensorflow 操作,应该构建什么样的图以及什么我应该选择优化器。因为 gibbs 采样的过程看起来就像所有关于文档主题、主题词矩阵和主题计数的逐元素更新 table。那么tensorflow可以做些什么来简化和优化这个过程呢?

我能否将生成的文档与真实输入文档的可能性作为优化目标,并利用梯度提升优化器来最小化可能性的负值,从而获得 alpha、beta 和 doc-topics 分布?因为如果这里是tractable,tensorflow绝对可以用在这里

关于如何 probabilistic programming benefits from deep probabilistic programming 系统的更广泛问题,有许多相关答案。

我可以针对 TensorFlow 中的 Latent Dirichlet Allocation (LDA) 给出一个明确的答案。一个关键的好处是认识到 LDA 只是一个模型。给定这个模型,以及一个表示为逐项矩阵的数据集(例如,通过 tf.SparseTensor), TensorFlow lets you not only perform scalable inference but very flexible inference. Specific ops to use in TF depends on the specific algorithm. You can write a Gibbs sampler or coordinate ascent variational inference algorithm—both highly efficient for LDA (usable with manual tf.assign ops on trainable variables). CAVI is computationally and memory-efficient, scaling to millions of documents and reifiable with efficient data pipelines such as tf.data.

借助 TensorFlow,您还可以使用黑盒变分推理等通用方法,这些方法用途极为广泛,并且不需要手动 tf.assign 操作。一旦你编写了它来很好地解决你的问题,你就可以通过多种方式扩展 LDA,例如使用非共轭先验、分层先验和深度网络参数化(可能使用 tf.layers). Generic methods require tools such as TensorFlow optimizers and TensorFlow's automatic differentiation for gradient-based optimization. These are not available in Python unless you expoit tracing tools such as autograd.

我有运行这两个模型,所以我想我从实践中得到了一些想法。 LDA 的输出是主题分布和词分布,输入是文档中的词。 Word2Vec 的输出是句子的向量表达。在你的应用场景中,你的目标是推荐相似的主题,而不是相似的句子。例如,"I find a very cute cat."、"My uncle's cat is fat and I feed it foods, I'm satisfied."这两个句子的意思不同,但是这两个句子包含的是同一个主题——猫。 希望对你有帮助。