TSNE(sklearn.manifold)KL分歧错误

时间:2017-03-08 19:00:31

标签: python python-2.7 machine-learning scikit-learn dimensionality-reduction

我试图使用tsne可视化我的示例数据。代码似乎工作正常,但我不确定输出的正确性。

tsne = manifold.TSNE(n_components = 2, 
                     random_state = 0, 
                     verbose = 5,
                     learning_rate = 80,
                     n_iter = 5000,
                     perplexity = 30,
                     method = "barnes_hut",
                     n_iter_without_progress = 30
                    )

transformed_data = tsne.fit_transform(x_std)

这是输出:

[t-SNE] Computing pairwise distances...
[t-SNE] Computing 91 nearest neighbors...
[t-SNE] Computed conditional probabilities for sample 264 / 264
[t-SNE] Mean sigma: 0.667425
[t-SNE] Iteration 25: error = 0.8046873, gradient norm = 0.0232980
[t-SNE] Iteration 50: error = 0.5615926, gradient norm = 0.0139973
[t-SNE] Iteration 75: error = 0.2540671, gradient norm = 0.0037830
[t-SNE] Iteration 100: error = 0.2289363, gradient norm = 0.0031010
[t-SNE] KL divergence after 100 iterations with early exaggeration: 0.228936
[t-SNE] Iteration 125: error = 0.1968820, gradient norm = 0.0022478
[t-SNE] Iteration 150: error = 0.1885508, gradient norm = 0.0020406
[t-SNE] Iteration 175: error = 0.1865089, gradient norm = 0.0019922
[t-SNE] Iteration 200: error = 0.1859080, gradient norm = 0.0019791
[t-SNE] Iteration 225: error = 0.1857601, gradient norm = 0.0019759
[t-SNE] Iteration 250: error = 0.1857159, gradient norm = 0.0019746
[t-SNE] Iteration 275: error = 0.1857016, gradient norm = 0.0019742
[t-SNE] Iteration 275: error difference 0.000000. Finished.
[t-SNE] Error after 275 iterations: 0.228936

在最后一行显示

[t-SNE] Error after 275 iterations: 0.228936

错误率来自以下行:"早期夸张100次迭代后的KL分歧:0.228936"。我读的几个例子,输出的最后一行的错误是上面2行的错误。我做得对吗?我错过了什么?

使用精确方法的另一项测试:

tsne = manifold.TSNE(n_components = 2, 
                     random_state = 0, 
                     verbose = 5,
                     learning_rate = 400,
                     n_iter = 5000,
                     method = "exact",
                     n_iter_without_progress = 300
                    )

transformed_data = tsne.fit_transform(x_std)

[t-SNE] Computing pairwise distances...
[t-SNE] Computed conditional probabilities for sample 264 / 264
[t-SNE] Mean sigma: 0.664578
[t-SNE] Iteration 25: error = 11.4506483, gradient norm = 0.1406410
[t-SNE] Iteration 50: error = 10.7174697, gradient norm = 0.1269968
[t-SNE] Iteration 75: error = 9.6377087, gradient norm = 0.1345971
[t-SNE] Iteration 100: error = 10.1510068, gradient norm = 0.1162036
[t-SNE] KL divergence after 100 iterations with early exaggeration: 10.151007
[t-SNE] Iteration 125: error = 0.1209401, gradient norm = 0.0063856
[t-SNE] Iteration 150: error = 0.1382205, gradient norm = 0.0117275
[t-SNE] Iteration 175: error = 0.1742659, gradient norm = 0.0140484
[t-SNE] Iteration 200: error = 0.1890085, gradient norm = 0.0169387
[t-SNE] Iteration 225: error = 0.2339525, gradient norm = 0.0177822
[t-SNE] Iteration 250: error = 0.2745199, gradient norm = 0.0190015
[t-SNE] Iteration 275: error = 0.2632307, gradient norm = 0.0188159
[t-SNE] Iteration 300: error = 0.2681131, gradient norm = 0.0187263
[t-SNE] Iteration 325: error = 0.2545400, gradient norm = 0.0182611
[t-SNE] Iteration 350: error = 0.2416118, gradient norm = 0.0180197
[t-SNE] Iteration 375: error = 0.2669461, gradient norm = 0.0179070
[t-SNE] Iteration 400: error = 0.2663364, gradient norm = 0.0178478
[t-SNE] Iteration 425: error = 0.2627337, gradient norm = 0.0183916
[t-SNE] Iteration 450: error = 0.2687405, gradient norm = 0.0198420
[t-SNE] Iteration 450: did not make any progress during the last 300 episodes. Finished.
[t-SNE] Error after 450 iterations: 10.151007

0 个答案:

没有答案