首页 > 解决方案 > 我们可以使用带有 t-sne 功能的 tdqm 进度条吗?

问题描述

我正在运行一个程序,使用 t-sne 将 MNIST 数据的维度从 784-dim 减少到 2-dim。

该程序需要很长时间才能完成,我想使用 tqdm 进度条跟踪进度。

我想知道如何使用 t-sne 功能添加 tqdm 进度条。tqdm 在循环中运行良好。

我不知道如何将其用于功能。

# TSNE
from sklearn.manifold import TSNE

# Picking the top 1000 points as TSNE takes a lot of time for 15K points
data_1000 = standardized_data[0:30000,:]
labels_1000 = labels[0:30000]

# configuring the parameteres
# the number of components = 2
# default perplexity = 30
# default learning rate = 200
# default Maximum number of iterations for the optimization = 1000
model = TSNE(n_components=2, random_state=0, perplexity=200,n_iter=5000)

# I want to keep track of progress for function 
tsne_data = model.fit_transform(data_1000)

标签: pythontqdm

解决方案


您必须通知tqdm进度。在您的情况下,TSNE是一个外部函数,所有迭代都在TSNE. 除非您将TSNE代码更改为 notify tqdm,否则无法使用tqdm此过程。


推荐阅读