Skip to content

Commit

Permalink
fix bugs on windows, default convert to int64 (PaddlePaddle#1016)
Browse files Browse the repository at this point in the history
  • Loading branch information
linjieccc authored Sep 13, 2021
1 parent 398473b commit 71aff69
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions paddlenlp/taskflow/dependency_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,15 +412,15 @@ def convert_example(example, vocabs, fix_len=20):
return [
pad_sequence(
[np.array(
ids[:fix_len], dtype=int) for ids in words],
ids[:fix_len], dtype=np.int64) for ids in words],
fix_len=fix_len)
]


def flat_words(words, pad_index=0):
mask = words != pad_index
lens = np.sum(mask.astype(int), axis=-1)
position = np.cumsum(lens + (lens == 0).astype(int), axis=1) - 1
lens = np.sum(mask.astype(np.int64), axis=-1)
position = np.cumsum(lens + (lens == 0).astype(np.int64), axis=1) - 1
lens = np.sum(lens, -1)
words = words.ravel()[np.flatnonzero(words)]

Expand All @@ -433,7 +433,7 @@ def flat_words(words, pad_index=0):

max_len = words.shape[1]

mask = (position >= max_len).astype(int)
mask = (position >= max_len).astype(np.int64)
position = position * np.logical_not(mask) + mask * (max_len - 1)
return words, position

Expand Down

0 comments on commit 71aff69

Please sign in to comment.