官方代码托管地址:https://github.com/Tencent/ncnn
在Extractor类中添加以下方法:
int Extractor::extract_all_blobs() { for (int blob_index = 0; blob_index < blob_mats.size(); blob_index++) { Mat outMat; extract(blob_index, outMat); // write to file char path[256]; char id[8]; strcpy(path, "./ncnn_blobs_data/"); sprintf(id, "%d", blob_index); strcat(path, id); strcat(path, ".txt"); FILE *fp = fopen(path, "w+"); if(!fp) fprintf(stderr, "error open file "); // header fprintf(fp, net->blobs[blob_index].name.c_str()); fprintf(fp, " "); for (int idx = 0; idx < outMat.w * outMat.h * outMat.c; idx++) fprintf(fp, "%f ", outMat[idx]); fclose(fp); } return 0; }