当前位置:网站首页>Torch weight to mindspore
Torch weight to mindspore
2022-06-23 10:43:00 【leo0308】
0 Preface
because torch Ease of use and flexibility , A lot of research work is based on torch Realized .
However, in practical applications or other reasons, it is necessary to migrate to mindspore when , We all want to reuse directly torch Pre trained weights .
Of course mindspore turn torch It's the same thing .
1 Method
In short , It's actually a mapping process . The weight saved is actually a dict, Contains the name of the weight and the specific value , However, the organizational form of different frameworks will be different .
The difference is reflected in 2 spot : First, the naming organization of names is different , Such as torch in batchnorm The weight suffix of is generally .weight and .bias, and mindspore It is beta and gamma; Second, the storage format is different .
For the first difference , We need to list their weights separately , Match their names according to the rules .
For the second difference , We need to use it. torch and mindspore Each provides an interface for loading or saving weights , Treat the weight as dict This intermediate result , Then it can be processed with their own interfaces .
2 Implementation code
import torch
from mindspore.train import save_checkpoint, load_checkpoint
边栏推荐
- 最简单DIY串口蓝牙硬件实现方案
- Simplest DIY remote control computer system based on STM32 ② (wireless remote control + key control)
- File has not been synchronized when NFS is mounted
- Experience of using thread pool in project
- vector的介绍及使用
- Unity technical manual - limit velocity over lifetime sub module and inherit velocity sub module
- Implementing Domain Driven Design - using ABP framework - General guidelines
- Google Earth Engine(GEE)——GEDI L2A Vector Canopy Top Height (Ver
- 社招腾讯高P(高级产品经理)的面试手册
- Noi OJ 1.2 conversion between integer and Boolean C language
猜你喜欢

Stm32f1 and stm32subeide programming example - infrared tracking sensor driver

最简单DIY串口蓝牙硬件实现方案

Numerical calculation method

基于SqlSugar的开发框架循序渐进介绍(9)-- 结合Winform控件实现字段的权限控制

当 Pandas 遇见 SQL,一个强大的工具库诞生了

What is a good quick development framework like?

图片存储--引用

UWA上新|真人真机测试新增海外机型专区

ESP32-CAM高性价比温湿度监控系统配网与上网方案设计与实现

Musk's 18-year-old son petitioned to change his name to sever the father son relationship
随机推荐
Implement common C language string processing functions
Mysql-03. Experience of SQL optimization in work
最简单DIY基于蓝牙、51单片机和舵机的钢铁爱国者机关枪控制器
Google Earth Engine(GEE)——用不同方法计算slope对比案例分析
New technology aesthetics and original biological networking operating system reshape the whole house intelligence
ESP32-CAM无线监控智能网关的设计与实现
Golang quick start (3)
Why should poll/select use Nonblock when opening
最简单DIY基于51单片机的舵机控制器
Step by step introduction to sqlsugar based development framework (9) -- Realizing field permission control with WinForm control
2021-05-12 internal class
[day 23] given an array of length N, insert element x into the position specified by the array | array insertion operation 4
Five SQL functions for operation date that must be known in SQL tutorial
MySQL基础-笔记
Musk's 18-year-old son petitioned to change his name to sever the father son relationship
韦东山设备信息查询例程学习
开源二进制文件静态漏洞分析工具BinAbsInspector安装使用
为什么指针做形参没有改变对应的值
Interview Manual of social recruitment Tencent high P (Senior Product Manager)
华为云·维享会交流平台简介