zoukankan      html  css  js  c++  java
  • 将caffemodel文件转换为Matlab可用的数据形式

    1.MATLAB示例程序:

    %% Load the Caffe.Net and save in model file.
    def = fullfile('..', 'models', 'VGG_CNN_M_1024', 'test.prototxt');
    net = fullfile('..', 'output', 'default', 'voc_2007_trainval', ...
    'vgg_cnn_m_1024_fast_rcnn_iter_40000.caffemodel');
    ConvNet = caffe.Net(def, net, 'test');
    save model/ConvNet ConvNet

    其中,def为网络的test.prototxt文件路径,net为caffe训练得到caffemodel文件路径。调用caffe.Net可以获得MATLAB可以解析的数据形式(矩阵形式),如下所示:
    (示例为Small VGG训练后,转成的Matlab形式的模型参数)

    这里写图片描述

    在matlab命令行内输入代码

    ConvNet.layers('conv1').params(1).get_data();

    可以看见第一个卷积层的参数。

    这里写图片描述

    2.异常处理

    1.Undefined variable “caffe” or class “caffe.Net”

    这里写图片描述

    解决方案:需要在Matlab中加入caffe目录及子目录的路径

    2.Encountered an internal problem

    这里写图片描述

    解决方案:可能是因为CUDA等版本变动导致,重新编译caffe。

    $ cd $(CAFFE_ROOT)
    $ make clean
    $ make -j24
    $ make pycaffe
    $ make matcaffe

    这里写图片描述

    3.部分网络会产生其他错误,具体问题具体分析。

    (FRCNN可以选择其他caffe源,编译并添加路径试试。)

  • 相关阅读:
    整数反转
    两数之和
    设计模式-备忘录模式
    设计模式-迭代器模式
    设计模式-中介者模式
    设计模式-观察者模式
    C# OpenFileDialog和SaveFileDialog的常见用法
    SQL数据库表结构的修改(sql2005)
    C# 时间格式处理
    C# 集合类(四)
  • 原文地址:https://www.cnblogs.com/lixuebin/p/10814846.html
Copyright © 2011-2022 走看看