Hello! I have this code and I want to get the variance inside each cluster. Thanks for helping.
import torchvision.datasets as dsets
train_dataset = dsets.MNIST(root=’./data’, train=True, transform=transforms.ToTensor(), download=True)
from sklearn.cluster import KMeans
num_class=10
data = train_dataset.data.numpy()
data=data.reshape(-1,28*28)
kmeans = KMeans(n_clusters=num_class, random_state=0).fit(data)
center=kmeans.cluster_centers_
centers=torch.from_numpy(center)