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

感谢您分享的模型代码,当我复现您的代码时,在emb_method=“bert”时,报了错? #9

Open
YeNiTing opened this issue Nov 6, 2020 · 5 comments

Comments

@YeNiTing
Copy link

YeNiTing commented Nov 6, 2020

No description provided.

@YeNiTing
Copy link
Author

YeNiTing commented Nov 6, 2020

错误为:;
Traceback (most recent call last):
File "main.py", line 108, in
fire.Fire()
File "D:\software\Anaconda3\envs\ynt2\lib\site-packages\fire\core.py", line 138, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name)
File "D:\software\Anaconda3\envs\ynt2\lib\site-packages\fire\core.py", line 468, in _Fire
target=component.name)
File "D:\software\Anaconda3\envs\ynt2\lib\site-packages\fire\core.py", line 672, in _CallAndUpdateTrace
component = fn(*varargs, **kwargs)
File "main.py", line 69, in train
output = model(x)
File "D:\software\Anaconda3\envs\ynt2\lib\site-packages\torch\nn\modules\module.py", line 550, in call
result = self.forward(*input, **kwargs)
File "C:\Users\YNT\Desktop\重要文件夹\数据集\EMLo相关\pytorch_bert_elmo_example-master\model.py", line 40, in forward
word_embs = self.get_bert(x)
File "C:\Users\YNT\Desktop\重要文件夹\数据集\EMLo相关\pytorch_bert_elmo_example-master\model.py", line 90, in get_bert
ids = self.tokenizer(sentence_lists, padding=True, return_tensors="pt")
TypeError: 'BertTokenizer' object is not callable

可是发现您代码里并不存在BertTokenizer对象?

@ShomyLiu
Copy link
Owner

ShomyLiu commented Nov 6, 2020

你好, 这个应该是版本问题。 Tokenizer这几次更新,导致API变化。
tokenizer定义在上面:
https://github.com/ShomyLiu/pytorch_bert_elmo_example/blob/master/model.py#L49

@YeNiTing
Copy link
Author

YeNiTing commented Nov 6, 2020

请问您transformers的版本为多少?

@ShomyLiu
Copy link
Owner

ShomyLiu commented Nov 6, 2020

tokenizers 0.8.1rc1
transformers 3.0.2

@YeNiTing
Copy link
Author

YeNiTing commented Nov 6, 2020

感谢!

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

2 participants