Home > samsung-code > trainInit.m

trainInit

PURPOSE ^

TRAININIT initilize all the parameters for training

SYNOPSIS ^

function [PARAM, SPECIFIC_DIRS, CategIdOfInterest] = trainInit( model_type )

DESCRIPTION ^

 TRAININIT initilize all the parameters for training
 
 Usage:

   [PARAM, SPECIFIC_DIRS, CategIdOfInterest] = trainInit( model_type )

 Input:

   model_type: can be a string naming the classifier model type:
       'struct' - (linear) structured SVM, 
                  use the models in ./models_svm_linear
       'linear' - ordinary linear SVM
                  use the models in ./models_svm_struct

 Output: All outputs are useful for training

   PARAM: all the parameters for training
     They are specified in 
       ./train_pipeline/params_commons.m
       ./train_pipeline/params_svm_linear.m
       ./train_pipeline/params_svm_struct.m

   SPECIFIC_DIRS: cache paths for all the trainging stages
     Training with linear and structured SVM shared some stages (used the
     same cache paths), and differs at other stages (used different cache paths)
    Also refer to the ./train_pipeline/params_*.m

   SPECIFIC_DIRS: is a vector of integer number that indicates
     which categories should be included in the further training
    It is always be 1:N, where N is the number of categories.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [PARAM, SPECIFIC_DIRS, CategIdOfInterest] = trainInit( model_type )
0002 % TRAININIT initilize all the parameters for training
0003 %
0004 % Usage:
0005 %
0006 %   [PARAM, SPECIFIC_DIRS, CategIdOfInterest] = trainInit( model_type )
0007 %
0008 % Input:
0009 %
0010 %   model_type: can be a string naming the classifier model type:
0011 %       'struct' - (linear) structured SVM,
0012 %                  use the models in ./models_svm_linear
0013 %       'linear' - ordinary linear SVM
0014 %                  use the models in ./models_svm_struct
0015 %
0016 % Output: All outputs are useful for training
0017 %
0018 %   PARAM: all the parameters for training
0019 %     They are specified in
0020 %       ./train_pipeline/params_commons.m
0021 %       ./train_pipeline/params_svm_linear.m
0022 %       ./train_pipeline/params_svm_struct.m
0023 %
0024 %   SPECIFIC_DIRS: cache paths for all the trainging stages
0025 %     Training with linear and structured SVM shared some stages (used the
0026 %     same cache paths), and differs at other stages (used different cache paths)
0027 %    Also refer to the ./train_pipeline/params_*.m
0028 %
0029 %   SPECIFIC_DIRS: is a vector of integer number that indicates
0030 %     which categories should be included in the further training
0031 %    It is always be 1:N, where N is the number of categories.
0032 
0033 % addpath
0034 
0035 TOOLBOX_ROOT_DIR = fileparts(which(mfilename('fullpath')));
0036 addpath( genpath( fullfile( TOOLBOX_ROOT_DIR, 'dependency' ) ) );
0037 addpath( genpath( fullfile( TOOLBOX_ROOT_DIR, 'caffe/matlab/caffe' ) ) );
0038 addpath( genpath( fullfile( TOOLBOX_ROOT_DIR, 'train_pipeline' ) ) );
0039 addpath( genpath( fullfile( TOOLBOX_ROOT_DIR, 'voc2007/VOCdevkit/VOCcode' ) ) );
0040 addpath( TOOLBOX_ROOT_DIR );
0041 
0042 % compile
0043 compile_dependency
0044 
0045 % settings
0046 PARAM = struct();
0047 SPECIFIC_DIRS = struct();
0048 params_common;  % load common settings
0049 
0050 switch model_type
0051     case 'linear'
0052         params_svm_linear;  % load specific settings for linear SVM
0053     case 'struct'
0054         params_svm_struct;  % load specific settings for structured SVM
0055     otherwise
0056         error( 'Unrecognized svm_type' );
0057 end
0058 
0059 % cache path
0060 CACHE_ROOT = fullfile( TOOLBOX_ROOT_DIR, 'voc2007_train_cache' );
0061 specific_fieldnames = fieldnames(SPECIFIC_DIRS);
0062 for k = 1:length(specific_fieldnames)
0063     cmdstr = sprintf('SPECIFIC_DIRS.%s = fullfile(CACHE_ROOT,SPECIFIC_DIRS.%s);', ...
0064         specific_fieldnames{k}, specific_fieldnames{k});
0065     eval( cmdstr );
0066     mkdir_p( eval(sprintf('SPECIFIC_DIRS.%s',specific_fieldnames{k})) );
0067 end
0068 SPECIFIC_DIRS.VOC2007_ROOT = fullfile( TOOLBOX_ROOT_DIR, 'voc2007/VOCdevkit/VOC2007' );
0069 
0070 %
0071 CategIdOfInterest = PARAM.CategIdOfInterest;

Generated on Thu 18-Dec-2014 22:27:44 by m2html © 2005