Skip to content

Commit

Permalink
Merge pull request #2 from ApelSYN/master
Browse files Browse the repository at this point in the history
I adjusted incorrectly resource files
  • Loading branch information
Juan Cazala authored Jul 9, 2016
2 parents b8e4c1a + fe551cc commit 22484f4
Show file tree
Hide file tree
Showing 15 changed files with 96 additions and 62 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
debug.html
debug.html
.idea
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ MNIST Digits

![mnist digits](http://i.ytimg.com/vi/0QI3xgXuB-Q/hqdefault.jpg "MNIST Digits")

The goal of this library is to provide an easy-to-use way for training and testing [MNIST digits](https://en.wikipedia.org/wiki/MNIST_database) for neural networks (either in the browser or node.js). It includes [9926](https://www.youtube.com/watch?v=SiMHTK15Pik) different samples of mnist digits. I built this in order to work out of the box with [Synaptic](https://github.com/cazala/synaptic).
The goal of this library is to provide an easy-to-use way for training and testing [MNIST digits](https://en.wikipedia.org/wiki/MNIST_database) for neural networks (either in the browser or node.js). It includes [10000](https://www.youtube.com/watch?v=SiMHTK15Pik) different samples of mnist digits. I built this in order to work out of the box with [Synaptic](https://github.com/cazala/synaptic).

You are free to create any number (from 1 to 60 000) of different examples c via [MNIST Digits data loader](https://github.com/ApelSYN/mnist_dl)

### Installation

Expand All @@ -14,7 +15,7 @@ for the browser: `bower install mnist --save`

### Usage

The most important method is `mnist.set(trainingAmmt, testAmmt)` which takes the ammount of samples for the training and test sets, and returns an object with the two sets of samples (one for training and the other one for testing). Both sets are shuffled, and there are no samples repeated in both sets.
The most important method is `mnist.set(trainingAmmt, testAmmt)` which takes the amount of samples for the training and test sets, and returns an object with the two sets of samples (one for training and the other one for testing). Both sets are shuffled, and there are no samples repeated in both sets.

For example:

Expand Down
53 changes: 24 additions & 29 deletions dist/mnist.js

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions simple.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>MNIST Digits Simples</title>
<script src="./dist/mnist.js"></script>
<script>
window.onload = function() {
var simplesCount = 20;
var size = 28;
var canvas = document.getElementById("mnistCanvas");
canvas.height = size*simplesCount;
var ctx = canvas.getContext("2d");

var canvasData = ctx.getImageData(0, 0, canvas.width, canvas.height);
var colOffset, rowOffcet;

for (var col=0;col < 10; col++) {
colOffset = col*size;
var digits = mnist[col].range(0, simplesCount-1);
for (var row=0;row < simplesCount; row++) {
var digit = digits[row];
rowOffcet = row*size;
for (var i = 0; i < digit.length; i++) {
var pointColor = digit[i] * 255;
var position = (colOffset+(rowOffcet + Math.floor(i/size))*canvas.width) + (i % size);
canvasData.data[position * 4 + 0] = 255-pointColor;
canvasData.data[position * 4 + 1] = 255-pointColor;
canvasData.data[position * 4 + 2] = 255-pointColor;
canvasData.data[position * 4 + 3] = 255;
}
}
}
ctx.putImageData(canvasData, 0, 0);
}
</script>
</head>
<body>
<h1>MNIST Digits Simples</h1>
<canvas id="mnistCanvas" width="280" height="280">
Your browser does not support the HTML5 canvas tag.
</canvas>
</body>
</html>
4 changes: 1 addition & 3 deletions src/digits/0.json

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions src/digits/1.json

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions src/digits/2.json

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions src/digits/3.json

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions src/digits/4.json

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions src/digits/5.json

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions src/digits/6.json

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions src/digits/7.json

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions src/digits/8.json

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions src/digits/9.json

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions src/mnist.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,19 @@ var raw = [
MNIST.push(digit);
});

// Generates non-overlaping training and a test sets, with the desired ammount of samples
MNIST.get = function(count) {
var range = [];
for (var i in [0,1,2,3,4,5,6,7,8,9]) {
range = range.concat(this[i].set(0,this[i].length));
}
range = shuffle(range);
if (Number(count)) {
range = range.slice(0,Number(count));
}
return range;
}


// Generates non-overlaping training and a test sets, with the desired ammount of samples
MNIST.set = function(_training, _test)
Expand Down

0 comments on commit 22484f4

Please sign in to comment.