ncnn:提取所有层特征值
官方代码托管地址:https://github.com/Tencent/ncnn
在Extractor类中添加以下方法:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | 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\n" ); // header fprintf (fp, net->blobs[blob_index].name.c_str()); fprintf (fp, "\n" ); for ( int idx = 0; idx < outMat.w * outMat.h * outMat.c; idx++) fprintf (fp, "%f\n" , outMat[idx]); fclose (fp); } return 0; } |
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步