Skip to content

JingTongsh/LeNet-with-NumPy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LeNet with NumPy

实验任务

仅使用 NumPy,编写并训练一个LeNet模型。 在mnist数据集上完成图像分类,记录测试准确率及训练时间。

数据集保存于 mnist.npz 文件,可读取为 dict

实验环境

  • python 3.8.5
  • numpy 1.20.2

训练和Demo

model 文件夹是自动生成的。 每训练完成一个epoch,程序都会自动在 model 文件夹下保存模型。 比如第3个epoch完成后,该文件夹下会有 model_3.pkl 文件。 此时可以中断训练。 此后如果想要继续训练,只需要将 prev_epochs 修改为3。

在IDE里点击运行按钮,或者在终端输入

python main.py

即可开始训练。

结果

epoch test accuracy training time (sec)
1 95.89% forgot
2 97.64% 3280.11
3 98.19% 3274.38
4 98.48% 3293.02
5 98.60% 2767.44
6 98.41% 2743.25
7 98.51% 2749.18
8 98.56% 2755.56
9 98.68% 2775.91
10 98.65% 2740.56

前4个epochs在windows 10系统训练。 后6个epochs在ubuntu 20.04系统训练。 可以发现ubuntu比windows快一点。 最佳的测试准确率出现在第9个epoch。

About

用NumPy手写LeNet

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages