MyCaffe
1.12.2.41
Deep learning software for Windows C# programmers.
|
Connects Layer's together into a direct acrylic graph (DAG) specified by a NetParameter More...
Public Member Functions | |
Net (CudaDnn< T > cuda, Log log, NetParameter p, CancelEvent evtCancel, IXDatabaseBase db, Phase phaseOverride=Phase.NONE, AutoResetEvent evtTrainingCompleted=null, Net< T > sharedNet=null, onGetWorkspace getws=null, onSetWorkspace setws=null) | |
The Net constructor. More... | |
void | Dispose () |
Releases all resources (GPU and Host) used by the Net. More... | |
void | Init (NetParameter p, Phase phaseOverride=Phase.NONE, AutoResetEvent evtTrainingCompleted=null) |
Initialize a network with a NetParameter. More... | |
Phase | SetPhase (Phase phase) |
Change the phase of the network. More... | |
void | RestorePhase () |
Restore the network phase to its original state. More... | |
void | SetEnablePassthrough (bool bEnable) |
Enables/disables passthrough on each layer of the net. More... | |
NetParameter | FilterNet (NetParameter param) |
Removes layers that the user specified should be excluded given the current phase, level and stage. More... | |
bool | StateMeetsRule (NetState state, NetStateRule rule, string strLayer) |
Returns whether NetState state meets NetStateRule rule. More... | |
double | ForwardFromTo (int nStart=0, int nEnd=int.MaxValue) |
The FromTo variant of forward and backward operate on the (topological) ordering by which the net is specified. For general DAG netowrks, note that (1) computing from one layer to another might entail extra computation on unrelated branches, and (2) computation starting in the middle may be incorrect if all the layers of a fan-in are not included. More... | |
BlobCollection< T > | Forward () |
Run forward with the input Blob's already fed separately. More... | |
BlobCollection< T > | Forward (out double dfLoss) |
Run forward with the input Blob's already fed separately. More... | |
BlobCollection< T > | Forward (BlobCollection< T > colBottom, out double dfLoss, bool bReshape=false) |
Run forward using a set of bottom blobs and return the result. More... | |
void | Backward (int nStart=int.MaxValue, int nEnd=0) |
The network backward should take no input and output, since it solely computes the gradient w.r.t. the parameters, and the data has already been provided during the forward pass. More... | |
void | ShareTrainedLayersWith (Net< T > srcNet, bool bEnableLog=false) |
For an already initialized net, implicitly compies (i.e., using no additional memory) the pre-trained layers from another Net. More... | |
void | CopyInternalBlobsTo (Net< T > dstNet) |
Copy the internal blobs from one net to another. More... | |
void | CopyTrainedLayersTo (Net< T > dstNet) |
Copies the trained layer of this Net to another Net. More... | |
void | CopyTrainedLayersTo (Net< T > dstNet, DictionaryEx< string, string > rgLayerNames, bool bTranspose) |
Copies the trained layers of this Net to another Net. More... | |
void | Reshape () |
Reshape all layers from the bottom to the top. More... | |
void | CopyTrainedLayersFrom (NetParameter param) |
For an already initialized net, CopyTrainedLayersFrom copies the already trained layers from another net parameter instance. More... | |
NetParameter | ToProto (bool bIncludeBlobs) |
Writes the net to a proto. More... | |
void | Update () |
Updates the network weights based on the diff values computed. More... | |
void | ClearParamDiffs () |
Zero out the diffs of all netw parameters. This should be run before Backward. More... | |
void | ShareWeights () |
Shares weight data of owner blobs with shared blobs. More... | |
bool | ForwardBackward (BlobCollection< T > colBottom, out double dfLocalLoss, TRAIN_STEP step=TRAIN_STEP.NONE) |
Runs a Forward pass followed by a Backward pass. More... | |
List< int > | top_ids (int layer_id) |
Returns the ids of the top blobs of layer i. More... | |
List< int > | bottom_ids (int layer_id) |
Returns the ids of the bottom blobs of layer i. More... | |
BlobCollection< T > | layer_blobs (string strLayerName) |
Returns the collection of Blobs internal to a Layer. More... | |
void | SetLearnedParameters (BlobCollection< T > col) |
Sets the learned parameters. More... | |
Blob< T > | param_by_name (string strName, bool bThrowExceptionOnError=true) |
Returns a parameter given its name. More... | |
bool | has_blob (string strBlobName) |
Returns whether or not the Net contains a given Blob. More... | |
Blob< T > | blob_by_name (string strName, bool bThrowExceptionOnError=true) |
Returns a blob given its name. More... | |
int | blob_index_by_name (string strName) |
Returns the index of a blob given its name. More... | |
bool | has_layer (string strLayer) |
Returns whether or not the Net has a given Layer by its name. More... | |
Layer< T > | layer_by_name (string strLayer, bool bThrowExceptionOnError=true) |
Returns a Layer given its name. More... | |
int | layer_index_by_name (string strLayer) |
Returns a Layer's index given its name. More... | |
void | set_debug_info (bool bVal) |
Sets the debug information flag. More... | |
NetParameter | InsertSplits (NetParameter param) |
Create a new NetParameter and insert splits into it based on a given NetParameter. More... | |
void | LoadWeights (byte[] rgWeights, IXPersist< T > persist, List< string > inputWtInfo=null, List< string > targetWtInfo=null, string strSkipBlobType=null) |
Loads new weights into the Net. More... | |
byte[] | SaveWeights (IXPersist< T > persist, bool bSaveDiff=false) |
Save the weights to a byte array. More... | |
Layer< T > | FindLayerOwningBlob (Blob< T > b) |
Finds the Layer that owns a given Blob. More... | |
int | FindLayerIndexOwningBlob (Blob< T > b) |
Finds the index of the Layer that owns a given Blob. More... | |
Blob< T > | FindBlob (string strName) |
Finds a Blob in the Net by name. More... | |
BlobCollection< T > | FindBottomBlobsOfLayer (string strLayer) |
Returns the collection of bottom blobs for a given layer. More... | |
BlobCollection< T > | FindTopBlobsOfLayer (string strLayer) |
Returns the collection of top blobs for a given layer. More... | |
Blob< T > | FindLossBottomBlob () |
Find the bottom blob of the Loss layer if it exists, otherwise null is returned. More... | |
DebugInformation< T > | GetDebugInformation (bool bDetectNans) |
Returns the DebugInformation for the Net. More... | |
string | GetDataSource () |
Returns the data source used by the network. More... | |
bool | ReInitializeParameters (WEIGHT_TARGET target, params string[] rgstrLayers) |
Re-initializes the blobs and each of the specified layers by re-running the filler (if any) specified by the layer. When the 'rgstr' parameter is null or otherwise empty, the blobs of all layers are re-initialized. More... | |
Layer< T > | FindLayer (LayerParameter.LayerType? type, string strName) |
Find the layer with the matching type, name and or both. More... | |
List< Layer< T > > | FindLayers (LayerParameter.LayerType type) |
Find the layers with the matching type. More... | |
Layer< T > | FindLayer (string strType, string strName) |
Find the layer with the matching type, name and or both. More... | |
Layer< T > | FindLastLayer (LayerParameter.LayerType type) |
Find the last layer with the matching type. More... | |
Protected Member Functions | |
virtual void | Dispose (bool bDisposing) |
Releases all resources (GPU and Host) used by the Net. More... | |
void | AppendTop (NetParameter param, int layer_id, int top_id, List< string > available_blobs, DictionaryEx< string, int > blob_name_to_idx) |
Append a new input or top blob to the net. More... | |
int | AppendBottom (NetParameter param, int layer_id, int bottom_id, List< string > available_blobs, DictionaryEx< string, int > blob_name_to_idx) |
Append a new bottom blob to the net. More... | |
void | AppendParam (NetParameter param, int layer_id, int param_id) |
Append a new parameter blob to the net. More... | |
void | InputDebugInfo (int input_id) |
Helper for displaying debug info in Forward about input blobs. More... | |
void | ForwardDebugInfo (int layer_id) |
Helper for displaying debug info in Forward. More... | |
void | BackwardDebugInfo (int layer_id) |
Helper for displaying debug info in Backward. More... | |
void | UpdateDebugInfo (int param_id) |
Helper for displaying debug info in Update. More... | |
Properties | |
bool | EnableBreakOnFirstNaN [getset] |
Enable/disable break the first NaN functionality where training stops immediately upon detecting a NaN in one of the Layer blobs. More... | |
bool | EnableDetailedNanDetection [getset] |
Enable/disable whether or not detailed nans are detected - this will make debugging slower and is only recommended when running on a TCC enabled driver (as opposed to an WDM driver one used with the monitor). More... | |
bool | EnableLayerDebugging [getset] |
Enable/disable layer debugging which causes each layer to check for NAN/INF on each forward/backward pass and throw an exception when found. More... | |
string | ActiveLabelCounts [get] |
Returns the active label counts observed during training. More... | |
string | LabelQueryHitPercents [get] |
Return the label query hit percentages for the active datasource. More... | |
string | LabelQueryEpochs [get] |
Return the label query epochs for the active datasource. More... | |
string | BoostQueryHitPercents [get] |
Return the boost query hit percentages for the active datasource. More... | |
NetParameter | net_param [get] |
Returns the net parameter. More... | |
string | name [get] |
Returns the network name. More... | |
List< string > | layer_names [get] |
Returns the layer names. More... | |
List< string > | blob_names [get] |
Returns the blob names. More... | |
BlobCollection< T > | blobs [get] |
Returns the blobs. More... | |
List< Layer< T > > | layers [get] |
Returns the layers. More... | |
Phase | phase [get] |
Returns the network phase: TRAIN or TEST More... | |
List< BlobCollection< T > > | bottom_vecs [get] |
Returns the bottom vecs for each layer – usually you won't need this unless you do per-layer checks such as gradients. More... | |
List< BlobCollection< T > > | top_vecs [get] |
Returns the top vecs for each layer – usually y ou won't need this unless you do per-layer checks such as gradients. More... | |
List< List< bool > > | bottom_need_backward [get] |
Returns the collection of lists that tell whether or not the bottom of each layer needs a backward pass or not. More... | |
List< double > | blob_loss_weights [get] |
Returns the collection of blob loss weights. More... | |
List< bool > | layer_need_backward [get] |
Returns a collection of items that tell whether each layer nees a backward pass or not. More... | |
BlobCollection< T > | parameters [get] |
Returns the parameters. More... | |
BlobCollection< T > | learnable_parameters [get] |
Returns the learnable parameters. More... | |
List< double?> | params_lr [get] |
Returns the learnable parameter learning rate multipliers. More... | |
List< double?> | params_weight_decay [get] |
Returns the learnable parameter decay multipliers. More... | |
DictionaryEx< string, int > | param_names_index [get] |
Returns the dictionary look for parameter names to their indexes. More... | |
List< int > | param_owners [get] |
Returns the list of parameter owner indexes. More... | |
List< string > | param_display_names [get] |
Returns the list of parameter display names. More... | |
int | num_inputs [get] |
Returns the number of inputs. More... | |
int | num_outputs [get] |
Returns the number of outputs. More... | |
BlobCollection< T > | input_blobs [get] |
Returns the collection of input Blobs. More... | |
BlobCollection< T > | output_blobs [get] |
Returns the collection of output Blobs. More... | |
List< int > | output_blob_indices [get] |
Returns a list of the output Blob indexes. More... | |
List< int > | input_blob_indices [get] |
Returns a list of the input Blob indexes. More... | |
CudaDnn< T > | Cuda [get] |
Returns the instance of CudaDnn used by this network. More... | |
Events | |
EventHandler< WorkspaceArgs > | OnGetWorkspace |
Specifies the OnGetWorkspace event that fires when the getWorkspace() function is called by a layer to get a shareable workspace to conserve GPU memory. More... | |
EventHandler< WorkspaceArgs > | OnSetWorkspace |
Specifies the OnSetWorkspace event that fires when the setWorkspace() function is called by a layer to get a shareable workspace to conserve GPU memory. More... | |
EventHandler< GetIterationArgs > | OnGetIteration |
Specifies the OnGetIteration event that fires when a layer needs to get the current iteration from the solver. More... | |
Connects Layer's together into a direct acrylic graph (DAG) specified by a NetParameter
T | Specifies the base type float or double. Using float is recommended to conserve GPU memory. |
MyCaffe.common.Net< T >.Net | ( | CudaDnn< T > | cuda, |
Log | log, | ||
NetParameter | p, | ||
CancelEvent | evtCancel, | ||
IXDatabaseBase | db, | ||
Phase | phaseOverride = Phase.NONE , |
||
AutoResetEvent | evtTrainingCompleted = null , |
||
Net< T > | sharedNet = null , |
||
onGetWorkspace | getws = null , |
||
onSetWorkspace | setws = null |
||
) |
The Net constructor.
cuda | Specifies the CudaDnn connection to Cuda. |
log | Specifies the Log for output. |
p | Specifies the NetParameter used to initialize the Net. |
evtCancel | Specifies the CancelEvent used to cancel operations run by the Net. |
db | Specifies the in-memory MyCaffeDatabase. |
phaseOverride | Optionally, specifies an override of the Phase for which the Net is used. |
evtTrainingCompleted | Optionally, specifies an auto reset event that is set after training has completed. |
sharedNet | Specifies another Net that shares the GPU memory created by this Net. |
getws | Optionally, specifies the handler for getting the workspace. |
setws | Optionally, specifies the handler for setting the workspace. |
|
protected |
Append a new bottom blob to the net.
|
protected |
|
protected |
Append a new input or top blob to the net.
void MyCaffe.common.Net< T >.Backward | ( | int | nStart = int.MaxValue , |
int | nEnd = 0 |
||
) |
The network backward should take no input and output, since it solely computes the gradient w.r.t. the parameters, and the data has already been provided during the forward pass.
nStart | Specifies the Layer index where the Backward operation is to start. |
nEnd | Specifies the Layer index of the last Layer that the Backward operation is run. |
|
protected |
Blob< T > MyCaffe.common.Net< T >.blob_by_name | ( | string | strName, |
bool | bThrowExceptionOnError = true |
||
) |
int MyCaffe.common.Net< T >.blob_index_by_name | ( | string | strName | ) |
List< int > MyCaffe.common.Net< T >.bottom_ids | ( | int | layer_id | ) |
void MyCaffe.common.Net< T >.ClearParamDiffs | ( | ) |
void MyCaffe.common.Net< T >.CopyInternalBlobsTo | ( | Net< T > | dstNet | ) |
void MyCaffe.common.Net< T >.CopyTrainedLayersFrom | ( | NetParameter | param | ) |
void MyCaffe.common.Net< T >.CopyTrainedLayersTo | ( | Net< T > | dstNet | ) |
void MyCaffe.common.Net< T >.CopyTrainedLayersTo | ( | Net< T > | dstNet, |
DictionaryEx< string, string > | rgLayerNames, | ||
bool | bTranspose | ||
) |
Copies the trained layers of this Net to another Net.
dstNet | Specifies the destination Net where the trained layers are to be copied. |
rgLayerNames | Specifies the layer name dictionary lookup, where only the weights of layer names within the Dictionary lookup are copied. |
bTranspose | Specifies whether or not to copy the weights and transpose the copy. |
void MyCaffe.common.Net< T >.Dispose | ( | ) |
|
protectedvirtual |
NetParameter MyCaffe.common.Net< T >.FilterNet | ( | NetParameter | param | ) |
Blob< T > MyCaffe.common.Net< T >.FindBlob | ( | string | strName | ) |
BlobCollection< T > MyCaffe.common.Net< T >.FindBottomBlobsOfLayer | ( | string | strLayer | ) |
Layer< T > MyCaffe.common.Net< T >.FindLastLayer | ( | LayerParameter.LayerType | type | ) |
Layer< T > MyCaffe.common.Net< T >.FindLayer | ( | LayerParameter.LayerType? | type, |
string | strName | ||
) |
Layer< T > MyCaffe.common.Net< T >.FindLayer | ( | string | strType, |
string | strName | ||
) |
int MyCaffe.common.Net< T >.FindLayerIndexOwningBlob | ( | Blob< T > | b | ) |
Layer< T > MyCaffe.common.Net< T >.FindLayerOwningBlob | ( | Blob< T > | b | ) |
List< Layer< T > > MyCaffe.common.Net< T >.FindLayers | ( | LayerParameter.LayerType | type | ) |
Blob< T > MyCaffe.common.Net< T >.FindLossBottomBlob | ( | ) |
BlobCollection< T > MyCaffe.common.Net< T >.FindTopBlobsOfLayer | ( | string | strLayer | ) |
BlobCollection< T > MyCaffe.common.Net< T >.Forward | ( | ) |
Run forward with the input Blob's already fed separately.
You can get the input blobs using input_blobs().
BlobCollection< T > MyCaffe.common.Net< T >.Forward | ( | BlobCollection< T > | colBottom, |
out double | dfLoss, | ||
bool | bReshape = false |
||
) |
BlobCollection< T > MyCaffe.common.Net< T >.Forward | ( | out double | dfLoss | ) |
Run forward with the input Blob's already fed separately.
You can get the input blobs using input_blobs().
dfLoss | Returns the loss of the operation. |
bool MyCaffe.common.Net< T >.ForwardBackward | ( | BlobCollection< T > | colBottom, |
out double | dfLocalLoss, | ||
TRAIN_STEP | step = TRAIN_STEP.NONE |
||
) |
Runs a Forward pass followed by a Backward pass.
colBottom | Optionally, specifies input data passed to the Forward pass. |
dfLocalLoss | Returns the local loss of the Forward pass. |
step | Optionally, specifies to step forward or backward. |
|
protected |
double MyCaffe.common.Net< T >.ForwardFromTo | ( | int | nStart = 0 , |
int | nEnd = int.MaxValue |
||
) |
The FromTo variant of forward and backward operate on the (topological) ordering by which the net is specified. For general DAG netowrks, note that (1) computing from one layer to another might entail extra computation on unrelated branches, and (2) computation starting in the middle may be incorrect if all the layers of a fan-in are not included.
nStart | Optionally, specifies the index of the first Layer where the Forward operation is to start. |
nEnd | Optionally, specifies the index of the last Layer to run the Forward operation on. |
string MyCaffe.common.Net< T >.GetDataSource | ( | ) |
DebugInformation< T > MyCaffe.common.Net< T >.GetDebugInformation | ( | bool | bDetectNans | ) |
Returns the DebugInformation for the Net.
bDetectNans | Specifies whether or not to detect Nan's in the data. |
bool MyCaffe.common.Net< T >.has_blob | ( | string | strBlobName | ) |
bool MyCaffe.common.Net< T >.has_layer | ( | string | strLayer | ) |
void MyCaffe.common.Net< T >.Init | ( | NetParameter | p, |
Phase | phaseOverride = Phase.NONE , |
||
AutoResetEvent | evtTrainingCompleted = null |
||
) |
Initialize a network with a NetParameter.
p | Specifies the NetParameter. |
phaseOverride | Optionally, specifies a Phase override for which the Net will run under. |
evtTrainingCompleted | Optionally, specifies an auto reset event that is set upon the completion of training. |
|
protected |
Helper for displaying debug info in Forward about input blobs.
input_id | Specifies the index of the input Blob within input_blobs(). |
NetParameter MyCaffe.common.Net< T >.InsertSplits | ( | NetParameter | param | ) |
Create a new NetParameter and insert splits into it based on a given NetParameter.
Splits are used when a given input (top) is used by more than one Layer. For example a DataLayer 'label' top may used by both an AccuracyLayer and SoftmaxLossLayer. In such a case a split is created that allows the 'label' top to be sent to both.
param | Specifies the original NetParameter. |
BlobCollection< T > MyCaffe.common.Net< T >.layer_blobs | ( | string | strLayerName | ) |
Layer< T > MyCaffe.common.Net< T >.layer_by_name | ( | string | strLayer, |
bool | bThrowExceptionOnError = true |
||
) |
Returns a Layer given its name.
strLayer | Specifies the Layer name. |
bThrowExceptionOnError | Optionally, specifies to throw an exception when the layer is not found. The default = true. |
int MyCaffe.common.Net< T >.layer_index_by_name | ( | string | strLayer | ) |
void MyCaffe.common.Net< T >.LoadWeights | ( | byte[] | rgWeights, |
IXPersist< T > | persist, | ||
List< string > | inputWtInfo = null , |
||
List< string > | targetWtInfo = null , |
||
string | strSkipBlobType = null |
||
) |
Loads new weights into the Net.
rgWeights | Specifies the weights themselves. |
persist | Specifies an interface to the persistance object used to load the weights. |
inputWtInfo | Optionally, specifies the input blobs to import. Note, when set, the targetWtInfo must also be specified. When null, this parameter is ignored. |
targetWtInfo | Optionally, specifies the target blobs to import into. Note, when set, the inputWtInfo must also be specified. When null, this parameter is ignored. |
strSkipBlobType | Optionally, specifies a blob type where weights are NOT loaded. See Blob.BLOB_TYPE for the types of Blobs. |
Blob< T > MyCaffe.common.Net< T >.param_by_name | ( | string | strName, |
bool | bThrowExceptionOnError = true |
||
) |
Returns a parameter given its name.
strName | Specifies the Parameter's name. |
bThrowExceptionOnError | Optionally, specifies to throw an exception when the layer is not found. The default = true. |
bool MyCaffe.common.Net< T >.ReInitializeParameters | ( | WEIGHT_TARGET | target, |
params string[] | rgstrLayers | ||
) |
Re-initializes the blobs and each of the specified layers by re-running the filler (if any) specified by the layer.
When the 'rgstr' parameter is null or otherwise empty, the blobs of all layers are re-initialized.
target | Specifies the weights to target (e.g. weights, bias or both). |
rgstrLayers | Specifies the layers to reinitialize, when null or empty, all layers are re-initialized |
void MyCaffe.common.Net< T >.Reshape | ( | ) |
void MyCaffe.common.Net< T >.RestorePhase | ( | ) |
byte[] MyCaffe.common.Net< T >.SaveWeights | ( | IXPersist< T > | persist, |
bool | bSaveDiff = false |
||
) |
void MyCaffe.common.Net< T >.set_debug_info | ( | bool | bVal | ) |
void MyCaffe.common.Net< T >.SetEnablePassthrough | ( | bool | bEnable | ) |
Enables/disables passthrough on each layer of the net.
If enabled by a given layer, the Bottom inputs are copied directly to the Top outputs during the forward pass and the forward pass returns. This is used by the BatchDataLayer.
bEnable | Specifies whether or not to enable passthrough. |
void MyCaffe.common.Net< T >.SetLearnedParameters | ( | BlobCollection< T > | col | ) |
Phase MyCaffe.common.Net< T >.SetPhase | ( | Phase | phase | ) |
void MyCaffe.common.Net< T >.ShareTrainedLayersWith | ( | Net< T > | srcNet, |
bool | bEnableLog = false |
||
) |
void MyCaffe.common.Net< T >.ShareWeights | ( | ) |
bool MyCaffe.common.Net< T >.StateMeetsRule | ( | NetState | state, |
NetStateRule | rule, | ||
string | strLayer | ||
) |
Returns whether NetState state meets NetStateRule rule.
state | Specifies the NetState to test. |
rule | Specifies the NetStateRul to test against the NetState. |
strLayer | Specifies the name of the Layer for which the test is taking place. |
List< int > MyCaffe.common.Net< T >.top_ids | ( | int | layer_id | ) |
NetParameter MyCaffe.common.Net< T >.ToProto | ( | bool | bIncludeBlobs | ) |
void MyCaffe.common.Net< T >.Update | ( | ) |
|
protected |
|
get |
|
get |
|
get |
|
get |
|
get |
|
get |
|
get |
|
get |
|
getset |
|
getset |
|
getset |
|
get |
|
get |
|
get |
|
get |
|
get |
|
get |
|
get |
|
get |
|
get |
|
get |
|
get |
|
get |
|
get |
|
get |
|
get |
|
get |
|
get |
|
get |
|
get |
|
get |
|
get |
|
get |
EventHandler<GetIterationArgs> MyCaffe.common.Net< T >.OnGetIteration |
EventHandler<WorkspaceArgs> MyCaffe.common.Net< T >.OnGetWorkspace |
EventHandler<WorkspaceArgs> MyCaffe.common.Net< T >.OnSetWorkspace |