File tree 4 files changed +45
-5
lines changed
4 files changed +45
-5
lines changed Original file line number Diff line number Diff line change 1
1
mod som;
2
- mod functions ;
2
+ mod net ;
3
3
4
- pub use self :: som:: SOM ;
4
+ pub use self :: som:: SOM ;
5
+ pub use self :: net:: Net ;
Original file line number Diff line number Diff line change
1
+ // Neural network struct
2
+ pub struct Net {
3
+ pub nodes : Vec < Vec < i32 > > ,
4
+ pub size : ( u32 , u32 )
5
+ }
6
+
7
+ impl Net {
8
+ // Create new network
9
+ pub fn new ( size : ( u32 , u32 ) , dimension : u32 ) -> Net {
10
+ Net {
11
+ nodes : vec ! [ vec![ 0i32 ; dimension as usize ] ; ( size. 0 * size. 1 ) as usize ] ,
12
+ size : size
13
+ }
14
+ }
15
+ }
Original file line number Diff line number Diff line change 1
1
use crate :: enums:: * ;
2
+ use crate :: core:: * ;
2
3
3
4
// SOM Struct
4
5
pub struct SOM {
@@ -25,8 +26,29 @@ impl SOM {
25
26
}
26
27
}
27
28
28
- // Start train
29
+ // Start training
29
30
pub fn train ( & self , dataset : & Vec < & Vec < i32 > > , iterations : i32 ) -> ( ) {
31
+ let dimension: u32 = 3 ; // Dimension
32
+ let _net: Net = Net :: new ( self . size , dimension) ;
33
+
34
+ // For each iteration
35
+ for _i in 0 ..iterations {
36
+ // Foe each dataitem
37
+ for _item in dataset {
38
+
39
+ // println!("{}", item[0])
40
+ }
41
+
42
+ // println!("{}", i);
43
+ }
44
+
45
+
46
+
47
+
48
+
49
+
30
50
println ! ( "Traing {} {}" , dataset[ 1 ] [ 2 ] , iterations) ;
51
+
52
+
31
53
}
32
54
}
Original file line number Diff line number Diff line change 1
- mod enums;
2
1
mod core;
2
+ mod enums;
3
+ mod helpers;
3
4
4
- pub use crate :: enums:: * ;
5
5
pub use crate :: core:: * ;
6
+ pub use crate :: enums:: * ;
7
+ pub use crate :: helpers:: * ;
You can’t perform that action at this time.
0 commit comments