以下是导致错误的代码块

training_args = TrainingArguments(
    output_dir="my_awesome_mind_model",
    evaluation_strategy="epoch",
    save_strategy="epoch",
    learning_rate=3e-5,
    per_device_train_batch_size=32,
    gradient_accumulation_steps=4,
    per_device_eval_batch_size=32,
    num_train_epochs=10,
    warmup_ratio=0.1,
    logging_steps=10,
    load_best_model_at_end=True,
    metric_for_best_model="accuracy",
    push_to_hub=True,
)

trainer = Trainer(
    model=model,
    args=training_args,
    train_dataset=dataset["train"],
    # eval_dataset=encoded_minds["test"],
    tokenizer=feature_extractor,
    compute_metrics=compute_metrics,
)

trainer.train()

获取以下错误

NameError回溯(最近一次调用) 在<细胞系中:1>() 1 Trading_args=TrainingArguments( 2 OUTPUT_DIR="My_AWOWE_Mind_Model", 3 EVALUATION_STARTICY="纪元", 4 SAVE_STRATURE="纪元", 5学习率=3E-5,

4帧 /usr/local/lib/python3.10/dist-packages/transformers/training_args.py In_Setup_Device(自身) 1629自._n_GPU=1 1630其他: 1631 self.Distributed_State=PartialState(Backend=self.ddp_Backend) 1632自._n_GPU=1 1633如果不是,则为IS_Sagemaker_MP_Enable():

NameError:未定义名称‘PartialState’

我正在try 遵循拥抱脸的音频分类指南(在另一个数据集上为link,但在运行训练ARGS代码时,我得到的名称为"PartialState"Not Defined Error.

推荐答案

截至2023-05-11:

该错误似乎是由huggingface/accelerate库中的still open issue引起的.

目前,您可以try 以下解决方案:

Reinstall transformers & accelerate

pip uninstall -y transformers accelerate
pip install transformers accelerate

如果您使用的是CoLab/Jupyter,则为make sure to restart the notebook's Runtime.

安装Accelerate的开发版本

pip install git+https://github.com/huggingface/accelerate

与以前版本的变压器相反

# You might also need to uninstall transformers first: pip uninstall -y transformers
pip install transformers==4.28.0

Python相关问答推荐

Python会扔掉未使用的表情吗?

比较两个数据帧并并排附加结果(获取性能警告)

时间序列分解

在Python中处理大量CSV文件中的数据

ModuleNotFound错误:没有名为Crypto Windows 11、Python 3.11.6的模块

Pandas—合并数据帧,在公共列上保留非空值,在另一列上保留平均值

PyQt5,如何使每个对象的 colored颜色 不同?'

为什么NumPy的向量化计算在将向量存储为类属性时较慢?'

有没有一种ONE—LINER的方法给一个框架的每一行一个由整数和字符串组成的唯一id?

字符串合并语法在哪里记录

为什么if2/if3会提供两种不同的输出?

为什么常规操作不以其就地对应操作为基础?

如何将数据帧中的timedelta转换为datetime

如何用FFT确定频变幅值

随机森林n_估计器的计算

如何在表单中添加管理员风格的输入(PDF)

按列表分组到新列中

如何在Polars中处理用户自定义函数的多行结果?

如何在Django查询集中生成带有值列表的带注释的字段?

Pandas:根据相邻行之间的差异过滤数据帧