Ejemplo n.º 1
0
void net_classify_cats(network_t* net, vol_t** input, double* output, int n) {
  batch_t* batch = make_batch(net, 1);

  for (int i = 0; i < n; i++) {
    copy_vol(batch[0][0], input[i]);
    net_forward(net, batch, 0, 0);
    output[i] = batch[11][0]->w[CAT_LABEL]; 
  }

  free_batch(batch, 1);
}
Ejemplo n.º 2
0
    void train_batch(IIT input_first, IIT input_last, EIT expected_first, EIT expected_last, trainer_type& trainer, rbm_training_context& context, rbm_t& rbm) {
        ++batches;

        auto input_batch    = make_batch(input_first, input_last);
        auto expected_batch = make_batch(expected_first, expected_last);
        trainer->train_batch(input_batch, expected_batch, context);

        context.reconstruction_error += context.batch_error;
        context.sparsity += context.batch_sparsity;

        cpp::static_if<EnableWatcher && layer_traits<rbm_t>::free_energy()>([&](auto f) {
            for (auto& v : input_batch) {
                context.free_energy += f(rbm).free_energy(v);
            }
        });

        if (EnableWatcher && layer_traits<rbm_t>::is_verbose()) {
            watcher.batch_end(rbm, context, batches, total_batches);
        }
    }
Ejemplo n.º 3
0
void net_classify_cats(network_t* net, vol_t** input, double* output, int n) {
  

  #pragma omp parallel for
  for (int i = 0; i < n; i+=8) {
    batch_t* batch = make_batch(net, 8);
    copy_vol(batch[0][0], input[i]);
    copy_vol(batch[0][1], input[i+1]);
    copy_vol(batch[0][2], input[i+2]);
    copy_vol(batch[0][3], input[i+3]);
    copy_vol(batch[0][4], input[i + 4]);
    copy_vol(batch[0][5], input[i + 5]);
    copy_vol(batch[0][6], input[i + 6]);
    copy_vol(batch[0][7], input[i + 7]);

    net_forward(net, batch, 0, 7);
    output[i] = batch[11][0]->w[CAT_LABEL]; 
    output[i + 1] = batch[11][1]->w[CAT_LABEL]; 
    output[i + 2] = batch[11][2]->w[CAT_LABEL];
    output[i + 3] = batch[11][3]->w[CAT_LABEL]; 
    output[i + 4] = batch[11][4]->w[CAT_LABEL]; 
    output[i + 5] = batch[11][5]->w[CAT_LABEL];
    output[i + 6] = batch[11][6]->w[CAT_LABEL];
    output[i + 7] = batch[11][7]->w[CAT_LABEL];
    free_batch(batch, 1);
  }
  double time0 = (double)net->l0->myTime;
  double time1 = (double)net->l1->myTime;
  double time2 = (double)net->l2->myTime;
  double time3 = (double)net->l3->myTime;
  double time4 = (double)net->l4->myTime;
  double time5 = (double)net->l5->myTime;
  double time6 = (double)net->l6->myTime;
  double time7 = (double)net->l7->myTime;
  double time8 = (double)net->l8->myTime;
  double time9 = (double)net->l9->myTime;
  double time10 = (double)net->l10->myTime;

  double totalTime = time0 + time1+ time2 + time3 + time4 + time5 + time6 + time7 + time8 + time9 + time10;
  printf("%s %lf %s %lf \n","conv_layer1 in ms is ", time0/1000,"and of total time is ", time0/totalTime);
  printf("%s %lf %s %lf \n","relu layer1", time1/1000, "and of total time is ",time1/totalTime *100);
  printf("%s %lf %s %lf \n","pool layer1", time2/1000, "and of total time is",time2/totalTime*100);
  printf("%s %lf %s %lf \n","conv_layer2", time3/1000, "and of total time is",time3/totalTime*100);
  printf("%s %lf %s %lf \n","relu layer2", time4/1000, "and of total time is",time4/totalTime*100);
  printf("%s %lf %s %lf \n","pool layer2", time5/1000, "and of total time is",time5/totalTime*100);
  printf("%s %lf %s %lf \n","conv_layer3", time6/1000, "and of total time is",time6/totalTime*100);
  printf("%s %lf %s %lf \n","relu layer3", time7/1000, "and of total time is",time7/totalTime*100);
  printf("%s %lf %s %lf \n","pool layer3", time8/1000, "and of total time is",time8/totalTime*100);
  printf("%s %lf %s %lf \n","fc layer", time9/1000, "and of total time is",time9/totalTime*100);
  printf("%s %lf %s %lf \n","softmax layer", time10/1000, "and of total time is",time10/totalTime*100);

  double convTime = time0 + time3 + time6;
  double reluTime = time1 + time4 + time7;
  double poolTime = time2 + time5 + time8;
  double fc_layer = time9;
  double softmax_layer_t = time10;
  
  printf("%s %lf \n","Time spent in conv_layer is ", convTime/totalTime *100);
  printf("%s %lf \n","Time spent in reluTime is ", reluTime/totalTime*100);
  printf("%s %lf \n","Time spent in poolTime is ", poolTime/totalTime*100);
  printf("%s %lf \n","Time spent in fc_layer is ", fc_layer/totalTime*100);
  printf("%s %lf \n","Time spent in softmax_layer_t is ", softmax_layer_t/totalTime*100);
  
}