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

Numpy Error #320

Open
akhileshrai003 opened this issue Jan 3, 2023 · 0 comments
Open

Numpy Error #320

akhileshrai003 opened this issue Jan 3, 2023 · 0 comments

Comments

@akhileshrai003
Copy link

import nlpaug.augmenter.word as naw
aug = naw.ContextualWordEmbsAug()
text="Transformers are the most popular toys"
print(f"original text:{text}")
print(f"Augmented text: {aug.augment(text)}")

original text:Transformers are the most popular toys

RuntimeError Traceback (most recent call last)
Input In [28], in <cell line: 3>()
1 text="Transformers are the most popular toys"
2 print(f"original text:{text}")
----> 3 print(f"Augmented text: {aug.augment(text)}")

File ~/.local/lib/python3.9/site-packages/nlpaug/base_augmenter.py:98, in Augmenter.augment(self, data, n, num_thread)
96 elif self.class.name in ['AbstSummAug', 'BackTranslationAug', 'ContextualWordEmbsAug', 'ContextualWordEmbsForSentenceAug']:
97 for _ in range(aug_num):
---> 98 result = action_fx(clean_data)
99 if isinstance(result, list):
100 augmented_results.extend(result)

File ~/.local/lib/python3.9/site-packages/nlpaug/augmenter/word/context_word_embs.py:471, in ContextualWordEmbsAug.substitute(self, data)
468 if not len(masked_texts):
469 continue
--> 471 outputs = self.model.predict(masked_texts, target_words=original_tokens, n=2)
473 # Update doc
474 for original_token, aug_input_pos, output, masked_text in zip(original_tokens, aug_input_poses, outputs, masked_texts):

File ~/.local/lib/python3.9/site-packages/nlpaug/model/lang_models/bert.py:113, in Bert.predict(self, texts, target_words, n)
111 seed = {'temperature': self.temperature, 'top_k': self.top_k, 'top_p': self.top_p}
112 target_token_logits = self.control_randomness(target_token_logits, seed)
--> 113 target_token_logits, target_token_idxes = self.filtering(target_token_logits, seed)
114 if len(target_token_idxes) != 0:
115 new_tokens = self.pick(target_token_logits, target_token_idxes, target_word=target_token, n=10)

File ~/.local/lib/python3.9/site-packages/nlpaug/model/lang_models/language_models.py:146, in LanguageModels.filtering(self, logits, seed)
144 if 'cuda' in self.device:
145 idxes = idxes.cpu()
--> 146 idxes = idxes.detach().numpy().tolist()
147 else:
148 idxes = np.arange(len(logits)).tolist()

RuntimeError: Numpy is not available

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant