Skip to content

Commit 1928a46

Browse files
committed
Fix failed test
Signed-off-by: abigailt <[email protected]>
1 parent 48185c4 commit 1928a46

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
@@ -164,7 +164,8 @@ def fit(self, x: np.ndarray, y: Optional[np.ndarray] = None) -> None:
164164
predictions = self.estimator.predict(x).reshape(-1, 1) * self.prediction_normal_factor
165165
if y is not None:
166166
y = y * self.prediction_normal_factor
167-
y = y.reshape(-1, 1)
167+
if y is not None:
168+
y = y.reshape(-1, 1)
168169

169170
# get vector of attacked feature
170171
y_attack = x[:, self.attack_feature]
@@ -229,7 +230,8 @@ def infer(self, x: np.ndarray, y: Optional[np.ndarray] = None, **kwargs) -> np.n
229230
x_test = np.concatenate((x, pred * self.prediction_normal_factor), axis=1).astype(np.float32)
230231
if y is not None:
231232
y = y * self.prediction_normal_factor
232-
y = y.reshape(-1, 1)
233+
if y is not None:
234+
y = y.reshape(-1, 1)
233235
else:
234236
x_test = np.concatenate((x, pred), axis=1).astype(np.float32)
235237
if y is not None:

0 commit comments

Comments
 (0)