Advanced Learning Record of Matlab

Source: Internet
Author: User
Tags random seed

Recently looking at Faster rcnn matlab code, found a lot of MATLAB skills, in this record:

1. conf_proposal = Proposal_config (' Image_means ', model.mean_image, ' feat_stride ', model.feat_stride);

  

function conf = proposal_config (varargin)% conf = proposal_config (varargin)%---------------------------------------- ----------------% Faster r-cnn% Copyright (c), shaoqing Ren% Licensed under the MIT License [see License for details ]% --------------------------------------------------------IP = inputparser; Percent training Ip.addparamvalue (' Use_gpu ', Gpudevicecount > 0, ... @islogical);                                         % whether drop the anchors that have edges outside of the image boundary IP.ADDP        Aramvalue (' Drop_boxes_runoff_image ', ... true, @islogical);                                                                                                    % Image Scales-the short edge of input Image    Ip.addparamvalue (' scales ', @ismatrix);    % Max pixel size of a scaled input image ip.addparamvalue (' max_size ',, @isscalar); % Images per batch, only supports Ims_per_batch = 1 currently ip.addparamvalue (' Ims_per_batch ', 1, @issc    Alar);    % Minibatch size ip.addparamvalue (' batch_size ', N, @isscalar); % fraction of minibatch that is foreground labeled (Class > 0) ip.addparamvalue (' fg_fraction ', 0.5, @i    Sscalar); % weight of background samples, when weight of foreground samples is% 1.0 IP. Addparamvalue (' Bg_weight ', 1.0, @isscalar);             % overlap threshold for a ROI to be considered foreground (if >= fg_thresh) ip.addparamvalue (' Fg_thresh ', 0.7,    @isscalar); % overlap threshold for a ROI to being considered background (class = 0 if% overlap in [bg_thresh_lo, Bg_thresh_hi)) I    P.addparamvalue (' Bg_thresh_hi ', 0.3, @isscalar);    Ip.addparamvalue (' Bg_thresh_lo ', 0, @isscalar);    % mean image, in RGB order Ip.addparamvalue (' Image_means ',, @ismatrix);    % use horizontally-flipped images during training?    Ip.addparamvalue (' use_flipped ', true, @islogical); % Stride in input image pixels at ROI pooling level (network specific)% are true for {alex,caffe}net, vgg_cnn_m_1024    , and VGG16 ip.addparamvalue (' feat_stride ', @isscalar); % train proposal target only to labled ground-truths or also include% other proposal results (selective Search, etc.)    Ip.addparamvalue (' Target_only_gt ', true, @islogical);        % random seed ip.addparamvalue (' Rng_seed ', 6, @isscalar);    Percent Testing Ip.addparamvalue (' Test_scales ', @isscalar);    Ip.addparamvalue (' test_max_size ', +, @isscalar);    Ip.addparamvalue (' Test_nms ', 0.3, @isscalar);    Ip.addparamvalue (' Test_binary ', false, @islogical);    Ip.addparamvalue (' test_min_box_size ', @isscalar);        Ip.addparamvalue (' Test_drop_boxes_runoff_image ', ... false, @islogical);ip.parse (varargin{:}); conf = IP. Results;ASSERT (Conf.ims_per_batch = = 1, ' currently RPN only supports ims_per_batch = = 1 ');        % if Image_means is a file, load it ... if Ischar (conf.image_means) s = load (Conf.image_means);        S_fieldnames = FieldNames (s);        Assert (Length (s_fieldnames) = = 1);    Conf.image_means = S. (S_fieldnames{1}); EndEnd

  

The inputParser object allows manage inputs to a function by creating an input scheme. To check the input, you can define validation functions for required arguments, optional arguments, and name-value pair AR Guments. Optionally, can set properties to adjust the parsing behavior, such as handling case sensitivity, structure array Inpu TS, and inputs that is not in the input scheme.

After calling parse the method to the parse the inputs, the inputParser saves names and values of inputs that match the input scheme (stored in Results ), names of inputs that is passed to the function and, therefore, is assigned default values (store D UsingDefaults in), and names and values of inputs that does not match the input scheme (stored in Unmatched ).

  

Check the validity of required and optional function inputs. Create a custom function with required and optional inputs in the fileFINDAREA.M.function A = Findarea (Width,varargin)p = inputparser;DefaultHeight = 1;   defaultunits = ' inches ';   DefaultShape = ' Rectangle '; Expectedshapes = {' Square ', ' rectangle ', ' parallelogram '};addrequired (P, ' width ', @isnumeric);   Addoptional (p, ' height ', defaultheight, @isnumeric);   Addparameter (p, ' units ', defaultunits); Addparameter (P, ' shape ', defaultshape,... @ (x) any (validatestring (x,expectedshapes)));   Parse (p,width,varargin{:});A = p.results.width. * P.results.height;
The input parser checks whether width and height is numeric, and whether the shape matches a string in cell array expecte Dshapes. @ indicates a function handle, and the syntax @ (x) creates an anonymous function with input x.call the function with input s that does not match the scheme. For example, specify a nonnumeric value for the width input:findarea (' text ')The Error using Findarea (line), the value of ' width ' is invalid. It must satisfy the function:isnumeric. Specify an unsupported value for shape:Findarea (4, ' shape ', ' circle ')The Error using Findarea (line), the value of ' shape ' is invalid. Expected input to match one of these strings:square, rectangle, parallelogramthe input, ' circle ', do not match any of t He valid strings.

  

Advanced Learning Record of Matlab

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.