PandA-2024.02
generate.c
Go to the documentation of this file.
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.h>
4 #include <sys/types.h>
5 #include <sys/stat.h>
6 #include <fcntl.h>
7 #include <unistd.h>
8 #include <assert.h>
9 
10 //#include "sol.h"
11 //#include "train.h"
12 #include "backprop.h"
13 
14 int main( int argc, const char* argv[] ){
15  int i, j, fd;
16 
17  struct bench_args_t data;
18  struct prng_rand_t state;
19 
20  prng_srand(1, &state);
21  for( i = 0; i < input_dimension; i++){
22  for( j = 0; j < nodes_per_layer; j++){
23  data.weights1[i*nodes_per_layer + j] = (((TYPE)prng_rand(&state)/((TYPE)(PRNG_RAND_MAX))) * max) - offset;
24  }
25  }
26  for( i = 0; i < nodes_per_layer; i++){
27  data.biases1[i] = (((TYPE)prng_rand(&state)/((TYPE)(PRNG_RAND_MAX))) * max) - offset;
28  data.biases2[i] = (((TYPE)prng_rand(&state)/((TYPE)(PRNG_RAND_MAX))) * max) - offset;
29  for( j = 0; j < nodes_per_layer; j++){
30  data.weights2[i*nodes_per_layer + j] = (((TYPE)prng_rand(&state)/((TYPE)(PRNG_RAND_MAX))) * max) - offset;
31  }
32  }
33  for( i = 0; i < nodes_per_layer; i++){
34  data.biases3[i] = (((TYPE)prng_rand(&state)/((TYPE)(PRNG_RAND_MAX))) * max) - offset;
35  for( j = 0; j < possible_outputs; j++){
36  data.weights3[i*possible_outputs + j] = (((TYPE)prng_rand(&state)/((TYPE)(PRNG_RAND_MAX))) * max) - offset;
37  }
38  }
39  for( i = 0; i < training_sets; i++){
40  for( j = 0; j < input_dimension; j++)
41  data.training_data[i*input_dimension + j] = (TYPE)training_data[i][j];
42  for( j = 0; j < possible_outputs; j++)
43  data.training_targets[i*possible_outputs + j] = (TYPE)0;
44  data.training_targets[i*possible_outputs + (training_targets[i] - 1)] = 1.0;
45  }
46 
47  fd = open("input.data", O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
48  assert( fd>0 && "Couldn't open input data file");
49 
50  data_to_input(fd, (void *)(&data));
51 
52  return 0;
53 }
static uint64_t prng_rand(struct prng_rand_t *state)
Definition: support.h:85
#define input_dimension
Definition: backprop.h:7
void data_to_input(int fd, void *vdata)
Definition: local_support.c:34
#define TYPE
Definition: backprop.h:21
TYPE weights1[input_dimension *nodes_per_layer]
Definition: backprop.h:38
#define max
Definition: backprop.h:17
#define training_sets
Definition: backprop.h:9
TYPE biases3[possible_outputs]
Definition: backprop.h:43
#define possible_outputs
Definition: backprop.h:8
uint_fast16_t i
Definition: support.h:78
unsigned offset[NUM_VERTICES+1]
Definition: graph.h:3
TYPE biases2[nodes_per_layer]
Definition: backprop.h:42
TYPE training_targets[training_sets *possible_outputs]
Definition: backprop.h:45
TYPE weights2[nodes_per_layer *nodes_per_layer]
Definition: backprop.h:39
TYPE biases1[nodes_per_layer]
Definition: backprop.h:41
TYPE weights3[nodes_per_layer *possible_outputs]
Definition: backprop.h:40
#define nodes_per_layer
Definition: backprop.h:10
int main(int argc, char **argv)
Definition: generate.c:12
TYPE training_data[training_sets *input_dimension]
Definition: backprop.h:44
static void prng_srand(uint64_t seed, struct prng_rand_t *state)
Definition: support.h:106
#define PRNG_RAND_MAX
Definition: support.h:82

Generated on Mon Feb 12 2024 13:02:49 for PandA-2024.02 by doxygen 1.8.13