Pytorch 读取t7文件

Pytorch 1.0以上可以使用:

c 复制代码
import torchfile

th_path = r"./path/xx.t7"
data = torchfile.load(th_path)

print(data.shape)

若data的尺寸为0,则将torch版本降为0.4.1,并使用以下函数:

c 复制代码
from torch.utils.serialization import load_lua

th_path = r"./path/xx.t7"
data = load_lua(th_path).numpy()

print(data.shape)

注意:

若是在Windows的系统中读取t7文件,一定要记得要用long_size=8

c 复制代码
data = torchfile.load(th_path,long_size=8)
或
data = load_lua(th_path,long_size=8).numpy()
相关推荐
用户51914958484512 分钟前
libcurl Headers API 释放后重利用漏洞:跨请求复用头句柄导致堆内存安全风险
人工智能·aigc
踩蚂蚁13 分钟前
自定义语音唤醒词:从训练到部署的完整链路实践
人工智能
用户51914958484518 分钟前
CVE-2025-1094 PostgreSQL SQL注入与WebSocket劫持远程代码执行利用工具
人工智能·aigc
金銀銅鐵1 小时前
用 Python 实现 Take-Away 游戏
python·游戏
IT_陈寒1 小时前
SpringBoot自动配置这个坑,我踩进去又爬出来了
前端·人工智能·后端
copyer_xyf2 小时前
Agent 流程编排
后端·python·agent
copyer_xyf2 小时前
Agent RAG
后端·python·agent
copyer_xyf2 小时前
【RAG】向量数据库:milvus
后端·python·agent
copyer_xyf3 小时前
Agent 记忆管理
后端·python·agent
冬奇Lab13 小时前
Agent 系列(23):Web Agent——让 Agent 真正浏览网页
人工智能·llm·agent