-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Expand file tree
/
Copy pathregression.html
More file actions
50 lines (48 loc) · 1.26 KB
/
Copy pathregression.html
File metadata and controls
50 lines (48 loc) · 1.26 KB
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
<!doctype html>
<html>
<head>
<title>
Hello wurl
</title>
<body>
<script src="../../build/convnet-min.js"></script>
<script>
//for regression as opposed to classification
//we can proceed similarly just replace the classifier
//layer from softmax
const layer_defs = []
layer_defs.push({
type: 'input',
out_sx: 1,
out_sy: 1,
out_depth: 2
})
layer_defs.push({
type: 'fc',
num_neurons: 5,
activation: 'sigmoid'
})
layer_defs.push({
type: 'regression',
num_neurons: 1
})
const net = new convnetjs.Net()
net.makeLayers(layer_defs)
const x = new convnetjs.Vol([0.5, -1.3])
const trainer = new convnetjs.SGDTrainer(net, {
learning_rate: 0.01,
momentum: 0.0,
batch_size: 1,
l2_decay: 0.001
})
//train on the datapoint, saying [0.5, -1.3]
//should map to value 0.7
for (var i = 0; i < 200; i++) {
trainer.train(Object.assign({}, x), [0.7])
}
const predicted_values = net.forward(x)
console.log(predicted_values.w)
</script>
</body>
</head>
</html>