博客
关于我
python bert_gen.py 报错Unable to load weights from pytorch checkpoint file for......
阅读量:806 次
发布时间:2023-03-05

本文共 613 字,大约阅读时间需要 2 分钟。

环境:运行环境:WIN10BERT版本:Bert-VITS2.4

问题描述:运行Python脚本bert_gen.py时,出现以下错误:

Unable to load weights from pytorch checkpoint file for './bert/Erlangshen-MegatronBert-1.3B-Chinese/pytorch_model.bin'.If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True.

此错误提示表明尝试从PyTorch模型中加载TensorFlow 2.0的检查点文件。

解决方案:

  • 确认模型文件路径是否正确
  • 检查PyTorch和TensorFlow的版本兼容性
  • 如果是从TensorFlow检查点加载,请在初始化模型时设置from_tf=True
  • 具体操作步骤:

  • 确认模型文件路径是否正确,确保文件路径无误
  • 如果模型文件大小不符(约14.8GB),请重新下载完整文件
  • 确保PyTorch和TensorFlow的版本兼容
  • 在加载模型时,检查是否需要设置from_tf=True(如从TensorFlow检查点加载)
  • 如果问题依旧,建议清除旧的PyTorch检查点文件并重新初始化模型
  • 经过上述步骤后,应能够正常运行python bert_gen.py脚本。

    转载地址:http://pvafk.baihongyu.com/

    你可能感兴趣的文章
    python glob的安装和使用
    查看>>
    Python google drive API 下载,文件在哪里?
    查看>>
    Python GPS 模块:读取最新的 GPS 数据
    查看>>
    python grpc入门
    查看>>
    python gRPC测试helloworld
    查看>>
    python list,str的拼接与转换
    查看>>
    python mac地址_python中MAC地址打包问题
    查看>>
    Python Matplotlib Box并排绘制两个数据集
    查看>>
    python matplotlib简单使用
    查看>>
    Python Multiprocessing - 将类方法应用于对象列表
    查看>>
    python nltk nltk_data 离线安装,chatterbot
    查看>>
    python numba 转灰度图_使用NumPy、Numba的简单使用(二)
    查看>>
    python numpy矩阵索引_python – 在2D numpy ndarray或numpy矩阵中获取前N个值的索引
    查看>>
    python os.system
    查看>>
    Python os.system执行多条语句,os.system的返回值以及与os.popen的区别
    查看>>
    Python os和sys模块
    查看>>
    python os文件/目录
    查看>>
    Python Package 之 Faker(随机姓名、电话)
    查看>>
    python运算符优先级
    查看>>
    Python Panda TIME 系列重新采样
    查看>>