Matconvnet工具箱在Matlab中的安装

时间:2017-06-15 20:58:09   收藏:0   阅读:2582

安装

 

 

测试

 

 

 

% Download a pre-trained CNN from the web (needed once).
urlwrite(‘http://www.vlfeat.org/matconvnet/models/imagenet-vgg-f.mat‘,‘imagenet-vgg-f.mat‘) ;
% Load a model and upgrade it to MatConvNet current version.
net = load(‘imagenet-vgg-f.mat‘) ;
net = vl_simplenn_tidy(net) ;
% Obtain and preprocess an image.
im = imread(‘peppers.png‘) ;
im_ = single(im) ; % note: 255 range
im_ = imresize(im_, net.meta.normalization.imageSize(1:2)) ;
im_ = im_ - net.meta.normalization.averageImage ;
% Run the CNN.
res = vl_simplenn(net, im_) ;
% Show the classification result.
scores = squeeze(gather(res(end).x)) ;
[bestScore, best] = max(scores) ;figure(1) ; clf ; imagesc(im) ;
title(sprintf(‘%s (%d), score %.3f‘, net.meta.classes.description{best}, best, bestScore)) ;

技术分享

 

 

Using DAG models

The example above exemplifies using a model using the SimpleNN wrapper. More complex models use the DagNN wrapper instead. For example, to run GoogLeNet use:

% setup MatConvNet
run  matlab/vl_setupnn

% download a pre-trained CNN from the web (needed once)
urlwrite(...
  ‘http://www.vlfeat.org/matconvnet/models/imagenet-googlenet-dag.mat‘, ...
  ‘imagenet-googlenet-dag.mat‘) ;

% load the pre-trained CNN
net = dagnn.DagNN.loadobj(load(‘imagenet-googlenet-dag.mat‘)) ;
net.mode = ‘test‘ ;

% load and preprocess an image
im = imread(‘peppers.png‘) ;
im_ = single(im) ; % note: 0-255 range
im_ = imresize(im_, net.meta.normalization.imageSize(1:2)) ;
im_ = bsxfun(@minus, im_, net.meta.normalization.averageImage) ;

% run the CNN
net.eval({‘data‘, im_}) ;

% obtain the CNN otuput
scores = net.vars(net.getVarIndex(‘prob‘)).value ;
scores = squeeze(gather(scores)) ;

% show the classification results
[bestScore, best] = max(scores) ;
figure(1) ; clf ; imagesc(im) ;
title(sprintf(‘%s (%d), score %.3f‘,...
net.meta.classes.description{best}, best, bestScore)) ;

技术分享

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


 

原文:http://www.cnblogs.com/wylhouse/p/7019885.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!