zoukankan      html  css  js  c++  java
  • mini-caffe:提取所有层特征值

    官方代码托管地址:https://github.com/luoyetx/mini-caffe

    在Net类中增加以下方法:

    const int Net::extract_all_blobs() const {
      for(int blob_idx = 0; blob_idx < blobs_.size(); blob_idx++) {
        shared_ptr<Blob> blob_ptr = blobs_[blob_idx];
        const float *pData = blob_ptr->cpu_data();
    
          // write to file
          char path[256];
          char id[8];
    
          strcpy(path, "./minicaffe_blobs_data/");
          sprintf(id, "%d", blob_idx);
          strcat(path, id);
          strcat(path, ".txt");
    
          FILE *fp = fopen(path, "w+");
          if(!fp)
            fprintf(stderr, "error open file
    ");
    
          // header
          // value to key
          char blob_name[256];
          for (auto iter : blob_names_index_)
            if (iter.second == blob_idx){
              strcpy(blob_name, iter.first.c_str());
              break;
            }
    
          fprintf(fp, blob_name);
          fprintf(fp, "
    ");
    
          for (int w = 0; w < blob_ptr->count(); w++)
            fprintf(fp, "%f
    ", pData[w]);
          fclose(fp);
      }
    
      return 0;
    }
    

      

  • 相关阅读:
    0615-temp-python web
    ResultSet 转ArrayList
    svn与git
    日期与时间
    springboot 注解
    函数式编程
    几个O
    springboot框架中的异步执行
    JDBC
    mysql 导出表结构
  • 原文地址:https://www.cnblogs.com/pepetang/p/11347532.html
Copyright © 2011-2022 走看看