forked from abaybektursun/why-batchNorm-works
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
72 lines (58 loc) · 1.68 KB
/
index.js
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import {MnistData} from './data';
import * as model from './model';
import * as ui from './ui';
var $ = require('jquery');
let data;
async function load(chart_id) {
ui.isLoading(chart_id);
data = new MnistData();
await data.load();
}
async function train(LEARNING_RATE, chart_id, noise=false, subId=undefined) {
ui.isTraining(chart_id);
await model.train('CNN', data, ui.trainingLog, LEARNING_RATE, chart_id, noise, subId);
}
async function train_BN(LEARNING_RATE, chart_id, noise=false, subId=undefined) {
ui.isTraining(chart_id);
await model.train('CNN_BN', data, ui.trainingLog, LEARNING_RATE, chart_id, noise, subId);
}
async function test() {
const testExamples = 50;
const batch = data.nextTestBatch(testExamples);
const predictions = model.predict(batch.xs);
const labels = model.classesFromLabel(batch.labels);
ui.showTestResults(batch, predictions, labels);
}
async function train0() {
var id = '0';
await load(id);
await train(0.1, id);
await train_BN(0.1, id);
await train(0.5, id);
await train_BN(0.5, id);
ui.done(id);
}
async function train1() {
var id = '1';
await load(id);
await train(undefined, id, false, '_1');
await train_BN(undefined, id, false, '_2');
await train_BN(undefined, id, true, '_3');
ui.done(id);
}
async function train2() {
var id = '2';
await load(id);
await train(undefined, id, false);
await train_BN(undefined, id, false);
ui.done(id);
}
document.getElementById('train0').addEventListener('click', function() {
train0();
});
document.getElementById('train1').addEventListener('click', function() {
train1();
});
document.getElementById('train2').addEventListener('click', function() {
train2();
});