-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrain.js
More file actions
27 lines (20 loc) · 773 Bytes
/
Copy pathtrain.js
File metadata and controls
27 lines (20 loc) · 773 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const brain = require('brain.js');
var net = new brain.NeuralNetwork();
const fs = require('fs');
const mnist = require('mnist');
const set = mnist.set(20000, 0);
const trainingSet = set.training;
//const testSet = set.test;
net.train(trainingSet,
{
errorThresh: 0.001, // error threshold to reach
iterations: 20000, // maximum training iterations
log: true, // console.log() progress periodically
logPeriod: 1, // number of iterations between logging
learningRate: 0.3 // learning rate
}
);
let wstream = fs.createWriteStream('./data/mnistTrain.json');
wstream.write(JSON.stringify(net.toJSON(),null,2));
wstream.end();
console.log('MNIST dataset with Brain.js train done.')