当前位置:网站首页>Ascend 910 realizes tensorflow1.15 to realize the Minist handwritten digit recognition of lenet network
Ascend 910 realizes tensorflow1.15 to realize the Minist handwritten digit recognition of lenet network
2022-07-07 14:40:00 【Hua Weiyun】
One 、 Environment and preparation
CPU/GPU Reappearance using Huawei cloud ModelArts-CodeLab platform
Ascend Reappearance using Huawei cloud ModelArts- development environment -Notebook
original Lenet Code link :https://gitee.com/lai-pengfei/LeNet
Two 、 stay CPU/GPU Run the original code in
First step : open CodeLab
notes : If you need to switch GPU resources , Can point
Resource selection GPU resources , have access to 1 Hours ,1 When I was young, I needed to renew my time manually
Click on the Terminal Enter the terminal interface :
Terminal interface :
The second step : Enter into work Catalog and git clone Related codes
git clone https://gitee.com/lai-pengfei/LeNet
You can see on the left git Down the code
The third step : Switch TensorFlow Running environment
source activate /home/ma-user/anaconda3/envs/TensorFlow-1.13.1/
Here is 1.13 Of , But it's not a big problem , Big difference is not bad , You can also run and 1.15 almost
Step four : Enter the folder and execute the original code
cd cd LeNet/python Train.py
Running :
Running results :
3、 ... and 、 Model migration
The environment uses Huawei cloud - development environment Notebook
Create an environment
Mirror select the checked
The specifications and other settings are shown in the figure below :
Environment and code download reference CPU/GPU
Switch to Ascend Under the TensorFlow 1.15 Running environment
source activate /home/ma-user/anaconda3/envs/TensorFlow-1.15.0/
Code changes
Modify the Train.py
Document address :https://www.hiascend.com/document/detail/zh/CANNCommunityEdition/51RC2alpha007/moddevg/tfmigr/atlasmprtg_13_0011.html
Add the code to introduce the package :
from npu_bridge.npu_init import *
Modify to create session And initialize the resource related code
This step is mainly in sess.run(tf.initialize_all_variables()) Add the following lines of code before
config = tf.ConfigProto()custom_op = config.graph_options.rewrite_options.custom_optimizers.add()custom_op.name = "NpuOptimizer"config.graph_options.rewrite_options.remapping = RewriterConfig.OFF # Must explicitly close config.graph_options.rewrite_options.memory_optimization = RewriterConfig.OFF # Must explicitly close sess = tf.Session(config=config)
This Demo You also need to change the first line of related library code
Original code :
import tensorflow.examples.tutorials.mnist.input_data as input_data
It is amended as follows :
from tensorflow.examples.tutorials.mnist import input_data
Run code
python Train.py
notice W tf_adapt Almost words indicate that NPU resources
Operation process :
Can open another Terminal Check whether it is really used Ascend, In the new Terminal Use the following command in :
npu-smi info
Running results :
summary
It's simple here TensorFlow transplant Ascend The code modification of the platform is completed , In fact, the whole process is relatively simple , It's not difficult to meet. , No, it may be difficult . The main difficulties of model migration are that some operators may not support and the accuracy performance optimization .
边栏推荐
- Emqx 5.0 release: open source Internet of things message server with single cluster supporting 100million mqtt connections
- Oracle Linux 9.0 officially released
- Wechat applet - Advanced chapter component packaging - Implementation of icon component (I)
- 寺岗电子称修改IP简易步骤
- 比尔·盖茨晒48年前简历:“没你们的好看”
- Leetcode - Sword finger offer 05 Replace spaces
- Bill Gates posted his resume 48 years ago: "it's not as good-looking as yours."
- Notes de l'imprimante substance: paramètres pour les affichages Multi - écrans et multi - Résolutions
- AWS学习笔记(三)
- LeetCode 648. Word replacement
猜你喜欢
OAuth 2.0 + JWT protect API security
一个程序员的水平能差到什么程度?尼玛,都是人才呀...
《微信小程序-进阶篇》组件封装-Icon组件的实现(一)
Substance painter notes: settings for multi display and multi-resolution displays
Pert diagram (engineering network diagram)
Pytorch model trains practical skills and breaks through the bottleneck of speed
用例图
"July 2022" Wukong editor update record
Navigation - are you sure you want to take a look at such an easy-to-use navigation framework?
数据湖(九):Iceberg特点详述和数据类型
随机推荐
WPF DataGrid realizes the UI interface to respond to a data change in a single line
Docker deploy Oracle
华为云数据库DDS产品深度赋能
Navigation - are you sure you want to take a look at such an easy-to-use navigation framework?
OAuth 2.0 + JWT 保护API安全
PD虚拟机教程:如何在ParallelsDesktop虚拟机中设置可使用的快捷键?
NDK beginner's study (1)
Source code analysis of ArrayList
比尔·盖茨晒48年前简历:“没你们的好看”
Substance Painter筆記:多顯示器且多分辨率顯示器時的設置
JS image to Base64
Base64 encoding
【愚公系列】2022年7月 Go教学课程 005-变量
Simple steps for modifying IP of sigang electronic scale
AWS learning notes (III)
Attribute keywords ondelete, private, readonly, required
PLC: automatically correct the data set noise, wash the data set | ICLR 2021 spotlight
数据库如何进行动态自定义排序?
Hangdian oj2054 a = = B? ???
Full details of efficientnet model