Skip to content

Commit

Permalink
v1.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Juan Cazala committed Jul 11, 2016
1 parent a50d6cd commit ffdcc44
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mnist",
"version": "1.0.4",
"version": "1.0.5",
"homepage": "https://github.com/cazala/mnist",
"authors": [
"Juan Cazala <cazala@mail.sfsu.edu> (http://juancazala.com/)"
Expand Down
40 changes: 21 additions & 19 deletions dist/mnist.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ var raw = [
var digit = {
id: id
};

// raw data
digit.raw = raw[digit.id];

// number of samples
digit.length = digit.raw.length / (size * size) | 0;

// get one sample
digit.get = function(_which)
digit.get = function(_which)
{
var which = _which;
// if not specified, or if invalid, pick a random sample
Expand All @@ -65,10 +65,10 @@ var raw = [
// generate sample
var sample = [];
for (
var length = size * size,
start = which * length,
i = 0;
i < length;
var length = size * size,
start = which * length,
i = 0;
i < length;
sample.push(digit.raw[start + i++])
);
return sample;
Expand All @@ -89,8 +89,8 @@ var raw = [
}
var range = [];
for (
var i = start;
i <= end;
var i = start;
i <= end;
range.push(digit.get(i++))
);
return range;
Expand All @@ -104,8 +104,8 @@ var raw = [
output[digit.id] = 1;
var range = digit.range(start, end);
for (
var i = 0;
i < range.length;
var i = 0;
i < range.length;
set.push({
input: range[i++],
output: output
Expand All @@ -122,11 +122,11 @@ var raw = [
MNIST.get = function(count) {
var range = [];
for (var i in [0,1,2,3,4,5,6,7,8,9]) {
range.concat(this[i].set(0,this[i].length));
range = range.concat(this[i].set(0,this[i].length));
}
range = shuffle(range);
if (count) {
range = range.slice(0,count);
if (Number(count)) {
range = range.slice(0,Number(count));
}
return range;
}
Expand All @@ -152,7 +152,7 @@ MNIST.set = function(_training, _test)
test = MNIST.__MINLENGTH * (test / training);
training = MNIST.__MINLENGTH - training;
}
else
else
{
training = MNIST.__MINLENGTH * (training / test);
test = MNIST.__MINLENGTH - test;
Expand Down Expand Up @@ -185,8 +185,9 @@ MNIST.draw = function(digit, context, offsetX, offsetY)
imageData.data[i * 4] = digit[i] * 255;
imageData.data[i * 4 + 1] = digit[i] * 255;
imageData.data[i * 4 + 2] = digit[i] * 255;
imageData.data[i * 4 + 3] = 255;
}
context.putImageData(imageData,offsetX,offsetY);
context.putImageData(imageData, offsetX || 0, offsetY || 0);
}


Expand All @@ -206,13 +207,13 @@ if (typeof module !== 'undefined' && module.exports)
if (typeof window == 'object')
{
(function()
{
{
var old = window['mnist'];
MNIST.ninja = function()
{
window['mnist'] = old;
{
window['mnist'] = old;
return MNIST;
};
};
})();

window['mnist'] = MNIST;
Expand All @@ -225,4 +226,5 @@ function shuffle(v){
for(var j, x, i = v.length; i; j = parseInt(Math.random() * i), x = v[--i], v[i] = v[j], v[j] = x);
return v;
};

},{"./digits/0.json":1,"./digits/1.json":2,"./digits/2.json":3,"./digits/3.json":4,"./digits/4.json":5,"./digits/5.json":6,"./digits/6.json":7,"./digits/7.json":8,"./digits/8.json":9,"./digits/9.json":10}]},{},[11]);
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mnist",
"version": "1.0.4",
"version": "1.0.5",
"description": "mnist digits",
"main": "src/mnist.js",
"scripts": {
Expand Down

0 comments on commit ffdcc44

Please sign in to comment.