首页 > 解决方案 > ImportError:无法导入名称“warmup_linear”

问题描述

尝试导入warmup_linear时,出现此错误

ImportError: cannot import name 'warmup_linear'

进口 -

from pytorch_pretrained_bert.optimization import BertAdam, warmup_linear

需求文件

boto3==1.9.198
botocore==1.12.198
certifi==2019.6.16
chardet==3.0.4
docutils==0.14
h5py==2.9.0
idna==2.8
jmespath==0.9.4
Keras==2.2.4
Keras-Applications==1.0.8
Keras-Preprocessing==1.1.0
numpy==1.17.0
Pillow==6.1.0
python-dateutil==2.8.0
pytorch-pretrained-bert==0.6.2
PyYAML==5.1.1
regex==2019.6.8
requests==2.22.0
s3transfer==0.2.1
scipy==1.3.0
seqeval==0.0.12
six==1.12.0
torch==1.1.0
torchvision==0.3.0
tqdm==4.32.2
urllib3==1.25.3

导入“warmup_linear”需要做什么?

标签: pytorchtorchbert-language-model

解决方案


将导入行更改为:

from pytorch_pretrained_bert.optimization import BertAdam, WarmupLinearSchedule

因为脚本中没有命名类warmup_linearoptimization.py


推荐阅读