参加华为的MindSpore SPONGE的培训
所用的代码来自其教程,地址如下:
www.mindspore.cn
开始学习
1.创建环境
conda create -n ms python=3.9.12
conda activate ms
conda deactivate
conda env list
2.下载数据
本章节中的示例代码依赖mindvision,可使用命令pip install mindvision安装。
pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/1.7.0/MindSpore/cpu/x86_64/mindspore-1.7.0-cp39-cp39-linux_x86_64.whl --trusted-host ms-release.obs.cn-north-4.myhuaweicloud.com -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install mindvision
pip install notebook
#conda install -c mindspore mindspore-cpu 版本有点高1.8.1的版本
pip install ipykernel###把jupyter notebook安装到ms的环境里面
从MNIST数据集下载页面下载,解压后按下方目录结构放置。
1.数据地址
http://yann.lecun.com/exdb/mnist/
3.建立目录
./mnist/
├── test
│ ├── t10k-images-idx3-ubyte
│ └── t10k-labels-idx1-ubyte
└── train
├── train-images-idx3-ubyte
└── train-labels-idx1-ubyte
4.开始运行
打开jupyter notebook
jupyter notebook
from mindvision.dataset import Mnist
# 下载并处理MNIST数据集
download_train = Mnist(path="./mnist", split="train", batch_size=32, repeat_num=1, shuffle=True, resize=32, download=True)
download_eval = Mnist(path="./mnist", split="test", batch_size=32, resize=32, download=True)
dataset_train = download_train.run()
dataset_eval = download_eval.run()