Skip to content

Commit

Permalink
Update Week6-CNN实现手写数字识别.md
Browse files Browse the repository at this point in the history
  • Loading branch information
learning511 authored Jun 7, 2019
1 parent 2860a3b commit 457c388
Showing 1 changed file with 0 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,42 +13,6 @@ MNIST数据集原网址:http://yann.lecun.com/exdb/mnist/

**问题:通过某个算法将0-9的数字进行分类**

### 下载
Github源码下载:数据集(源文件+解压文件+字体图像jpg格式),py源码文件
文件目录
```python
/utils/data_util.py 用于加载MNIST数据集方法文件
/utils/test.py 用于测试的文件,一个简单的KNN测试MNIST数据集
/data/train-images.idx3-ubyte 训练集X
/dataset/train-labels.idx1-ubyte 训练集y
/dataset/data/t10k-images.idx3-ubyte 测试集X
/dataset/data/t10k-labels.idx1-ubyte 测试集y
```

### 结构解释
MNIST数据集解释
将MNIST文件解压后,发现这些文件并不是标准的图像格式。这些图像数据都保存在二进制文件中。每个样本图像的宽高为28*28。

mnist的结构如下,选取train-images
```python
[code]TRAINING SET IMAGE FILE (train-images-idx3-ubyte):

[offset] [type] [value] [description]
0000 32 bit integer 0x00000803(2051) magic number
0004 32 bit integer 60000 number of images
0008 32 bit integer 28 number of rows
0012 32 bit integer 28 number of columns
0016 unsigned byte ?? pixel
0017 unsigned byte ?? pixel
........
xxxx unsigned byte ?? pixel
```

首先该数据是以二进制存储的,我们读取的时候要以’rb’方式读取;其次,真正的数据只有[value]这一项,其他的[type]等只是来描述的,并不真正在数据文件里面。也就是说,在读取真实数据之前,我们要读取4个

32 bit integer
.由[offset]我们可以看出真正的pixel是从0016开始的,一个int 32位,所以在读取pixel之前我们要读取4个 32 bit integer,也就是magic number, number of images, number of rows, number of columns. 当然,在这里使用struct.unpack_from()会比较方便.

### 算法实现
[代码答案](https://github.com/dafish-ai/NTU-Machine-learning/blob/master/%E6%9D%8E%E5%AE%8F%E6%AF%85%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0-%E4%BD%9C%E4%B8%9A/week6/CNN.py)

0 comments on commit 457c388

Please sign in to comment.