Skip to content

Commit 001e3bc

Browse files
author
Alex Yu
authored
Merge pull request #40 from alexander-yu/alex
Add weights for each iteration in demo2
2 parents eedda51 + 6f727d0 commit 001e3bc

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

demo/demo2.neo

+11-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ int sum(matrix<int> X) {
1111

1212
matrix<int> train(matrix<int> X, matrix<int> y) {
1313
create matrix<int> weights[1][cols(X)];
14+
auto iter_weights = weights[:, :];
1415
auto has_errors = True;
1516

1617
while (has_errors) {
@@ -39,10 +40,19 @@ matrix<int> train(matrix<int> X, matrix<int> y) {
3940

4041
if (count == 0) {
4142
has_errors = False;
43+
} else {
44+
auto weights_copy = weights[:, :];
45+
auto new_iter_weights = append(iter_weights, weights_copy);
46+
47+
free(weights_copy);
48+
free(iter_weights);
49+
50+
iter_weights = new_iter_weights;
4251
}
4352
}
4453

45-
return weights;
54+
free(weights);
55+
return iter_weights;
4656
}
4757

4858
void main() {

demo/weights2.mats

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,21 @@
1-
1,3,int
1+
20,3,int
2+
0, 0, 0
3+
3, 8, 3
4+
6, 3, 9
5+
10, 12, 6
6+
12, 6, 1
7+
15, 7, 9
8+
16, 5, 2
9+
18, 5, -1
10+
21, 6, 7
11+
23, 3, 8
12+
24, -1, -2
13+
26, 2, 7
14+
28, 3, 3
15+
30, 3, 6
16+
32, 0, 7
17+
34, 1, 3
18+
36, 1, 6
19+
38, 2, 2
20+
40, 2, 5
221
39, -5, -2

0 commit comments

Comments
 (0)