 " labels found:      " << std::endl;
  auto i = 0;
  for (auto label : class_labels) {
    std::cout << "  " << i << ": " << label << " #" << class_size[i]
              << std::endl;
    i++;
  }
  std::cout << image_files.size() << " files found " << std::endl;

  std::cerr << "  loading model.. \r" << std::flush;
  NetDef full_init_model, full_predict_model;
  ModelUtil full(full_init_model, full_predict_model);
  Keeper(FLAGS_model).AddModel(full, has_split, class_labels.size());

  if (FLAGS_device == "cudnn") {
    full.init.SetEngineOps("CUDNN");
    full.predict.SetEngineOps("CUDNN");
  }

  NetDef init_model[kRunNum], predict_model[kRunNum];
  ModelUtil models[kRunNum] = {
      {init_model[kRunTrain], predict_model[kRunTrain],
       name_for_run[kRunTrain]},
      {init_model[kRunTest], predict_model[kRunTest], name_for_run[kRunTest]},
      {init_model[kRunValidate], predict_model[kRunValidate],
       name_for_run[kRunValidate]},
  };

  NetDef first_init_model, first_predict_model;
  ModelUtil first(first_init_model, first_predict_model);
  NetDef second_init_model, second_predict_model;
  ModelUtil second(second_init_model, second_predict_model);

  if (has_split) {
    full.predict.CheckLayerAvailable(FLAGS_layer);
    std::cout << "split model.. (at " << FLAGS_layer << ")" << std::endl;
    full.Split(FLAGS_layer, first, second, FLAGS_device!= "cudnn");
    if (FLAGS_device!= "cpu") {
      first.SetDeviceCUDA();
    }
  } else {
    second.init.net = full.init.net;
    second.predict.net = full.predict.net;
  }

  std::cerr << "  counting cached images.. \r" << std::flush;
  std::set<std::string> keys;
  auto count = count_samples(db_paths, FLAGS_db_type, image_files.size(), keys);
  std::cerr << "  preprocessing images.. \r" << std::flush;
  count = preprocess(image_files, db_paths, first, FLAGS_db_type, FLAGS_batch,
                     FLAGS_size, FLAGS_size, keys);
  std::cout << count << " images cached" << std::endl;
  load_time += clock();

  if (count == 0) {
    std::cerr << "no images in database" << std::endl;
    return;
  }

  auto model_in = has_split? FLAGS_layer : full.predict.Input(0);
  for (int i = 0; i < kRunNum; i++) {
    models[i].AddDatabaseOps(name_for_run[i], model_in, db_paths[i],
                             FLAGS_db_type, FLAGS_batch);
  }
  second.CopyTrain(model_in, class_labels.size(), models[kRunTrain]);
  second.CopyTest(models[kRunValidate]);
  second.CopyTest(models[kRunTest]);

  auto output = models[kRunTrain].predict.Output(0);
  if (FLAGS_reshape) {
    auto output_reshaped = output + "_reshaped";
    for (int i = 0; i < kRunNum; i++) {
      models[i].predict.AddReshapeOp(output, output_reshaped, {0, -1});
    }
    output = output_reshaped;
  }

  models[kRunTrain].AddTrainOps(output, FLAGS_lr, FLAGS_optimizer);
  ModelUtil(second.predict, models[kRunValidate].predict).AddTestOps(output);
  ModelUtil(second.predict, models[kRunTest].predict).AddTestOps(output);

  if (FLAGS_display) {
    if (!has_split) {
      models[kRunValidate].predict.AddShowWorstOp(output, "label",
                                                  second.predict.Input(0));
    }
    models[kRunTrain].predict.AddTimePlotOp("accuracy", "iter", "accuracy",
                                            "train", 10);
    models[kRunValidate].predict.AddTimePlotOp("accuracy", "iter", "accuracy",
                                               "validate");
    models[kRunTrain].predict.AddTimePlotOp("loss", "iter", "loss", "train",
                                            10);
    models[kRunValidate].predict.AddTimePlotOp("loss", "iter", "loss",
                                               "validate");
    cvplot::figure("accuracy").series("train").color(cvplot::Purple);
    cvplot::figure("accuracy").series("validate").color(cvplot::Pink);
    cvplot::figure("loss").series("train").color(cvplot::Purple);
    cvplot::figure("loss").series("validate").color(cvplot::Pink);
  }

  if (FLAGS_device!= "cpu") {
    for (int i = 0; i < kRunNum; i++) {
      models[i].SetDeviceCUDA();
    }
  }

  if (FLAGS_dump_model) {
    std::cout << models[kRunTrain].Short();
  }

  std::cout << std::endl;

  Workspace workspace("tmp");

  clock_t train_time = 0;
  clock_t validate_time = 0;
  clock_t test_time = 0;

  std::cout << "training.." << std::endl;
  run_trainer(FLAGS_iters, models[kRunTrain], models[kRunValidate], workspace,
              train_time, validate_time);

  std::cout << std::endl;
  std::cout << "testing.." << std::endl;
  run_tester(FLAGS_test_runs, models[kRunTest], workspace, test_time,
             FLAGS_matrix);

  NetDef deploy_init_model;  // the final initialization model
  ModelUtil deploy(deploy_init_model, full.predict.net,
                   "train_" + full.init.net.name());
  full.CopyDeploy(deploy, workspace);

  std::cout << std::endl;

  std::cout << "saving model.. (" << (path_prefix + model_safe) << "_%_net.pb)"
            << std::endl;
  size_t model_size = deploy.Write(path_prefix + model_safe);

  std::cout << std::setprecision(3)
            << "load: " << ((float)load_time / CLOCKS_PER_SEC)
            << "s  train: " << ((float)train_time / CLOCKS_PER_SEC)
            << "s  validate: " << ((float)validate_time / CLOCKS_PER_SEC)
            << "s  test: " << ((float)test_time / CLOCKS_PER_SEC)
            << "s  model: " << ((float)model_size / 1000000) << "MB"
            << std::endl;

  if (FLAGS_display) {
    std::cout << "press Ctrl+C to quit" << std::endl;
    cvWaitKey(0);
  }
}

}  // namespace caffe2

int main(int argc, char **argv) {
  caffe2::GlobalInit(&argc, &argv);
  caffe2::run();
  google::protobuf::ShutdownProtobufLibrary();
  return 0;
}
Cybex Summer Cover – White – compatible with...
The Cybex Pallas S is a 2-in-1 child seat that grows with. From 9 months to the age of 12, this car seat is suitable for your child. The optimized catch body of the Pallas S reduces the risk of serious neck injuries without restricting the child. A quick setting of the catch body is facilitated by the one-handed adjustment mechanism.
Get The Online Casino Bonus
You’ve joined an on the net casino with a no deposit bonus, your account is loaded with free casino chips you begin to convincingly play. That