From 3af7f51e04aaaf47cb6c2284b3e279914b770e5a Mon Sep 17 00:00:00 2001 From: tosemml <97384583+tosemml@users.noreply.github.com> Date: Tue, 8 Aug 2023 14:50:26 -0700 Subject: [PATCH] Minor improvement with numpy --- experiments/stability.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/experiments/stability.py b/experiments/stability.py index 8685dd4..8124e65 100644 --- a/experiments/stability.py +++ b/experiments/stability.py @@ -132,11 +132,7 @@ def add_image_epsilon(X, n_examples=100, mnist=False): n_p = np.random.normal(loc=0, scale=1, size=(n_examples, 5, 224, 224, 3)) # Perturb instances - neighbors = [] - for i in range(n_examples): - neighbors.append(X_to_eps[i] + n_p[i]) - neighbors = np.array(neighbors) - + neighbors = np.add(X_to_eps[:n_examples],n_p[:n_examples]) return neighbors