MindSpore

导航

 

 

安装

官网目前提供了多种安装方式,亲测用docker安装最非常方便

  • CPU:
docker pull mindspore/mindspore-cpu:0.3.0-alpha
  • GPU:
docker pull mindspore/mindspore-gpu:0.3.0-alpha

 

安装好后,可以看到我们安装的镜像

 

huxiaoman@huxiaomandeiMac ~ % docker images
REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE
mindspore/mindspore-cpu   0.3.0-alpha         9a124f33ed27        3 weeks ago         1.19GB

 

然后基于这个镜像创建一个你的容器:

 

huxiaoman@huxiaomandeiMac ~ % docker run -it mindspore/mindspore-cpu:0.3.0-alpha /bin/bash
root@32953de6019e:/#

 

 

运行MindSpore Lenet代码

 

git clone https://github.com/mindspore-ai/docs.git

 

进入到tutorials_code,可以看到lenet.py ,官网教程示例是默认在Ascend上跑的,我们把196行的device_target改成CPU就可以啦

 

parser.add_argument('--device_target', type=str, default="CPU", choices=['Ascend', 'GPU', 'CPU'],
                        help='device where the code will be implemented (default: Ascend)')

 

然后运行

 

python lenet.py

 

就会看到屏幕上会输出训练日志:

 

******Downloading the MNIST dataset******
============== Starting Training ==============
epoch: 1 step: 1, loss is 2.2985785
epoch: 1 step: 2, loss is 2.3037047
epoch: 1 step: 3, loss is 2.306114
epoch: 1 step: 4, loss is 2.3083768
epoch: 1 step: 5, loss is 2.3051324
···
epoch: 1 step: 1873, loss is 0.034860577
epoch: 1 step: 1874, loss is 0.10654623
epoch: 1 step: 1875, loss is 0.11245084
============== Starting Testing ==============
============== Accuracy:{'Accuracy': 0.9567307692307693} ==============

 

整个过程非常流畅!

 

 


 

我把整个过程也录制了一个小视频放在B站上看,欢迎观看:

视频链接

 

后续也会继续写MindSpore的学习笔记哦,欢迎大家给我提建议&留言,看完的小伙伴们,赶快去试试吧~

ps:欢迎大家一键三连(star、fork、watch),有任何问题可以随时提issue ^_^

 

GitHub跳转链接

 

码云跳转链接

 

 

posted on 2020-06-19 09:24  MindSpore  阅读(722)  评论(0)    收藏  举报