MCPcopy Create free account
hub / github.com/1a1a11a/libCacheSim / dump_training_data

Function dump_training_data

libCacheSim/cache/eviction/GLCache/dataPrep.c:7–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5#include "utils.h"
6
7static void dump_training_data(cache_t *cache) {
8 GLCache_params_t *params = cache->eviction_params;
9 learner_t *learner = &params->learner;
10
11 static __thread char filename[24];
12 snprintf(filename, 24, "train_data_%d", learner->n_train);
13
14 INFO("dump training data %d\n", learner->n_train);
15
16 FILE *f = fopen(filename, "w");
17 fprintf(f, "# y: x\n");
18 for (int m = 0; m < learner->n_train_samples; m++) {
19 fprintf(f, "%f: ", learner->train_y[m]);
20 for (int n = 0; n < learner->n_feature; n++) {
21 fprintf(f, "%6f,", learner->train_x[learner->n_feature * m + n]);
22 }
23 fprintf(f, "\n");
24 }
25 fclose(f);
26
27 snprintf(filename, 24, "valid_data_%d", learner->n_train);
28 f = fopen(filename, "w");
29 for (int m = 0; m < learner->n_valid_samples; m++) {
30 fprintf(f, "%f: ", learner->valid_y[m]);
31 for (int n = 0; n < learner->n_feature; n++) {
32 fprintf(f, "%6f,", learner->valid_x[learner->n_feature * m + n]);
33 }
34 fprintf(f, "\n");
35 }
36 fclose(f);
37}
38
39/* currently we snapshot segments after each training, then we collect segment
40 * utility for the snapshotted segments over time, when it is time to retrain,

Callers 1

dataPrep.cFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected