Blob Blame Raw

#include <time.h>
#include <stdlib.h>

#include "nntrain.inc.c"


int main() {
  srand(time(NULL));

  printf("load training data\n");
  NeuralTrainer *nt = ntNewSymbolMap("data/symbols-data.bin", 784, 10);
  if (!nt) return 1;

  printf("create neural network\n");
  double tr = 0.1;
  NeuralLayer *nl = nlNew(NULL, 784, tr);
  nlNew(nl, 256, tr);
  nlNew(nl, 128, tr);
  nlNew(nl, 64, tr);
  nlNew(nl, 64, tr);
  nlNew(nl, 10, tr);

  printf("try load previously saved network\n");
  nlLoad(nl, "data/weights.bin");

  printf("train\n");
  ntTrain(nt, nl, 10, 100, 0.4);
  ntTrain(nt, nl, 10, 100, 0.2);
  ntTrain(nt, nl, 10, 100, 0.1);
  ntTrain(nt, nl, 10, 100, 0.05);

  printf("save neural network weights\n");
  if (!nlSave(nl, "data/output/weights.bin")) return 1;

  return 0;
}