![]() |
MyCaffe
1.12.2.41
Deep learning software for Windows C# programmers.
|
The ModelBuilder is an abstract class that is overridden by a base class used to programically build new models. More...
Public Types | |
| enum | SCALE_BIAS { NONE , SCALE , BIAS } |
| Defines the scale bias type to use. More... | |
Public Member Functions | |
| ModelBuilder (string strBaseDir, NetParameter net=null, SolverParameter solver=null) | |
| The constructor. More... | |
| abstract SolverParameter | CreateSolver () |
| Create the base solver to use. More... | |
| abstract NetParameter | CreateModel (bool bDeploy=false) |
| Create the training/testing/deploy model to use. More... | |
| abstract NetParameter | CreateDeployModel () |
| Create the deploy model to use. More... | |
Protected Member Functions | |
| string | getFileName (string strFile, string strSubDir) |
| Returns the full path of the filename using the base directory original set when creating the ModelBuilder. More... | |
| abstract LayerParameter | addExtraLayers (bool bUseBatchNorm=true, double dfLrMult=1.0) |
| Add extra layers on top of a 'base' network (e.g. VGGNet or Inception) More... | |
| LayerParameter | findLayer (string strName) |
| Find a layer with a given name. More... | |
| NetParameter | createNet (string strName) |
| Create the base network parameter for the model and set its name to the 'm_strModel' name. More... | |
| LayerParameter | addDataLayer (string strSource, Phase phase, int nBatchSize=32, bool bOutputLabel=true, TransformationParameter transform=null, string strName="data", bool bSiamese=false) |
| Add the Data layer. More... | |
| LayerParameter | addAnnotatedDataLayer (string strSource, Phase phase, int nBatchSize=32, bool bOutputLabel=true, string strLabelMapFile="", SimpleDatum.ANNOTATION_TYPE anno_type=SimpleDatum.ANNOTATION_TYPE.NONE, TransformationParameter transform=null, List< BatchSampler > rgSampler=null) |
| Add the Annotated Data layer. More... | |
| List< LayerParameter > | createMultiBoxHead (LayerParameter data, int nNumClasses, List< MultiBoxHeadInfo > rgInfo, List< float > rgPriorVariance, bool bUseObjectness=false, bool bUseBatchNorm=true, double dfLrMult=1.0, bool useScale=true, int nImageHt=0, int nImageWd=0, bool bShareLocation=true, bool bFlip=true, bool bClip=true, double dfOffset=0.5, int nKernelSize=1, int nPad=0, string strConfPostfix="", string strLocPostfix="") |
| Create the multi-box head layers. More... | |
| LayerParameter | addConvBNLayer (string strInputLayer, string strOutputLayer, bool bUseBatchNorm, bool bUseRelU, int nNumOutput, int nKernelSize, int nPad, int nStride, double dfLrMult=1.0, int nDilation=1, SCALE_BIAS useScale=SCALE_BIAS.SCALE, string strConvPrefix="", string strConvPostfix="", string strBnPrefix="", string strBnPostfix="_bn", string strScalePrefix="", string strScalePostFix="_scale", string strBiasPrefix="", string strBiasPostfix="_bias", bool bNamedParams=false, string strLayerPostfix="", Phase phaseExclude=Phase.NONE) |
| Add convolution, batch-norm layers. More... | |
| LayerParameter | connectAndAddLayer (string fromLayer, LayerParameter toLayer, string fromLayer2=null) |
| Connect the from layer to the 'to' layer. More... | |
| LayerParameter | connectAndAddLayer (LayerParameter fromLayer, LayerParameter toLayer, bool bInPlace=false, bool bAdd=true, int nTopIdx=0) |
| Connect the from layer to the 'to' layer. More... | |
| LayerParameter | connectAndAddLayer (List< LayerParameter > rgFromLayer, LayerParameter toLayer, bool bAdd=true) |
| Connect the from layer to the 'to' layer. More... | |
| LayerParameter | createConvolution (string strName, int nNumOutput, int nKernelSize, int nPad=0, int nStride=1, int nDilation=1) |
| Create a new convolution layer parameter. More... | |
| LayerParameter | createPooling (string strName, PoolingParameter.PoolingMethod method, int nKernelSize, int nPad=0, int nStride=1) |
| Create a new pooling layer parameter. More... | |
| LayerParameter | addVGGBlock (LayerParameter lastLayer, int nBlockIdx, int nConvIdx, int nNumOutput, int nConvCount, bool? bNoPool, bool bDilatePool=false, int nKernelSize=3, int nPad=1, int nStride=1, int nDilation=1) |
| Add a new VGG block. More... | |
| LayerParameter | addVGGfc (LayerParameter lastLayer, int nBlockIdx, int nConvIdx, int nNumOutput, int nDilation, bool bDilated, bool bNoPool, bool bFullConv, bool bReduced, bool bDropout) |
| Adds the final layers to the network. More... | |
| LayerParameter | addVGGNetBody (LayerParameter lastLayer, bool bNeedFc=true, bool bFullConv=true, bool bReduced=true, bool bDilated=true, bool bNoPool=false, bool bDropout=false, List< string > rgstrFreezeLayers=null, bool bDilatePool4=false) |
| Adds the full VGG body to the network, connecting it to the 'lastLayer'. More... | |
| LayerParameter | addResBody (LayerParameter lastLayer, string strBlockName, int nOut2A, int nOut2B, int nOut2C, int nStride, bool bUseBranch1, int nDilation=1, bool bNamedParams=false, string strLayerPostfix="", Phase phaseExclude=Phase.NONE) |
| Adds a ResNet body to the network, connecting it to the 'lastLayer'. More... | |
| void | addExclusion (LayerParameter p, Phase phase) |
| Add a phase exclusion. More... | |
| LayerParameter | addResNetBody (string strDataName, int nBlock3Count=4, int nBlock4Count=23, bool bUsePool5=true, bool bUseDilationConv5=false, bool bNamedParams=false, string strLayerPostfix="", Phase phaseExclude=Phase.NONE) |
| Create a ResNet101 Body. More... | |
Protected Attributes | |
| string | m_strBaseDir |
| Specifies the base directory that contains the data and models. More... | |
| NetParameter | m_net = new NetParameter() |
| Specifies the base net to be altered. More... | |
| SolverParameter | m_solver = new SolverParameter() |
| Specifies the base solver to use. More... | |
Properties | |
| NetParameter | Net [get] |
| Returns the base net altered by the model builder. More... | |
| SolverParameter | Solver [get] |
| Returns the base solver. More... | |
The ModelBuilder is an abstract class that is overridden by a base class used to programically build new models.
Definition at line 18 of file ModelBuilder.cs.
Defines the scale bias type to use.
| Enumerator | |
|---|---|
| NONE | Specifies to not use the scale or bias. |
| SCALE | Specifies to use the scale. |
| BIAS | Specifies to use the bias. |
Definition at line 36 of file ModelBuilder.cs.
| MyCaffe.model.ModelBuilder.ModelBuilder | ( | string | strBaseDir, |
| NetParameter | net = null, |
||
| SolverParameter | solver = null |
||
| ) |
The constructor.
| strBaseDir | Specifies the base directory that contains the data and models. |
| net | Optionally, specifies the 'base' net parameter that is to be altered (default = null). |
| solver | Optionally, specifies the 'base' solver parameter to use (default = null). |
Definition at line 58 of file ModelBuilder.cs.
|
protected |
Add the Annotated Data layer.
| strSource | Specifies the data source. |
| phase | Specifies the phase under which to run the layer (e.g. TRAIN, TEST, RUN). |
| nBatchSize | Optionally, specifies the batch size (default = 32). |
| bOutputLabel | Optionally, specifies whether or not to output the label (default = true). |
| strLabelMapFile | Optionally, specifies the label file (default = ""). |
| anno_type | Optionally, specifies the annotation type (default = NONE). |
| transform | Optionally, specifies the transformation parameter (default = null, ignored). |
| rgSampler | Optionally, specifies the list of batch samplers (default = null, ignored). |
Definition at line 192 of file ModelBuilder.cs.
|
protected |
Add convolution, batch-norm layers.
| strInputLayer | Specifies the input layer. |
| strOutputLayer | Specifies the output layer. |
| bUseBatchNorm | Optionally, specifies whether or not to use a batch-norm layer. |
| bUseRelU | Specifies whether or not to add a RelU layer. |
| nNumOutput | Specifies the number of output. |
| nKernelSize | Specifies the kernel size. |
| nPad | Specifies the pad. |
| nStride | Specifies the stride. |
| dfLrMult | Optionally, specifies the default learning rate multiplier (default = 1.0). |
| nDilation | Optionally, specifies the dilation (default = 1). |
| useScale | Optionally, specifies whether or not to use a ScaleLayer or BiasLayer (default = SCALE). |
| strConvPrefix | Optionally, specifies the convolution layer name prefix (default = ""). |
| strConvPostfix | Optionally, specifies the convolution layer name postfix (default = ""). |
| strBnPrefix | Optionally, specifies the batch-norm layer name prefix (default = ""). |
| strBnPostfix | Optionally, specifies the batch-norm layer name postfix (default = "_bn"). |
| strScalePrefix | Optionally, specifies the scale layer name prefix (default = ""). |
| strScalePostFix | Optionally, specifies the scale layer name postfix (default = "_scale") |
| strBiasPrefix | Optionally, specifies the bias layer name prefix (default = ""). |
| strBiasPostfix | Optionally, specifies the bias layer name postfix (default = "_bias"). |
| bNamedParams | Optionally, specifies to name the parameters (default = false). |
| strLayerPostfix | Optionally, specifies a layer name postfix (default = ""). |
| phaseExclude | Optionally, specifies a phase to exclude (default = NONE). |
Definition at line 491 of file ModelBuilder.cs.
|
protected |
Add the Data layer.
| strSource | Specifies the data source. |
| phase | Specifies the phase under which to run the layer (e.g. TRAIN, TEST, RUN). |
| nBatchSize | Optionally, specifies the batch size (default = 32). |
| bOutputLabel | Optionally, specifies whether or not to output the label (default = true). |
| transform | Optionally, specifies the transformation parameter (default = null, ignored). |
| strName | Optionally, specifies a name for the layer and data top name (default = "data"). |
| bSiamese | Optionally, specifies to add data layers for a Siamese net (default = false). |
Definition at line 149 of file ModelBuilder.cs.
|
protected |
Add a phase exclusion.
| p | Specifies the layer parameter to alter. |
| phase | Specifies the phase to exclude, or NONE to ignore. |
Definition at line 1025 of file ModelBuilder.cs.
|
protectedpure virtual |
Add extra layers on top of a 'base' network (e.g. VGGNet or Inception)
| bUseBatchNorm | Optionally, specifies whether or not to use batch normalization layers (default = true). |
| dfLrMult | Optionally, specifies the learning rate multiplier (default = 1.0). |
Implemented in MyCaffe.model.ResNetModelBuilder, MyCaffe.model.ResNetOctConvModelBuilder, and MyCaffe.model.SsdPascalModelBuilder.
|
protected |
Adds a ResNet body to the network, connecting it to the 'lastLayer'.
| lastLayer | Specifies the layer to connect the ResNet net to. |
| strBlockName | Specifies the block name. |
| nOut2A | Specifies the output of the first branch. |
| nOut2B | Specifies the output of the second branch. |
| nOut2C | Specifies the output of the third branch. |
| nStride | Specifies the stride used in the first branch. |
| bUseBranch1 | Specifies whether or not to use the first branch. |
| nDilation | Specifies the dilation used in all branches. |
| bNamedParams | Optionally, specifies to name the parameters (default = false). |
| strLayerPostfix | Optionally, specifies a layer name postfix (default = ""). |
| phaseExclude | Optionally, specifies a phase to exclude (default = NONE). |
Definition at line 959 of file ModelBuilder.cs.
|
protected |
Create a ResNet101 Body.
| strDataName | Specifies the last layer name where the ResNet body is to be created from. |
| nBlock3Count | Specifies the number of blocks in the 3 blocks (default = 4 for ResNet101, use 8 for ResNet152). |
| nBlock4Count | Speciifes the number of blocks in the 4 blocks (default = 23 for ResNet101, use 36 for ResNet152). |
| bUsePool5 | Specifies whether or not a Pooling layer is to be used as the last layer. |
| bUseDilationConv5 | Specifies whether or not to use dilation on the level 5 block. |
| bNamedParams | Specifies whether or not to name the parameters (default = false). |
| strLayerPostfix | Specifies a layer name post-fix (default = ""). |
| phaseExclude | Specifies a phase to exclude, or NONE to ignore (default = NONE). |
Definition at line 1048 of file ModelBuilder.cs.
|
protected |
Add a new VGG block.
| lastLayer | Specifies the last layer that this block is to be connected to. |
| nBlockIdx | Specifies the block index. |
| nConvIdx | Specifies the convolution index. |
| nNumOutput | Specifies the number of outputs. |
| nConvCount | Specifies the number of convolution layers to add. |
| bNoPool | When adding the last layer, specifies whether or not to add a pooling (false) or convolution (true) layer. When this parameter is null, the adding of the last layer is skipped. |
| bDilatePool | Optionally, specifies whether or not to dilate the last pooling layer (default = false). |
| nKernelSize | Optionally, specifies the kernel size (default = 3). |
| nPad | Optionally, specifies the pad (default = 1). |
| nStride | Optionally, specifies the stride (default = 1). |
| nDilation | Optionally, specifies the dilation (default = 1). |
Definition at line 728 of file ModelBuilder.cs.
|
protected |
Adds the final layers to the network.
| lastLayer | Specifies the previous layer to connect the last layers to. |
| nBlockIdx | Specifies the block index. |
| nConvIdx | Specifies the convolution index. |
| nNumOutput | Specifies the number of outputs for the convolution layers. |
| nDilation | Specifies the dilation to use for the last fully connected convolution layers (used when bFullConv = true). |
| bDilated | Specifies whether or not dialation is used. |
| bNoPool | Specifies whether or not pooling is used. |
| bFullConv | Specifies whether or not full convolution layers are used instead of inner product layers. |
| bReduced | Specifies whether or not the final layers are used to reduce the data. |
| bDropout | Specifies whether or not dropout layers are connected. |
Definition at line 777 of file ModelBuilder.cs.
|
protected |
Adds the full VGG body to the network, connecting it to the 'lastLayer'.
| lastLayer | Specifies the layer to connect the VGG net to. |
| bNeedFc | Optionally, specifies whether or not to add the fully connected end layers (default = true). |
| bFullConv | Optionally, specifies whether or not full convolution layers are used instead of inner product layers (default = true). |
| bReduced | Optionally, specifies whether or not the final layers are used to reduce the data (default = true). |
| bDilated | Optionally, specifies whether or not dialation is used (default = true). |
| bNoPool | Optionally, specifies whether or not pooling is used (default = false, use pooling). |
| bDropout | Optionally, specifies whether or not dropout layers are connected (default = false). |
| rgstrFreezeLayers | Optionally, specifies a set of layers who's training is to be frozen (default = null to ignore). |
| bDilatePool4 | Optionally, specifies whether or not to dilate pool #4 (default = false). |
Definition at line 915 of file ModelBuilder.cs.
|
protected |
Connect the from layer to the 'to' layer.
| fromLayer | Specifies the layer who's bottom is connected to the toLayer's top. |
| toLayer | Specifies the layer who's top is connected to the from layer's bottom. |
| bInPlace | Optionally, specifies whether or not to connect both the top and bottom of the toLayer to the top of the from layer. |
| bAdd | Optionally, specifies whether or not to add the layer to the network (default = true). |
| nTopIdx | Optionally, specifies the top index of the item to connect. |
Definition at line 624 of file ModelBuilder.cs.
|
protected |
Connect the from layer to the 'to' layer.
| rgFromLayer | Specifies a list of layers who's bottoms are connected to the toLayer's top. |
| toLayer | Specifies the layer who's top is connected to the from layer's bottom. |
| bAdd | Optionally, specifies whether or not to add the layer to the network (default = true). |
Definition at line 648 of file ModelBuilder.cs.
|
protected |
Connect the from layer to the 'to' layer.
| fromLayer | Specifies the layer bottom to connect to the toLayer's top. |
| toLayer | Specifies the layer who's top is connected to the from layer's bottom. |
| fromLayer2 | Optionally, specifies a second input layer. |
Definition at line 602 of file ModelBuilder.cs.
|
protected |
Create a new convolution layer parameter.
| strName | Specifies the layer name. |
| nNumOutput | Specifies the number of output. |
| nKernelSize | Specifies the kernel size. |
| nPad | Optionally, specifies the pad (default = 0). |
| nStride | Optionally, specifies the stride (default = 1). |
| nDilation | Optionally, specifies the dilation (default = 1). |
Definition at line 673 of file ModelBuilder.cs.
|
pure virtual |
Create the deploy model to use.
Implemented in MyCaffe.model.ResNetModelBuilder, MyCaffe.model.ResNetOctConvModelBuilder, and MyCaffe.model.SsdPascalModelBuilder.
|
pure virtual |
Create the training/testing/deploy model to use.
Implemented in MyCaffe.model.ResNetModelBuilder, MyCaffe.model.ResNetOctConvModelBuilder, and MyCaffe.model.SsdPascalModelBuilder.
|
protected |
Create the multi-box head layers.
| data | Specifies the data layer. |
| nNumClasses | Specifies the number of classes. |
| rgInfo | Specifies the info associated with the layers to connect to. |
| rgPriorVariance | Specifies the prior variance. |
| bUseObjectness | Optionally, specifies whether or not to use objectness (default = false). |
| bUseBatchNorm | Optionally, specifies whether or not to use batch-norm layers (default = true). |
| dfLrMult | Optionally, specifies the learning multiplier (default = 1.0). |
| useScale | Optionally, specifies whether or not to use scale layers (default = true). |
| nImageHt | Optionally, specifies the image height (default = 0, ignore). |
| nImageWd | Optionally, specifies the image width (default = 0, ignore). |
| bShareLocation | Optionally, specifies whether or not to share the location (default = true). |
| bFlip | Optionally, specifies whether or not to flip (default = true). |
| bClip | Optionally, specifies whether or not to clip (default = true). |
| dfOffset | Optionally, specifies the offset (default = 0.5). |
| nKernelSize | Optionally, specifies the kernel size (default = 1). |
| nPad | Optionally, specifies the pad (default = 0). |
| strConfPostfix | Optionally, specifies the confidence postfix (default = ""). |
| strLocPostfix | Optionally, specifies the location postifix (default = ""). |
Definition at line 244 of file ModelBuilder.cs.
|
protected |
Create the base network parameter for the model and set its name to the 'm_strModel' name.
| strName | Specifies the model name. |
Definition at line 129 of file ModelBuilder.cs.
|
protected |
Create a new pooling layer parameter.
| strName | Specifies the layer name. |
| method | Specifies the pooling method. |
| nKernelSize | Specifies the kernel size. |
| nPad | Optionally, specifies the pad (default = 0). |
| nStride | Optionally, specifies the stride (default = 1). |
Definition at line 700 of file ModelBuilder.cs.
|
pure virtual |
Create the base solver to use.
Implemented in MyCaffe.model.ResNetModelBuilder, MyCaffe.model.ResNetOctConvModelBuilder, and MyCaffe.model.SsdPascalModelBuilder.
|
protected |
Find a layer with a given name.
| strName | Specifies the name of the layer to find. |
Definition at line 113 of file ModelBuilder.cs.
|
protected |
Returns the full path of the filename using the base directory original set when creating the ModelBuilder.
| strFile | Specifies the partial path of the file. |
| strSubDir | Specifies the sub-directory off the path (or null for none). |
Definition at line 89 of file ModelBuilder.cs.
|
protected |
Specifies the base net to be altered.
Definition at line 27 of file ModelBuilder.cs.
|
protected |
Specifies the base solver to use.
Definition at line 31 of file ModelBuilder.cs.
|
protected |
Specifies the base directory that contains the data and models.
Definition at line 23 of file ModelBuilder.cs.
|
get |
Returns the base net altered by the model builder.
Definition at line 1105 of file ModelBuilder.cs.
|
get |
Returns the base solver.
Definition at line 1113 of file ModelBuilder.cs.