def kmeans_clustering(features, k=2): features = features.cpu().numpy().reshape(-1, features.shape[-2] * features.shape[-1]) kmeans = KMeans(n_clusters=k, random_state=0).fit(features) labels = kmeans.labels_.reshape(features.shape[0], features.shape[-2], features.shape[-1]) return labels
k-均值聚类
最新推荐文章于 2024-09-08 22:28:13 发布