Skip to content

Commit

Permalink
Merge pull request #709 from plasmashen/master
Browse files Browse the repository at this point in the history
Fix the problem of text output from T5 model
  • Loading branch information
jxmorris12 committed Aug 28, 2023
2 parents 2abb4dd + 25f9b78 commit e3d05c4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion textattack/goal_functions/goal_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,15 @@ def _call_model_uncached(self, attacked_text_list):
if isinstance(batch_preds, list):
outputs.extend(batch_preds)
elif isinstance(batch_preds, np.ndarray):
outputs.append(torch.tensor(batch_preds))
outputs.append(batch_preds)
else:
outputs.append(batch_preds)
i += self.batch_size

if isinstance(outputs[0], torch.Tensor):
outputs = torch.cat(outputs, dim=0)
elif isinstance(outputs[0], np.ndarray):
outputs = np.concatenate(outputs).ravel()

assert len(inputs) == len(
outputs
Expand Down

0 comments on commit e3d05c4

Please sign in to comment.