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
use ndarray::array;
use super::{Dataset, DatasetType};
pub static XOR: Dataset = Dataset {
name: "XOR",
dataset_type: DatasetType::Static(|| {
let x = array![[0.0, 0.0], [0.0, 1.0], [1.0, 0.0], [1.0, 1.0]];
let y = array![[0.0], [1.0], [1.0], [0.0]];
(x, y)
}),
};
pub static CIRCLE: Dataset = Dataset {
name: "Circle",
dataset_type: DatasetType::Dynamic(
|x| {
let dist_from_center = ((x[0] - 0.5).powi(2) + (x[1] - 0.5).powi(2)).sqrt();
let y = if dist_from_center < 0.25 { 1.0 } else { 0.0 };
array![y]
},
(2, 1),
),
};
pub static RGB_TEST: Dataset = Dataset {
name: "RGB_TEST",
dataset_type: DatasetType::Dynamic(
|x| {
let r = x[0];
let g = x[1];
let b = 1.0 - r;
array![r, g, b]
},
(2, 3),
),
};
pub static RGB_DONUT: Dataset = Dataset {
name: "RGB_DONUT",
dataset_type: DatasetType::Dynamic(
|x| {
let dist_from_center = ((x[0] - 0.5).powi(2) + (x[1] - 0.5).powi(2)).sqrt();
let r = x[0];
let g = x[1];
let b = 1.0 - r;
if dist_from_center > 0.25 && dist_from_center < 0.45 {
array![r, g, b]
} else {
array![0.0, 0.0, 0.0]
}
},
(2, 3),
),
};