Skip to content

Commit f891cd8

Browse files
committed
Fix failed test
Signed-off-by: abigailt <[email protected]>
1 parent 4bdf0c8 commit f891cd8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

art/attacks/inference/attribute_inference/black_box.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ def fit(self, x: np.ndarray, y: Optional[np.ndarray] = None) -> None:
161161
predictions = self.estimator.predict(x).reshape(-1, 1) * self.prediction_normal_factor
162162
if y is not None:
163163
y = y * self.prediction_normal_factor
164-
y = y.reshape(-1, 1)
164+
if y is not None:
165+
y = y.reshape(-1, 1)
165166

166167
# get vector of attacked feature
167168
y_attack = x[:, self.attack_feature]
@@ -226,7 +227,8 @@ def infer(self, x: np.ndarray, y: Optional[np.ndarray] = None, **kwargs) -> np.n
226227
x_test = np.concatenate((x, pred * self.prediction_normal_factor), axis=1).astype(np.float32)
227228
if y is not None:
228229
y = y * self.prediction_normal_factor
229-
y = y.reshape(-1, 1)
230+
if y is not None:
231+
y = y.reshape(-1, 1)
230232
else:
231233
x_test = np.concatenate((x, pred), axis=1).astype(np.float32)
232234
if y is not None:

0 commit comments

Comments
 (0)