直接上代码解释预训练模型的转换过程,需要注意:
(1)若想完全转换pytorch模型,可直接转
(2)若想转换预训练模型,即包含权重不包含全连接层,则舍弃全连接层的部分即可
(3)如遇数据维度不对,需要对权重进行转置
环境:
pytorch 1.1.0
paddlepaddle 1.8.4
import torch
import paddle.fluid as fluid
from collections import OrderedDict
from model import ResNet3D
torch_weight = torch.load('r3d50_KM_200ep.pth', map_location=torch.device('cpu'))
# 全连接1039
weight = []
for torch_key

最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



