-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathmain.odin
More file actions
51 lines (35 loc) · 1.04 KB
/
main.odin
File metadata and controls
51 lines (35 loc) · 1.04 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
51
package main
import "core:fmt"
import "core:math/rand"
import "core:intrinsics"
import tri "triadic"
main :: proc() {
n: int = 1000
p: int = 10
rng: rand.Rand = rand.create(u64(intrinsics.read_cycle_counter()))
ttm := tri.temporal_memory_new(n, p)
defer tri.temporal_memory_free(ttm)
inputs: [20]tri.SDR
fmt.println("Seq:")
for t := 0; t < len(inputs); t += 1 {
inputs[t] = tri.sdr_new_random(n, p, ttm.randomize_buffer, &rng)
tri.sdr_print(inputs[t])
}
defer for t := 0; t < len(inputs); t += 1 {
tri.sdr_free(inputs[t])
}
fmt.println("Training...")
for it := 0; it < 20; it += 1 {
for t := 0; t < len(inputs); t += 1 {
tri.temporal_memory_step(ttm, inputs[t], &rng, true)
}
}
fmt.println("Recall:")
input := tri.sdr_new(n, p)
defer tri.sdr_free(input)
for t := 0; t < 20; t += 1 {
tri.sdr_print(ttm.pred)
tri.sdr_copy(&input, ttm.pred)
tri.temporal_memory_step(ttm, input, &rng, false)
}
}