Skip to content

Commit 411b322

Browse files
committed
fix typos
1 parent 7693cb5 commit 411b322

File tree

7 files changed

+28
-29
lines changed

7 files changed

+28
-29
lines changed

interpretdl/interpreter/bidirectional_transformer.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ def interpret(self,
110110
R = R + np.matmul(np.matmul(attn, m), R)
111111
else:
112112
assert "please specify the attentional perception mode"
113-
114113

115114
total_gradients = np.zeros((b, h, s, s))
116115
for alpha in np.linspace(0, 1, steps):
@@ -229,7 +228,7 @@ def text_to_input_fn(raw_text):
229228
R = np.eye(s, s, dtype=attns[0].dtype)
230229
R = np.expand_dims(R, 0)
231230

232-
if ap_mode == 'head':
231+
if ap_mode == 'head':
233232
for i, attn in enumerate(attns):
234233
if i < start_layer:
235234
continue
@@ -268,8 +267,8 @@ def text_to_input_fn(raw_text):
268267
explanation = R[:, 0, :] * grad_head_mean[:, 0, :] # NLP tasks return explanations for all tokens, including [CLS] and [SEP].
269268

270269
# intermediate results, for possible further usages.
271-
self.predcited_label = preds
272-
self.predcited_proba = proba
270+
self.predicted_label = preds
271+
self.predicted_proba = proba
273272

274273
if visual:
275274
# TODO: visualize if tokenizer is given.

interpretdl/interpreter/gradient_shap.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ def interpret(self,
7272

7373
self._build_predict_fn(gradient_of='probability')
7474

75-
_, predcited_labels, predcited_probas = self.predict_fn(data, labels)
76-
self.predcited_labels = predcited_labels
77-
self.predcited_probas = predcited_probas
75+
_, predicted_label, predicted_proba = self.predict_fn(data, labels)
76+
self.predicted_label = predicted_label
77+
self.predicted_proba = predicted_proba
7878
if labels is None:
79-
labels = predcited_labels
79+
labels = predicted_label
8080

8181
def add_noise_to_inputs(data):
8282
max_axis = tuple(np.arange(1, data.ndim))
@@ -181,8 +181,8 @@ def interpret(self,
181181
bs = data.shape[0]
182182

183183
gradients, labels, data_out, probas = self.predict_fn(data, labels, None)
184-
self.predcited_labels = labels
185-
self.predcited_probas = probas
184+
self.predicted_label = labels
185+
self.predicted_proba = probas
186186

187187
labels = labels.reshape((bs, ))
188188
total_gradients = np.zeros_like(gradients)

interpretdl/interpreter/integrated_gradients.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ def interpret(self,
8787
self.baselines = baselines
8888

8989
# obtain the labels (and initialization).
90-
_, predcited_labels, predcited_probas = self.predict_fn(data, labels)
91-
self.predcited_labels = predcited_labels
92-
self.predcited_probas = predcited_probas
90+
_, predicted_label, predicted_proba = self.predict_fn(data, labels)
91+
self.predicted_label = predicted_label
92+
self.predicted_proba = predicted_proba
9393
if labels is None:
94-
labels = predcited_labels
94+
labels = predicted_label
9595

9696
labels = np.array(labels).reshape((bsz, ))
9797

@@ -208,8 +208,8 @@ def text_to_input_fn(raw_text):
208208
ig_gradients = total_gradients * data_out / steps
209209

210210
# intermediate results, for possible further usages.
211-
self.predcited_label = label
212-
self.predcited_proba = proba
211+
self.predicted_label = label
212+
self.predicted_proba = proba
213213

214214
if visual:
215215
# TODO: visualize if tokenizer is given.

interpretdl/interpreter/lime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ def predict_fn_for_lime(*inputs):
261261
batch_size=batch_size)
262262

263263
# intermediate results, for possible further usages.
264-
self.predcited_proba = probability
264+
self.predicted_proba = probability
265265
self.lime_results['probability'] = {c: probability[c] for c in classes_to_interpret.ravel()}
266266
self.lime_results['r2_scores'] = r2_scores
267267
self.lime_results['lime_weights'] = lime_weights

interpretdl/interpreter/occlusion.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ def interpret(self,
8383
baselines = np.repeat(baselines, len(data), 0)
8484

8585
probas, label, _ = self.predict_fn(data, None)
86-
self.predcited_labels = labels
87-
self.predcited_probas = probas
86+
self.predicted_label = labels
87+
self.predicted_proba = probas
8888

8989
sliding_windows = np.ones(sliding_window_shapes)
9090

interpretdl/interpreter/smooth_grad.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ def interpret(self,
7272
self._build_predict_fn(gradient_of='probability')
7373

7474
# obtain the labels (and initialization).
75-
_, predcited_labels, predcited_probas = self.predict_fn(data, labels)
76-
self.predcited_labels = predcited_labels
77-
self.predcited_probas = predcited_probas
75+
_, predicted_label, predicted_proba = self.predict_fn(data, labels)
76+
self.predicted_label = predicted_label
77+
self.predicted_proba = predicted_proba
7878
if labels is None:
79-
labels = predcited_labels
79+
labels = predicted_label
8080
labels = np.array(labels).reshape((bsz, ))
8181

8282
# SmoothGrad
@@ -196,8 +196,8 @@ def text_to_input_fn(raw_text):
196196
sg_gradients = total_gradients / n_samples
197197

198198
# intermediate results, for possible further usages.
199-
self.predcited_label = label
200-
self.predcited_proba = proba
199+
self.predicted_label = label
200+
self.predicted_proba = proba
201201

202202
if visual:
203203
# TODO: visualize if tokenizer is given.

interpretdl/interpreter/smooth_grad_v2.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ def interpret(self,
7979
self._build_predict_fn(gradient_of='probability')
8080

8181
# obtain the labels (and initialization).
82-
_, predcited_labels, predcited_probas = self.predict_fn(data, labels)
83-
self.predcited_labels = predcited_labels
84-
self.predcited_probas = predcited_probas
82+
_, predicted_label, predicted_proba = self.predict_fn(data, labels)
83+
self.predicted_label = predicted_label
84+
self.predicted_proba = predicted_proba
8585
if labels is None:
86-
labels = predcited_labels
86+
labels = predicted_label
8787

8888
labels = np.array(labels).reshape((1, ))
8989

0 commit comments

Comments
 (0)