VICO-UoE / DatasetCondensation

Dataset Condensation (ICLR21 and ICML21)
MIT License
473 stars 91 forks source link

Code for running the herding baselines #15

Closed rajasbansal closed 2 years ago

rajasbansal commented 2 years ago

I am trying to run the baseline for herding, but I see that the codebase pulls preprocessed versions of the dataset from google drive. Could you share the scripts used to run the herding algorithm?

PatrickZH commented 2 years ago

Hi, this is the pseudocode for herding algorithm. You need to run it class by class.

mean = torch.mean(features, dim=0, keepdim=True)
idx_selected = []
idx_left = np.arange(features.shape[0]).tolist()
for i in range(num):
    det = mean*(i+1) - torch.sum(features[idx_selected], dim=0)
    dis = distance(det, features[idx_left])
    idx = torch.argmin(dis)
    idx_selected.append(idx_left[idx])
    del idx_left[idx]