zoukankan      html  css  js  c++  java
  • Matconvnet 的一些记录

     

    Matconvnet 的一些记录

     

    Example code from ADNet: Action-Decision Networks for Visual Tracking with Deep Reinforcement Learning [Paper]

    GitHubhttps://github.com/hellbell/ADNet

    1. 加载一个模型,然后去掉某些层,,如将 Conv + fc 改为 全卷机的(only Conv):

    function [net, net_conv, net_fc] = split_dagNN(net)
    
    net.move('cpu');
    net_fc = copy(net);
    net_conv = copy(net);
    
    % remove the fc layers, only the convolutional layers remained. 
    layer_names = {};
    for ii = 1 : 10
        layer_names{ii} = net_fc.layers(ii).name;
    end
    net_fc.removeLayer(layer_names);
    net_fc.rebuild();
    
    % remove the convolutional layers, and only the fc layers remained. 
    layer_names = {};
    for ii = 11 : numel(net.layers)
        layer_names{ii-10} = net_conv.layers(ii).name;
    end
    net_conv.removeLayer(layer_names);
    net_conv.rebuild(); 
    
    net.move('gpu');
    
    net_fc.rebuild();
    

    2. 得到特定 layer 的索引和值(index 和 value):

    tutorial from:http://www.vlfeat.org/matconvnet/quick/

    % run the CNN
    net.eval({'data', im_}) ;
    
    % obtain the CNN otuput
    scores = net.vars(net.getVarIndex('prob')).value ;  %% net.getVarIndex('prob')---> 是分类输出概率的那个 layer 的index XXX,然后 net.var(XXX).value 输出的是:对应 XXX 的特定概率值。
    scores = squeeze(gather(scores)) ;  %% gather 应该是将 GPU data 转为 CPU data 的方法 
    

    3.   

  • 相关阅读:
    棋盘问题 简单搜索DFS
    Equivalent Strings
    素数环
    LeetCode Maximum Product Subarray
    UVA 725 – Division
    矩形嵌套问题
    ACM最大子串和问题
    ACM装箱问题
    ACM田胫赛马
    ACM雷达安放问题
  • 原文地址:https://www.cnblogs.com/wangxiaocvpr/p/8268292.html
Copyright © 2011-2022 走看看