TensorFlow 2.0 中 tf.contrib.factorization.KMeans 的 API 是什么?

What is the equivalent API of tf.contrib.factorization.KMeans in TensorFlow 2.0?

在 Tensorflow 1.13.1 中,聚类模型可以使用 KMeans 算法构建,使用 tf.contrib.factorization.KMeans 但升级到 TensorFlow 2.0 后,我发现很难定位适合 API 用于构建聚类模型。我找到了 K-Means tf.compat.v1.estimator.experimental.KMeans 的估计器 API。但是,它不像前者那样对开发人员友好。我需要使用 TensorFlow 实施聚类模型,但不确定哪个 API 适合。

旧的 KMeans API 被重构以遵循 Estimator API 并且 tf.contrib.factorization.KMeans 甚至在迁移到 Tensorflow 2.0 之前就被弃用了。 "estimator" 执行 k-means 的方法在 1.15 and 2.x.

中是相同的

如果您正在寻找更多 "friendly" 方法,据我所知,例如scikit learn。估算器不会很快消失,因此熟悉它们并不是一个坏主意(尽管存在学习曲线)。