当前位置:网站首页>Hugging face's problem record I
Hugging face's problem record I
2022-07-28 06:34:00 【SCHLAU_ tono】
Error 1.
Torch.utils.datasets and huggingface Of datasets It's different
Error 2. cuDNN error: CUDNN_STATUS_NOT_INITIALIZED
To be precise , This is not Hugging face The problem of , I'm using it Torch Problems encountered in , Now also collect them
The main reasons are CUDA runtime version Don't fit , Solution reference post :
pip install torch==1.8.0+cu111 torchvision==0.9.0+cu111 torchaudio==0.8.0 -f https://download.pytorch.org/whl/torch_stable.html
Error 3. vars() argument must have dict attribute?
The reason for this problem is mostly due to the use of customized dataset, But when training the model, there is no relative data_collator
The problem code is as follows :
encoded_texts = tokenizer(texts, padding = True, truncation = True, return_tensors = 'pt')
labels = torch.tensor(labels)
dataset = TensorDataset(encoded_texts['input_ids'], encoded_texts['attention_mask'], labels)
there dataset The type is torch.util.dataset, trainer By default, the incoming dataset yes datasets , So use the default default_data_collator Extract the data .
resolvent : Customize data_collator Function and then add TrainingArguments in . The code is as follows :
customised_data_collector(features):
batch = {
}
batch['input_ids'] = torch.stack([f[0] for f in features])
batch['attention_mask'] = torch.stack([f[1] for f in features])
batch['labels'] = torch.stack([f[2] for f in features])
return batch
################
TrainingArguments(..., data_collator=customised_data_collector ,...)
Reference resources post
Error 4. TypeError: forward() got an unexpected keyword argument ‘label’
The reason for this error is complicated , And I finally failed to solve this problem directly . Here we only record some possible reasons and solutions :
- The parameter names of some models are
labelsinstead of label. Solutiondatasets.rename_column("label", "labels")Change name - Jupyter Notebook Self madness , Just restart the kernel and run again . Reference resources post
- Somewhat model for example
MT5EncoderModelandT5EncoderModelJust the basic model , No,labelParameters . Reference model source code forward(). if necessary Sequence classification. You need to customize Model, Reference resourcesBertForSequenceClassificationThe implementation of the Source code
How to be in Colab Load in Google Drive The file of .
The article Seven kinds of loading are introduced in detail Google drive The way . I use the sixth method , Mount the hard disk locally (Mount the drive locally). Write the following code in the file :
from google.colab import drive
drive.mount('/content/drive')
The address path when reading the file is as follows 
(This screenshot is from the article “7 ways to load external data into Google Colab” B. Chen )
About Evaluate Metrics
Official website about all Metric Introduction to :https://huggingface.co/evaluate-metric
Yes 28 Different matrices , Stick it on the bottom Official statement
>>>from datasets import list_metrics
>>>metrics_list = list_metrics()
>>>len(metrics_list)
>28
>>>print(metrics_list)
['accuracy', 'bertscore', 'bleu', 'bleurt', 'cer', 'comet', 'coval', 'cuad', 'f1', 'gleu', 'glue', 'indic_glue', 'matthews_correlation', 'meteor', 'pearsonr', 'precision', 'recall', 'rouge', 'sacrebleu', 'sari', 'seqeval', 'spearmanr', 'squad', 'squad_v2', 'super_glue', 'wer', 'wiki_split', 'xnli']
Common use combinations :metric = load_metric("glue","mrpc")
Show at the same time accuracy and f1 fraction 
How to be in colab Load in python file (saved on the google drive)
In the load google After the hard disk ,!python 'filepath'
How to be in python Use... In the document pip install
If you are directly in python It says in the file pip install packagename Will jump out Syntax Error. So change to import pip package , Use pip The method built in the package is used to download the third-party library . Solution reference post Why does “pip install” inside Python raise a SyntaxError?
import pip
package_names=['datasets', 'transformers'] #packages to install
pip.main(['install'] + package_names + ['--upgrade'])
# --upgrade to install or update existing packages
Problem 1. Train loss is decreasing, but accuracy remain the same
Train_loss Falling but accuracy There is no change
Probable cause :
- Over fitting . You can try to use
weight_decayin theTrainingArguments,hidden_dropout_probstaymodel.from_pretrained(...)And data augmentation solve . Reference resources post
边栏推荐
- Pytorch learning notes 2 - about tensor
- 听说你也在实习|当我采访了几个大三实习生之后。
- NFT数藏盲盒+模式系统开发
- A NOVEL DEEP PARALLEL TIME-SERIES RELATION NETWORK FOR FAULT DIAGNOSIS
- QT parse string into JSON data and parse
- Paper artifact vs code + latex + latex workshop
- VI and VIM commands
- qt解析字符串转为json数据并解析
- Pycharm2019 set editor theme and default code
- 保研面试中常见的英语问题有哪些?
猜你喜欢

I heard that you are also practicing when I interviewed several junior interns.

qt批量操作控件,并设置信号槽

自定义组件--父子组件之间的通信

How can fluke dsx2-5000 and dsx2-8000 modules find the calibration expiration date?

Matlab simulation of radar imaging 4 - range resolution analysis

【YOLOv5】环境搭建:Win11 + mx450

小程序navigator无法跳转(debug)

雷达成像 Matlab 仿真 1 —— LFM信号及其频谱

OpenGL的开发环境配置【VS2017】+常见问题

Servlet
随机推荐
Filter
qt解析字符串转为json数据并解析
Weight decay
听说你也在实习|当我采访了几个大三实习生之后。
Word自动目录字体修改和行间距的问题
Why should fluke dsx2-5000 network cable tester be calibrated once a year?
当前学习进度
Pycharm2019设置编辑器主题和默认代码
What are the common English questions in the postgraduate interview?
自定义组件--数据监听器
Vscode中,无法打开源文件 “Adafruit_GFX.h“
Bag of tricks training convolution network skills
正反斜杠笔记
【YOLOv5】环境搭建:Win11 + mx450
MFC 使用控制台打印程序信息
IMS-FACNN(Improved Multi-Scale Convolution Neural Network integrated with a Feature Attention Mecha
Selection of PLC
How to use the bit error meter?
[yolov5] environment construction: win11 + mx450
JSP should pass parameters to the background while realizing the file upload function