当前位置:网站首页>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_dataIt is amended as follows :
from tensorflow.examples.tutorials.mnist import input_dataRun 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 .
边栏推荐
- Pytorch model trains practical skills and breaks through the bottleneck of speed
- LeetCode 648. 单词替换
- GAN发明者Ian Goodfellow正式加入DeepMind,任Research Scientist
- Because the employee set the password to "123456", amd stolen 450gb data?
- 低代码平台中的数据连接方式(下)
- Cocos creator direction and angle conversion
- 一文读懂数仓中的pg_stat
- Docker deploy Oracle
- Search engine interface
- Navigation - are you sure you want to take a look at such an easy-to-use navigation framework?
猜你喜欢

#yyds干货盘点# 解决名企真题:交叉线

Navigation - are you sure you want to take a look at such an easy-to-use navigation framework?

Because the employee set the password to "123456", amd stolen 450gb data?

Computer win7 system desktop icon is too large, how to turn it down

EfficientNet模型的完整细节

OAuth 2.0 + JWT 保护API安全

云上“视界” 创新无限 | 2022阿里云直播峰会正式上线

Docker deploy Oracle

Pandora IOT development board learning (HAL Library) - Experiment 12 RTC real-time clock experiment (learning notes)

Five pain points for big companies to open source
随机推荐
Summary on adding content of background dynamic template builder usage
The method of parsing PHP to jump out of the loop and the difference between continue, break and exit
In the field of software engineering, we have been doing scientific research for ten years!
Substance Painter筆記:多顯示器且多分辨率顯示器時的設置
《微信小程序-进阶篇》组件封装-Icon组件的实现(一)
Démontage de la fonction du système multi - Merchant Mall 01 - architecture du produit
The longest ascending subsequence model acwing 1012 Sister cities
Leetcode——236. The nearest common ancestor of binary tree
Computer win7 system desktop icon is too large, how to turn it down
Leetcode——236. 二叉树的最近公共祖先
A laravel background management expansion package you can't miss - Voyager
PD虚拟机教程:如何在ParallelsDesktop虚拟机中设置可使用的快捷键?
ES日志报错赏析-maximum shards open
找到自己的价值
Substance Painter笔记:多显示器且多分辨率显示器时的设置
Leetcode one question per day (636. exclusive time of functions)
Data Lake (IX): Iceberg features and data types
OAuth 2.0 + JWT protect API security
Simple use of websocket
Es log error appreciation -trying to create too many buckets