forked from htm-community/cell-viz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example1.html
96 lines (88 loc) · 3.38 KB
/
example1.html
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<title>Lowbrow: Two Layers over Input Space</title>
<style>
body { margin: 0; }
canvas { width: 100%; height: 100% }
</style>
</head>
<body>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://threejs.org/build/three.min.js"></script>
<script src="https://rhyolight.github.io/lowbrow/bin/lowbrow-0.1.0.min.js"></script>
<script src="dist/cell-viz-3d-1.4.4.min.js"></script>
<script>
(function() {
// The scale is same as "cube size". This makes the cubes 100
// pixels.
const scale = 100
const oneColTwoLayers = {
name: "one column, two layers",
origin: {x: 0, y: 0, z: 0},
scale: scale,
corticalColumns: [{
// Puts one cell between layers
spacing: scale,
name: "column 1",
layers: [
{
name: "layer 4",
miniColumns: false,
neuronCount: 4*3*4,
dimensions: {
x: 4, y: 3, z: 4
}
},
{
name: "layer 2/3",
miniColumns: false,
neuronCount: 5*3*5,
dimensions: {
x: 5, y: 3, z: 5
}
},
{
name: "input space",
miniColumns: false,
neuronCount: 10*1*10,
dimensions: {
x: 10, y: 1, z: 10
}
}
]
}]
}
var network = Lowbrow.createHtmNetwork(oneColTwoLayers)
var column = network.getCorticalColumns()[0]
var cellviz = new HighbrowColumnVisualization(column, {cubeSize: scale});
cellviz.camera.translateX(500)
cellviz.camera.translateY(2200)
cellviz.camera.translateZ(4000)
cellviz.camera.rotateX(-0.5)
animateCells(column);
// Renders the canvas with empty cells into the DOM and canvas.
cellviz.render();
setInterval(function() {
animateCells(column);
cellviz.redraw();
}, 500);
function animateCells(column) {
// We're going straight to the Highbrow objects to
// update neuron states. We can access all the highbrow
// state from the layer directly and change it as we like.
column.getLayers().forEach(function(layer) {
layer.getNeurons().forEach(function(neuron) {
if (Math.random() >= 0.98) {
neuron.activate()
} else {
neuron.deactivate()
}
});
});
}
}());
</script>
</body>
</html>