-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatasets.h
More file actions
167 lines (153 loc) · 10.6 KB
/
Copy pathdatasets.h
File metadata and controls
167 lines (153 loc) · 10.6 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
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#ifndef __MICRO_ML_DATASET_H
#define __MICRO_ML_DATASET_H
#define DATASET_RAM_BUDGET_BYTES_DEFAULT (31360)
#include "pxt.h"
namespace __micro_ml {
struct DataPoint {
const float *features;
int features_len;
int label;
};
//%
enum DatasetEnum {
XOR,
ACCEL
};
struct Dataset {
DataPoint *data_points;
int current_index;
int start_index; // For handling train/test splits
int capacity;
int total_len;
int num_classes;
bool inited;
DatasetEnum ds_enum;
};
struct TestTrainSplitDataset {
Dataset *train;
Dataset *test;
float split;
};
TestTrainSplitDataset *construct_train_test_split_dataset(DatasetEnum dataset_enum,
float training_split,
unsigned ram_budget_kb);
DataPoint *dataset_get_datapoint(Dataset *ds);
Dataset *construct_dataset(DatasetEnum dataset_enum, unsigned start_idx, unsigned stop_idx,
unsigned ram_budget_kb);
void print_dataset_info(Dataset *ds);
unsigned dataset_get_total_len(DatasetEnum dataset_enum);
void print_MNIST_datapoint(const DataPoint *dp);
#define XOR_DATASET_LEN (4)
#define XOR_NUM_CLASSES (2)
#define XOR_DATASET_NUM_FEATURES (2)
#define XOR_DATASET_RAM_COST_BYTES \
((XOR_DATASET_NUM_FEATURES * sizeof(float)) + sizeof(int))
static const unsigned char XOR_LABELS[XOR_DATASET_LEN] = {0x00, 0x00, 0x01, 0x01};
static const unsigned char XOR_RAW_DATA[XOR_DATASET_LEN * XOR_DATASET_NUM_FEATURES] = {
0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00
};
#define ACCEL_DATASET_LEN (40)
#define ACCEL_NUM_CLASSES (2)
#define ACCEL_DATA_POINT_NUM_FEATURES (30)
#define ACCEL_DATA_POINT_RAM_COST_BYTES (ACCEL_DATA_POINT_NUM_FEATURES * sizeof(int16_t))
static const unsigned char ACCEL_LABELS[ACCEL_DATASET_LEN] = {
0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1,
0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0
};
static const int16_t ACCEL_RAW_DATA[ACCEL_DATASET_LEN * ACCEL_DATA_POINT_NUM_FEATURES] = {
44, 92, -1052, 52, 100, -1052, 48, 100, -1056, 52, 96, -1052, 44,
88, -1052, 56, 88, -1056, 40, 88, -1048, 44, 88, -1056, 44, 84,
-1048, 48, 92, -1044, 8, 124, -1056, 12, 128, -1052, 8, 132, -1052,
4, 132, -1048, 12, 124, -1052, 8, 140, -1044, 4, 132, -1048, 8,
128, -1048, 12, 124, -1052, 8, 124, -1048, 588, -1992, -1568, 476, -900,
-76, -1068, -4, 708, 196, -576, -2040, 1076, -680, 2040, -612, -248, -2040,
12, -308, 2040, -828, 108, -2040, 124, 600, -880, 268, 244, -312, 20,
96, -1040, 20, 120, -1052, 24, 116, -1044, 24, 116, -1048, 24, 108,
-1056, 36, 104, -1056, 20, 112, -1048, 36, 100, -1048, 36, 108, -1056,
32, 108, -1048, 12, 116, -1048, 12, 128, -1052, 28, 108, -1052, 24,
104, -1048, 24, 116, -1052, 24, 112, -1048, 16, 112, -1048, 20, 108,
-1048, 16, 108, -1052, 24, 116, -1052, -2040, 2040, -2040, 1248, -2040, -532,
-428, 0, -76, -1508, 1424, -1732, 1824, -2040, 1472, -2040, 2040, -2040, 2040,
-2040, 2040, -2040, 1400, -2040, -248, 244, -1184, 536, -292, -308, 16, 120,
-1048, 8, 120, -1052, 16, 124, -1052, 12, 116, -1048, 16, 120, -1052,
12, 124, -1052, 12, 128, -1052, 12, 124, -1044, 16, 124, -1052, 16,
108, -1048, 8, 128, -1056, 4, 132, -1052, 4, 136, -1056, 12, 124,
-1048, 8, 132, -1052, 8, 124, -1052, 8, 128, -1052, 16, 124, -1052,
8, 120, -1052, 12, 128, -1048, 36, 100, -1040, 32, 108, -1048, 40,
96, -1052, 40, 104, -1056, 84, 32, -1048, 32, 92, -1056, 36, 100,
-1048, 28, 104, -1056, 44, 96, -1052, 36, 96, -1052, 68, 72, -1056,
68, 80, -1048, 68, 72, -1052, 60, 72, -1048, 68, 80, -1056, 64,
80, -1056, 68, 80, -1048, 60, 76, -1048, 60, 72, -1052, 68, 16,
-1052, 20, 104, -1052, 16, 108, -1044, 20, 112, -1056, 20, 108, -1056,
32, 116, -1048, 16, 116, -1044, 28, 112, -1048, 12, 124, -1044, 12,
120, -1052, 16, 116, -1052, -1736, -4, -860, -1436, 1616, -1488, 2040, -2040,
1032, -2040, 1420, -2040, -1112, 460, -980, 2040, -2040, 1484, -2040, 2040, -2040,
668, -2040, -48, 156, -652, 100, -2036, 2040, -2040, 52, 84, -1044, 52,
84, -1052, 52, 84, -1052, 60, 88, -1048, 48, 92, -1052, 52, 84,
-1056, 56, 80, -1048, 44, 84, -1052, 60, 88, -1052, 52, 84, -1052,
-1272, 136, 2040, -2040, 2040, 2040, 128, -2040, -2040, -2040, 2040, -284, -356,
-1732, 2040, -2040, 1464, -2040, -100, -544, -1356, -16, -36, 2040, 216, -1860,
-2040, -568, -548, 1636, 76, 60, -1048, 72, 72, -1056, 68, 76, -1048,
76, 64, -1052, 72, 76, -1052, 68, 72, -1052, 112, 16, -1048, 72,
72, -1048, 72, 68, -1052, 76, 68, -1056, 16, 124, -1048, 12, 124,
-1056, 20, 128, -1048, 12, 120, -1048, 8, 116, -1044, 8, 132, -1048,
12, 120, -1052, 12, 128, -1056, 8, 124, -1044, 16, 120, -1044, -2040,
2040, -2040, 2040, -2040, 1104, -1024, -592, -668, -820, 224, -1840, 2036, -2040,
1464, -2040, 2040, -2040, 2040, -2040, 2040, -1932, 1648, -2040, 588, -768, -1224,
304, 60, -316, 2040, -2040, 268, -2040, 2040, 280, -1224, -788, -1604, -1468,
-1316, -324, -2040, 2040, -1756, 2040, -2040, 2040, -2040, 2040, -2040, 1196, -2040,
2036, -2040, 2040, -2040, 2040, -2040, 2040, 8, 128, -1052, 8, 136, -1052,
4, 132, -1048, -4, 140, -1048, 12, 132, -1056, 8, 128, -1044, 8,
132, -1052, 8, 124, -1044, -4, 144, -1048, 8, 128, -1052, -2040, 2040,
2040, 544, -2040, -2040, -2040, 2040, 1900, -972, -1864, -1896, -560, -324, 1280,
-2040, 2040, -328, 2040, -2040, -992, -2040, 2040, -616, 964, -560, -1504, -260,
740, -856, 8, 112, -1052, 12, 128, -1048, 20, 116, -1044, 16, 112,
-1044, 8, 128, -1052, 12, 120, -1048, 16, 124, -1052, 12, 124, -1052,
16, 108, -1040, 16, 120, -1048, -1696, 2040, -2040, 2040, -2040, 1968, -2040,
2040, -2040, -656, -1884, 88, -840, -1600, -1504, -2040, 2040, -932, 2040, -2040,
-312, -2040, 2040, -2040, 1996, -2040, 772, -1740, 1728, -2040, 8, 128, -1052,
4, 128, -1048, 8, 124, -1044, 12, 124, -1048, 8, 132, -1048, 16,
124, -1056, 12, 120, -1048, 12, 124, -1048, 12, 116, -1056, 20, 120,
-1048, 916, -952, 376, -2040, 2040, -2040, 508, -2040, 580, -1492, -100, -856,
-2032, -8, -988, 2036, -1112, 684, -1484, 2040, -2040, -8, 172, -976, 224,
120, -928, 16, 412, -876, 16, 112, -1048, 16, 112, -1048, 20, 112,
-1052, 20, 112, -1056, 24, 104, -1044, 96, 8, -1056, 32, 104, -1044,
24, 112, -1052, 12, 108, -1036, 24, 112, -1044, -2040, 2040, -2040, 2040,
-2040, 2040, -2040, 1960, -2040, -1004, -952, -800, 1492, -2040, 700, -2040, 2040,
-2040, 2040, -2040, 2040, -2040, 2040, -2040, 1064, -2040, 420, -544, 1124, -1484,
-1608, 1036, -992, 1872, -2040, 544, -2040, 2040, -2040, 764, -2040, 200, -1620,
12, -1356, -1672, 404, -684, 180, -1940, 272, -2040, 2040, -2040, 1568, -2040,
756, -2040, 2040, -2040, 424, -952, 208, -2032, 2040, -2040, 2040, -2040, 1936,
-1016, -484, -1988, -1392, 940, -1768, 2040, -2040, 916, -2040, 1732, -2040, -100,
-820, -1344, 496, -292, -464, -160, 304, -924, -2040, -1124, 2040, -2040, 1464,
1164, -2040, -1744, -724, -2040, 2040, 2040, -1392, -2040, -1840, -1524, 2040, 2040,
-24, -2040, -2036, -2040, 2040, 384, 408, -1900, -1228, 64, 2040, -508, 0,
128, -1048, 8, 136, -1052, 4, 132, -1052, 4, 132, -1052, 8, 136,
-1048, -8, 132, -1044, 4, 128, -1052, 4, 132, -1052, 0, 136, -1048,
0, 132, -1052, -1864, 496, 916, -544, -2040, -872, -2040, 1572, 144, -1896,
-2040, -336, -1684, 2040, 260, 1088, -2040, -564, -1780, 2040, -676, 824, -2040,
-1664, -2008, 2040, -192, 1036, -2040, -1264, -352, -2040, -2040, -1824, 1632, 648,
2040, -2040, -2040, -2040, 2040, 276, 2040, -2040, -2040, -2040, 2040, 36, 1212,
-2040, -1812, -148, 944, -488, 404, 8, -968, 344, 132, -836, -2040, -2040,
-476, -2040, 2040, 980, -924, -2040, 76, -2040, -956, -264, -1112, 2040, 2040,
2040, -2040, 1484, -2040, 2040, -2040, -760, -708, -544, 752, -2040, 1340, -2040,
2040, -1104, -1908, 512, -2040, -312, -696, 1060, -1036, 252, -388, -28, 836,
-2040, 580, -1048, 2040, -820, 872, -2040, -380, -700, 1840, -1112, 952, -1560,
-316, 468, -1988, 168, -840, 2040, 1424, -2040, 232, -2040, 1536, -1828, 168,
-1932, -236, -644, 228, -164, 840, -1488, -1640, 452, -72, 348, 132, 568,
-1508, 352, -8, -768, 304, 236, -1124, 236, 268, -1036, 56, 80, -1052,
56, 88, -1052, 52, 76, -1056, 76, 48, -1044, 56, 76, -1048, 64,
112, -1028, 60, 84, -1052, 52, 84, -1056, 52, 80, -1048, 60, 72,
-1052, 1064, -2040, 496, -2040, -548, -2028, 364, -2040, -936, -1060, -580, -1132,
268, -224, -1288, -120, -924, -960, -1140, 352, -1152, -16, -1472, -504, -668,
1000, -1472, 1292, -892, -284, 636, -1776, 1480, -2040, 2040, -2040, 2040, -2040,
2040, -2040, 2036, -2040, 28, -2040, -296, 76, -1044, -588, -1320, 1776, -1836,
1932, -2040, 1188, -1936, 2040, -2040, 1332, -864, 512, 68, 64, -1052, 68,
68, -1052, 72, 72, -1052, 68, 68, -1052, 72, 68, -1052, 68, 68,
-1052, 72, 72, -1052, 68, 64, -1052, 76, 72, -1056, 72, 64, -1056,
76, 60, -1052, 72, 64, -1052, 68, 60, -1048, 72, 72, -1048, 76,
64, -1048, 64, 64, -1048, 72, 72, -1048, 76, 72, -1056, 64, 72,
-1044, 72, 68, -1052,
};
}
#endif