torch序列化
【摘要】 同一张文件需要7ms左右:
import timeimport torchimport torch.nn.functional as fif __name__ == '__main__': for i in range(200): x = torch.rand(1, 3, 1280, 720) # torch.set_num_threads(3) torch.save(x...
同一张文件需要7ms左右:
-
import time
-
import torch
-
import torch.nn.functional as f
-
if __name__ == '__main__':
-
for i in range(200):
-
x = torch.rand(1, 3, 1280, 720)
-
# torch.set_num_threads(3)
-
-
torch.save(x, 'd:/lib/'+str(0)+'.dat')
-
start = time.time()
-
aaa= torch.load('d:/lib/'+str(0)+'.dat')
-
print('time4', time.time() - start,aaa.size())
import time
from distributed.protocol import serialize, deserialize
import cv2
import torch
import torch.nn.functional as f
if __name__ == '__main__':
obj={'mat':torch.randn(10, 10),'name': '10','test':{'entry':1}}
torch.save(obj,'test.dat' )
for i in range(1000):
img = cv2.imread('
文章来源: blog.csdn.net,作者:网奇,版权归原作者所有,如需转载,请联系作者。
原文链接:blog.csdn.net/jacke121/article/details/84342788
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)