Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the generation model work with numpy 1.24.0 #67

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions generation/strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def __init__(self, batch_size, invalid_slices=[], temperature=1., top_k=200, eps
if end_tokens is None:
end_tokens = []
self.end_tokens = end_tokens
self._is_done = np.zeros(self.batch_size, dtype=np.bool)
self._is_done = np.zeros(self.batch_size, dtype=np.bool_)

@property
def is_done(self) -> bool:
Expand Down Expand Up @@ -43,7 +43,7 @@ def forward(self, logits, tokens, mems, temperature=None):
return tokens, mems

def finalize(self, tokens, mems):
self._is_done = np.zeros(self.batch_size, dtype=np.bool)
self._is_done = np.zeros(self.batch_size, dtype=np.bool_)
return tokens, mems


Expand Down Expand Up @@ -77,7 +77,7 @@ def _init_cache(self):
self.cached_beam_scores = 0 # [batch_size]
self.cached_beam_ngram_bans = [[{} for _ in range(self.num_beams)] for _ in range(self.batch_size)]
self.length_generated = 0
self._is_done = np.zeros(self.batch_size, dtype=np.bool)
self._is_done = np.zeros(self.batch_size, dtype=np.bool_)

def _add_end_beams(self, score, beam, batch_idx):
score = score / ((5.0 + len(beam)) / 6) ** self.length_penalty # Magic number for OpenNMT
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ icetk
apex
scipy
dataclass_wizard
cpm_kernels
cpm_kernels
numpy>=1.24.0