.pth is a zip archive (did you mean to use torch.jit.load()?)

2024-02-08 17:08
文章标签 use zip load torch mean jit archive pth

本文主要是介绍.pth is a zip archive (did you mean to use torch.jit.load()?),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

RuntimeError: bert.pth is a zip archive (did you mean to use torch.jit.load()?)
 

.pth is a zip archive (did you mean to use torch.jit.load()?)

原因
xxx.pth来自pytorch1.6或更高的版本。1.6之后pytorch默认使用zip文件格式来保存权重文件,导致这些权重文件无法直接被1.5及以下的pytorch加载。

解决方案
在pytorch1.6版本下运行:

state_dict = torch.load("xxx.pth")
torch.save(state_dict, "xxx.pth", _use_new_zipfile_serialization=False)
1
2

https://blog.csdn.net/song_wheaver/article/details/112527697


 

这篇关于.pth is a zip archive (did you mean to use torch.jit.load()?)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/691661

相关文章

类的load方法和initialize方法对比

1. load方法在main()之前被调用,而initialize方法在main()之后调用 load方法实际是在load_images过程中被调用的。load_images会将当前应用依赖的所有镜像(动态库)加载到内存,在在加载中首先是对镜像进行扫描,将所有包含 load 方法的类加入列表 loadable_classes ,然后从这个列表中逐一调用其所包含的 load 方法。 +[XXCl

pytorch torch.nn.functional.one_hot函数介绍

torch.nn.functional.one_hot 是 PyTorch 中用于生成独热编码(one-hot encoding)张量的函数。独热编码是一种常用的编码方式,特别适用于分类任务或对离散的类别标签进行处理。该函数将整数张量的每个元素转换为一个独热向量。 函数签名 torch.nn.functional.one_hot(tensor, num_classes=-1) 参数 t

torch.nn 与 torch.nn.functional的区别?

区别 PyTorch中torch.nn与torch.nn.functional的区别是:1.继承方式不同;2.可训练参数不同;3.实现方式不同;4.调用方式不同。 1.继承方式不同 torch.nn 中的模块大多数是通过继承torch.nn.Module 类来实现的,这些模块都是Python 类,需要进行实例化才能使用。而torch.nn.functional 中的函数是直接调用的,无需

Unity Adressables 使用说明(六)加载(Load) Addressable Assets

【概述】Load Addressable Assets Addressables类提供了加载 Addressable assets 的方法。你可以一次加载一个资源或批量加载资源。为了识别要加载的资源,你需要向加载方法传递一个键或键列表。键可以是以下对象之一: Address:包含你分配给资源的地址的字符串。Label:包含分配给一个或多个资源的标签的字符串。AssetReference Obj

How can I load the openai api configuration through js in html?

题意:怎样在HTML中通过JavaScript加载OpenAI API配置 问题背景: I am trying to send a request through js in my html so that openai analyzes it and sends a response, but if in the js I put the following: 我正在尝试通过HTM

Docker容器创建时,无法访问镜像源:Could not connect to archive.ubuntu.com:80

1.问题描述 当基于dockerfile创建容器时,遇到Could not connect to ...、Failed to fetch ...等异常时,大概原因是没有配置好容器创建所需的镜像源。这里以Ubuntu基础镜像源为例。 dockerfile内容 FROM ubuntuRUN apt update && apt install python3 -y && apt install

Tomcat启动报错:transport error 202: bind failed: Address already in use

Tomcat启动报错:transport error 202: bind failed: Address already in use 了,上网查找了下面这篇文章。也是一种解决办法。 下文来自:http://blog.csdn.net/sam031503/article/details/7037033 tomcat 启动日志报出以下错误:  ERROR: transport err

Unity Adressables 使用说明(五)在运行时使用 Addressables(Use Addressables at Runtime)

一旦你将 Addressable assets 组织到 groups 并构建到 AssetBundles 中,就需要在运行时加载、实例化和释放它们。 Addressables 使用引用计数系统来确保 assets 只在需要时保留在内存中。 Addressables 初始化 Addressables 系统在运行时第一次加载 Addressable 或进行其他 Addressable API 调

linux下zip加密压缩文件

zip -q -r  -P password zipfile.zip sourcefiles.txt                            #password 是加密密码 zipfile.zip 是生成的压缩文件 sourcefiles.txt 是被压缩的文件   zip [参数] <压缩包> <源文件>   使用zip格式打包文件     -r 递归,将指定目

JavaBug系列- Failed to load driver class com.mysql.cj.jdbc.Driver in either of HikariConfig class load

JavaBug系列之Mysql驱动问题 Java医生一、关于错误信息二、如何解决问题 Java医生 本系列记录常见Bug,以及诊断过程和原因 Java/一对一零基础辅导/企业项目一对一辅导/日常Bug解决/代码讲解/毕业设计等 V:study_51ctofx 一、关于错误信息 APPLICATION FAILED TO START Description: Fai