Skip to content

Commit

Permalink
Creating new bool tensor straight away instead of regular clone
Browse files Browse the repository at this point in the history
  • Loading branch information
KasperFyhn committed Oct 31, 2023
1 parent 3f474f8 commit fbe8bcf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
1 change: 0 additions & 1 deletion paper/src/ents_heads_extraction.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Pipeline for headwords/entities extractions and frequency count."""
import spacy

from relationextraction import SpacyRelationExtractor # noqa
from conspiracies.docprocessing.headwordextraction import contains_ents


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ def get_pred_mask(tensor):
where B is the batch size, L is the sequence length.
:return: masked binary tensor with the same shape.
"""
res = tensor.clone()
res[tensor == pred_tag2idx["O"]] = 1
res[tensor != pred_tag2idx["O"]] = 0
return res.bool()
res = tensor.bool()
res[tensor == pred_tag2idx["O"]] = True
res[tensor != pred_tag2idx["O"]] = False
return res


def filter_pred_tags(pred_tags, tokens):
Expand Down

0 comments on commit fbe8bcf

Please sign in to comment.