首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >TypeError:需要一个整数(got类型NoneType)

TypeError:需要一个整数(got类型NoneType)
EN

Stack Overflow用户
提问于 2022-01-13 15:40:02
回答 1查看 1.5K关注 0票数 1

目标:修改此distilbert-base-uncased模型以使用记事本模型

错误发生在第1.3节中。

内核:conda_pytorch_p36.我重新启动并运行了所有文件,并在工作目录中刷新了文件视图。

第1.3款:

代码语言:javascript
复制
# define the tokenizer
tokenizer = AutoTokenizer.from_pretrained(
        configs.output_dir, do_lower_case=configs.do_lower_case)

回溯:

代码语言:javascript
复制
Evaluating PyTorch full precision accuracy and performance:
/home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/transformers/data/processors/glue.py:67: FutureWarning: This function will be removed from the library soon, preprocessing should be handled with the  Datasets library. You can have a look at this example script for pointers: https://github.com/huggingface/transformers/blob/master/examples/pytorch/text-classification/run_glue.py
  warnings.warn(DEPRECATION_WARNING.format("function"), FutureWarning)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-31-1f864e3046eb> in <module>
    144 # Evaluate the original FP32 BERT model
    145 print('Evaluating PyTorch full precision accuracy and performance:')
--> 146 time_model_evaluation(model, configs, tokenizer)
    147 
    148 # Evaluate the INT8 BERT model after the dynamic quantization

<ipython-input-31-1f864e3046eb> in time_model_evaluation(model, configs, tokenizer)
    132 def time_model_evaluation(model, configs, tokenizer):
    133     eval_start_time = time.time()
--> 134     result = evaluate(configs, model, tokenizer, prefix="")
    135     eval_end_time = time.time()
    136     eval_duration_time = eval_end_time - eval_start_time

<ipython-input-31-1f864e3046eb> in evaluate(args, model, tokenizer, prefix)
     22     results = {}
     23     for eval_task, eval_output_dir in zip(eval_task_names, eval_outputs_dirs):
---> 24         eval_dataset = load_and_cache_examples(args, eval_task, tokenizer, evaluate=True)
     25 
     26         if not os.path.exists(eval_output_dir) and args.local_rank in [-1, 0]:

<ipython-input-31-1f864e3046eb> in load_and_cache_examples(args, task, tokenizer, evaluate)
    121     all_input_ids = torch.tensor([f.input_ids for f in features], dtype=torch.long)
    122     all_attention_mask = torch.tensor([f.attention_mask for f in features], dtype=torch.long)
--> 123     all_token_type_ids = torch.tensor([f.token_type_ids for f in features], dtype=torch.long)
    124     if output_mode == "classification":
    125         all_labels = torch.tensor([f.label for f in features], dtype=torch.long)

TypeError: an integer is required (got type NoneType)

如果还有什么可以添加到帖子中,请告诉我。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-01-14 10:23:45

开发人员在这个Git发行中解释了这种困境。

记事本与使用token_type_idsBERT进行了实验。

DistilBERT不使用来培训

因此,这将需要重新开发笔记本;删除/调整该模型中提到的所有token_type_ids

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70699247

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档