当前位置:网站首页>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 .
边栏推荐
- JS in the browser Base64, URL, blob mutual conversion
- 半小时『直播连麦搭建』动手实战,大学生技术岗位简历加分项get!
- 杭电oj2092 整数解
- 用例图
- 数据库如何进行动态自定义排序?
- MLGO:Google AI发布工业级编译器优化机器学习框架
- Differences between cookies and sessions
- Decrypt the three dimensional design of the game
- 一文读懂数仓中的pg_stat
- Multi merchant mall system function disassembly lecture 01 - Product Architecture
猜你喜欢
内部排序——插入排序
云上“视界” 创新无限 | 2022阿里云直播峰会正式上线
Wechat applet - Advanced chapter component packaging - Implementation of icon component (I)
Computer win7 system desktop icon is too large, how to turn it down
Notes de l'imprimante substance: paramètres pour les affichages Multi - écrans et multi - Résolutions
EfficientNet模型的完整细节
设备故障预测机床故障提前预警机械设备振动监测机床故障预警CNC震动无线监控设备异常提前预警
2022年13个UX/UI/UE最佳创意灵感网站
Huawei cloud database DDS products are deeply enabled
Pert diagram (engineering network diagram)
随机推荐
小程序目录结构
Mmkv use and principle
Leetcode——344. Reverse string /541 Invert string ii/151 Reverse the word / Sword finger in the string offer 58 - ii Rotate string left
AWS学习笔记(三)
MRS离线数据分析:通过Flink作业处理OBS数据
Cvpr2022 | backdoor attack based on frequency injection in medical image analysis
什么是云原生?这回终于能搞明白了!
Mrs offline data analysis: process OBS data through Flink job
Substance painter notes: settings for multi display and multi-resolution displays
ES日志报错赏析-- allow delete
PG基础篇--逻辑结构管理(锁机制--表锁)
Navigation - are you sure you want to take a look at such an easy-to-use navigation framework?
WebRTC 音频抗弱网技术(上)
云上“视界” 创新无限 | 2022阿里云直播峰会正式上线
华为云数据库DDS产品深度赋能
Small game design framework
【服务器数据恢复】某品牌StorageWorks服务器raid数据恢复案例
Attribute keywords ondelete, private, readonly, required
Applet directory structure
Cocos creator direction and angle conversion