【发布时间】:2021-05-04 10:33:23
【问题描述】:
我正在尝试构建一个基于 BERT 的西班牙语文本分类器。所以我选择了一个名为 BETO https://github.com/scruz03/beto 的模型。我正在使用 Google Colab 并尝试复制在 https://colab.research.google.com/drive/1uRwg4UmPgYIqGYY4gW_Nsw9782GFJbPt#scrollTo=HhAqZLs3lwhW 之前引用的同一页面中引用的示例中指示的步骤。 我确实下载了未封装的 tensorflow 版本,而不是示例中提到的 pytorch 版本。我在tensorflow子目录下得到了以下文件:
但是,当我运行以下代码时:
# create the tokenizer and the model
tokenizer = BertTokenizer.from_pretrained("tensorflow/")
model = BertForMaskedLM.from_pretrained("tensorflow/")
model.eval()
我收到以下错误:
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-37-4b5a17f4238d> in <module>()
1 # create the tokenizer and the model
2 tokenizer = BertTokenizer.from_pretrained("tensorflow/")
----> 3 model = BertForMaskedLM.from_pretrained("tensorflow/")
4 model.eval()
/usr/local/lib/python3.6/dist-packages/transformers/modeling_utils.py in from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
982 "Error no file named {} found in directory {} or `from_tf` set to False".format(
983 [WEIGHTS_NAME, TF2_WEIGHTS_NAME, TF_WEIGHTS_NAME + ".index"],
--> 984 pretrained_model_name_or_path,
985 )
986 )
OSError: Error no file named ['pytorch_model.bin', 'tf_model.h5', 'model.ckpt.index'] found in directory tensorflow/ or `from_tf` set to False
感谢您的帮助。提前致谢。
【问题讨论】:
标签: python tensorflow multilingual text-classification bert-language-model