当前位置:网站首页>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 .
边栏推荐
- Attribute keywords ondelete, private, readonly, required
- Navigation — 这么好用的导航框架你确定不来看看?
- LeetCode每日一题(636. Exclusive Time of Functions)
- Five pain points for big companies to open source
- Es log error appreciation -maximum shards open
- Multi merchant mall system function disassembly lecture 01 - Product Architecture
- oracle 触发器实现级联更新
- Cvpr2022 | backdoor attack based on frequency injection in medical image analysis
- In the field of software engineering, we have been doing scientific research for ten years!
- Because the employee set the password to "123456", amd stolen 450gb data?
猜你喜欢
AWS学习笔记(三)
Applet directory structure
2022PAGC 金帆奖 | 融云荣膺「年度杰出产品技术服务商」
Ian Goodfellow, the inventor of Gan, officially joined deepmind as research scientist
GAN发明者Ian Goodfellow正式加入DeepMind,任Research Scientist
Huawei cloud database DDS products are deeply enabled
Internal sort - insert sort
The longest ascending subsequence model acwing 1014 Mountaineering
#yyds干货盘点# 解决名企真题:交叉线
【愚公系列】2022年7月 Go教学课程 005-变量
随机推荐
Pert diagram (engineering network diagram)
GAN发明者Ian Goodfellow正式加入DeepMind,任Research Scientist
CVPR2022 | 医学图像分析中基于频率注入的后门攻击
「2022年7月」WuKong编辑器更版记录
Docker deploy Oracle
Introduction and use of Kitti dataset
属性关键字OnDelete,Private,ReadOnly,Required
Attribute keywords ondelete, private, readonly, required
昇腾体验官第五期随手记I
Leetcode - Sword finger offer 05 Replace spaces
The longest ascending subsequence model acwing 1014 Mountaineering
Search engine interface
Instructions for mictr01 tester vibrating string acquisition module development kit
Because the employee set the password to "123456", amd stolen 450gb data?
"July 2022" Wukong editor update record
AWS学习笔记(三)
一个程序员的水平能差到什么程度?尼玛,都是人才呀...
Simple use of websocket
C # switch pages through frame and page
JS get the current time, month, day, year, and the uniapp location applet opens the map to select the location