From b41755a27983d260b0077acdb57aabcf757489ec Mon Sep 17 00:00:00 2001 From: Martin Lange <32666496+lange-martin@users.noreply.github.com> Date: Thu, 24 Mar 2022 10:58:12 +0100 Subject: [PATCH] Switch harmful and helpful lists The most helpful samples are those with the "most positive -I_{up, loss}" (page 6 Koh and Liang paper). Since influences contains the I_{up, loss} for each training sample, the most helpful samples should be those indices in ascending order. --- pytorch_influence_functions/calc_influence_function.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pytorch_influence_functions/calc_influence_function.py b/pytorch_influence_functions/calc_influence_function.py index 8861cd4..5abad63 100644 --- a/pytorch_influence_functions/calc_influence_function.py +++ b/pytorch_influence_functions/calc_influence_function.py @@ -343,8 +343,8 @@ def calc_influence_single(model, train_loader, test_loader, test_id_num, gpu, influences.append(tmp_influence) display_progress("Calc. influence function: ", i, train_dataset_size) - harmful = np.argsort(influences) - helpful = harmful[::-1] + helpful = np.argsort(influences) + harmful = helpful[::-1] return influences, harmful.tolist(), helpful.tolist(), test_id_num