def select(self):
self.evaluation()
while self.budgetLeft > 0:
# K-center-Greedy
selected_ids = []
unlabeled_tmp = deepcopy(self.unlabeled)
labeled_tmp = deepcopy(self.labeled)
for i in range(self.batch):
UL_dist = self.distMatrix[np.ix_(unlabeled_tmp, labeled_tmp)]
UL_dist_min = np.min(UL_dist, axis=1)
max_idx = np.argmax(UL_dist_min)
tar_idx = unlabeled_tmp[max_idx]
selected_ids.append(tar_idx)
unlabeled_tmp.remove(tar_idx)
labeled_tmp.append(tar_idx)
self.model_incremental_train(new_ids=selected_ids)
# ----------将选择的样本从无标记样本池中剔除--------------
for idx in selected_ids:
self.unlabeled.remove(idx)
# ----------将选择的样本加入训练样本集-------------------
for idx in selected_ids:
self.labeled.append(idx)
self.budgetLeft -= self.batch
self.evaluation()
CoreSet
最新推荐文章于 2023-12-15 19:15:23 发布