36ml.mnist Module
36.1Overview
The ml.mnist module provides measures to read image database of handwritten digit called MNIST. MNIST data files are avaiable in: http://yann.lecun.com/exdb/mnist/.
The database consists of the following files:
train-images-idx3-ubyte.gz.. training set imagestrain-labels-idx1-ubyte.gz.. training set labelst10k-images-idx3-ubyte.gz.. test set imagest10k-labels-idx1-ubyte.gz.. test set labels
36.2ml.mnist.dbpair Structure
36.2.1Constructor
mnist.dbpair(imageset:mnist.imageset, labelset:mnist.labelset) {block?}36.2.2Property
A ml.mnist.dbpair instance has the following properties:
| Property | Type | R/W | Explanation |
|---|---|---|---|
imageset |
ml.mnist.imageset |
R | |
labelset |
ml.mnist.labelset |
R |
36.3ml.mnist.database Class
36.3.1Constructor
mnist.database(dirname:string) {block?}dirname and returns a ml.mnist.database instance.
36.3.2Property
A ml.mnist.database instance has the following properties:
| Property | Type | R/W | Explanation |
|---|---|---|---|
test |
ml.mnist.dbpair |
R | |
train |
ml.mnist.dbpair |
R |
36.4ml.mnist.imageset Class
36.4.1Constructor
mnist.imageset(stream:stream):map {block?}
Reads MNIST image set file from the specified stream and returns a ml.mnist.imageset instance.
If block is specified, it would be evaluated with a block parameter |stream:stream|, where stream is the created instance. In this case, the block's result would become the function's returned value.
36.4.2Property
A ml.mnist.imageset instance has the following properties:
mnist.imageset#ncols … number [read-only]mnist.imageset#nimages … number [read-only]mnist.imageset#nrows … number [read-only]36.4.3Method
mnist.imageset#toarray(shape?:symbol, elemtype?:symbol, normalize?:symbol):map {block?}
Creates an array instance from the MNIST image set.
Arguments:
shape.. element shape that takes`flator`matrix. Default is`flat.elemtype.. element type of createdarraythat takes`uint8,`half,`floator`double. Default is`float.normalize.. specifies whether it maps element values of[0, 255]into a range of[0, 1]. Default istruewhenelemtypeis`half,`floator`double. Ignored and always treated asfalsewhenelemtypeis`uint8.
If block is specified, it would be evaluated with a block parameter |array:array|, where array is the created instance. In this case, the block's result would become the function's returned value.
36.5ml.mnist.labelset Class
36.5.1Constructor
mnist.labelset(stream:stream):map {block?}
Reads MNIST label set file from the specified stream and returns a ml.mnist.labelset instance.
If block is specified, it would be evaluated with a block parameter |stream:stream|, where stream is the created instance. In this case, the block's result would become the function's returned value.
36.5.2Property
A ml.mnist.labelset instance has the following properties:
mnist.labelset#nlabels … number [read-only]36.5.3Method
mnist.labelset#toarray(onehot?:boolean, elemtype?:symbol) {block?}
Creates an array instance from the MNIST label set.
Arguments:
onehot.. one-hot data is created when set totrue. Raw data is stored otherwise. Default istrue.elemtype.. element type of createdarraythat takes`uint8,`half,`floator`double. Default is`float.
If block is specified, it would be evaluated with a block parameter |array:array|, where array is the created instance. In this case, the block's result would become the function's returned value.