Skip to content

Commit

Permalink
test softmax performance
Browse files Browse the repository at this point in the history
  • Loading branch information
mateogianolio committed Jun 6, 2015
1 parent 7d0ce5d commit 6cf6268
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 17 deletions.
12 changes: 4 additions & 8 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
{
"mnist": false,
"text": "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
"fonts": [
"sans-serif",
"serif"
],
"training_set": 2000,
"testing_set": 1000,
"text": "0123456789",
"training_set": 50000,
"testing_set": 500,
"image_size": 16,
"threshold": 400,
"network": {
"hidden": 40,
"output": 10,
"learning_rate": 0.03
}
}
Binary file modified examples/0123456789.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 6 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
perceptron = new synaptic.Architect.Perceptron(
(config.image_size * config.image_size), // input
config.network.hidden, // hidden
8 // output
config.network.output // output
);

var index,
Expand Down Expand Up @@ -171,15 +171,18 @@

chunk = tools.center(chunk);

var output = Array.apply(null, new Array(10)).map(Number.prototype.valueOf, 0);
output[i] = 1;

if(index < config.training_set) {
training.push({
input: chunk,
output: ('00000000' + text.charCodeAt(i).toString(2)).substr(-8).split('').map(Number)
output: output
});
} else {
testing.push({
input: chunk,
output: ('00000000' + text.charCodeAt(i).toString(2)).substr(-8).split('').map(Number)
output: output
});
}

Expand Down
8 changes: 2 additions & 6 deletions network.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,9 @@

prediction = network
.activate(object.input)
.map(function(bit) {
return bit > 0.5 ? 1 : 0;
});

// convert to char codes
prediction = String.fromCharCode(parseInt(prediction.join(''), 2));
result = String.fromCharCode(parseInt(object.output.join(''), 2));
prediction = prediction.indexOf(Math.max.apply(null, prediction));
result = object.output.indexOf(1);

if(prediction === result)
success++;
Expand Down

0 comments on commit 6cf6268

Please sign in to comment.