MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
MyCaffe.common.Net< T > Class Template Reference

Connects Layer's together into a direct acrylic graph (DAG) specified by a NetParameter More...

Inheritance diagram for MyCaffe.common.Net< T >:

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< WorkspaceArgsOnGetWorkspace
 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< WorkspaceArgsOnSetWorkspace
 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< GetIterationArgsOnGetIteration
 Specifies the OnGetIteration event that fires when a layer needs to get the current iteration from the solver. More...
 

Detailed Description

Connects Layer's together into a direct acrylic graph (DAG) specified by a NetParameter

Template Parameters
TSpecifies the base type float or double. Using float is recommended to conserve GPU memory.

Definition at line 22 of file Net.cs.

Constructor & Destructor Documentation

◆ Net()

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.

Parameters
cudaSpecifies the CudaDnn connection to Cuda.
logSpecifies the Log for output.
pSpecifies the NetParameter used to initialize the Net.
evtCancelSpecifies the CancelEvent used to cancel operations run by the Net.
dbSpecifies the in-memory MyCaffeDatabase.
phaseOverrideOptionally, specifies an override of the Phase for which the Net is used.
evtTrainingCompletedOptionally, specifies an auto reset event that is set after training has completed.
sharedNetSpecifies another Net that shares the GPU memory created by this Net.
getwsOptionally, specifies the handler for getting the workspace.
setwsOptionally, specifies the handler for setting the workspace.

Definition at line 161 of file Net.cs.

Member Function Documentation

◆ AppendBottom()

int MyCaffe.common.Net< T >.AppendBottom ( NetParameter  param,
int  layer_id,
int  bottom_id,
List< string >  available_blobs,
DictionaryEx< string, int >  blob_name_to_idx 
)
protected

Append a new bottom blob to the net.

Parameters
paramSpecifies the NetParameter used.
layer_idSpecifies the Layer index associated with the Blob.
bottom_idSpecifies the Blob index of the (bottom) Blob.
available_blobsSpecifies the list of available Blob names.
blob_name_to_idxSpecifies the Blob name to index dictionary lookup.

Definition at line 1272 of file Net.cs.

◆ AppendParam()

void MyCaffe.common.Net< T >.AppendParam ( NetParameter  param,
int  layer_id,
int  param_id 
)
protected

Append a new parameter blob to the net.

Parameters
paramSpecifies the NetParameter used.
layer_idSpecifies the Layer index associated with the Blob.
param_idSpecifies the Blob index of the (parameter) Blob.

Definition at line 1303 of file Net.cs.

◆ AppendTop()

void MyCaffe.common.Net< T >.AppendTop ( NetParameter  param,
int  layer_id,
int  top_id,
List< string >  available_blobs,
DictionaryEx< string, int >  blob_name_to_idx 
)
protected

Append a new input or top blob to the net.

Parameters
paramSpecifies the NetParameter used.
layer_idSpecifies the Layer index associated with the Blob.
top_idSpecifies the Blob index of the (top) Blob.
available_blobsSpecifies the list of available Blob names.
blob_name_to_idxSpecifies the Blob name to index dictionary lookup.

Definition at line 1154 of file Net.cs.

◆ Backward()

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.

Parameters
nStartSpecifies the Layer index where the Backward operation is to start.
nEndSpecifies the Layer index of the last Layer that the Backward operation is run.

Definition at line 1499 of file Net.cs.

◆ BackwardDebugInfo()

void MyCaffe.common.Net< T >.BackwardDebugInfo ( int  layer_id)
protected

Helper for displaying debug info in Backward.

Parameters
layer_idSpecifies the Layer index associated with the Blob.

Definition at line 1587 of file Net.cs.

◆ blob_by_name()

Blob< T > MyCaffe.common.Net< T >.blob_by_name ( string  strName,
bool  bThrowExceptionOnError = true 
)

Returns a blob given its name.

Parameters
strNameSpecifies the Blob's name.
bThrowExceptionOnErrorOptionally, specifies to throw an exception when the layer is not found. The default = true.
Returns
The Blob with the given name is returned, or null if not found.

Definition at line 2245 of file Net.cs.

◆ blob_index_by_name()

int MyCaffe.common.Net< T >.blob_index_by_name ( string  strName)

Returns the index of a blob given its name.

Parameters
strNameSpecifies the name of the blob to look for.
Returns
The index of the blob within the 'blobs' is returned.

Definition at line 2268 of file Net.cs.

◆ bottom_ids()

List< int > MyCaffe.common.Net< T >.bottom_ids ( int  layer_id)

Returns the ids of the bottom blobs of layer i.

Parameters
layer_idSpecifies the index of the Layer.
Returns

Definition at line 2050 of file Net.cs.

◆ ClearParamDiffs()

void MyCaffe.common.Net< T >.ClearParamDiffs ( )

Zero out the diffs of all netw parameters. This should be run before Backward.

Definition at line 1907 of file Net.cs.

◆ CopyInternalBlobsTo()

void MyCaffe.common.Net< T >.CopyInternalBlobsTo ( Net< T >  dstNet)

Copy the internal blobs from one net to another.

Parameters
dstNetSpecifies the destination net.

Definition at line 1699 of file Net.cs.

◆ CopyTrainedLayersFrom()

void MyCaffe.common.Net< T >.CopyTrainedLayersFrom ( NetParameter  param)

For an already initialized net, CopyTrainedLayersFrom copies the already trained layers from another net parameter instance.

Parameters
paramSpecifies the NetParameter to use.

Definition at line 1814 of file Net.cs.

◆ CopyTrainedLayersTo() [1/2]

void MyCaffe.common.Net< T >.CopyTrainedLayersTo ( Net< T >  dstNet)

Copies the trained layer of this Net to another Net.

Parameters
dstNetSpecifies the Net where the trained layers are to be copied.

Definition at line 1714 of file Net.cs.

◆ CopyTrainedLayersTo() [2/2]

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.

Parameters
dstNetSpecifies the destination Net where the trained layers are to be copied.
rgLayerNamesSpecifies the layer name dictionary lookup, where only the weights of layer names within the Dictionary lookup are copied.
bTransposeSpecifies whether or not to copy the weights and transpose the copy.

Definition at line 1754 of file Net.cs.

◆ Dispose() [1/2]

void MyCaffe.common.Net< T >.Dispose ( )

Releases all resources (GPU and Host) used by the Net.

Definition at line 258 of file Net.cs.

◆ Dispose() [2/2]

virtual void MyCaffe.common.Net< T >.Dispose ( bool  bDisposing)
protectedvirtual

Releases all resources (GPU and Host) used by the Net.

Parameters
bDisposingSet to true when called from Dispose().

Definition at line 184 of file Net.cs.

◆ FilterNet()

NetParameter MyCaffe.common.Net< T >.FilterNet ( NetParameter  param)

Removes layers that the user specified should be excluded given the current phase, level and stage.

Parameters
paramSpecifies the NetParameter to filter.
Returns
The newly filtered NetParmeter is returned.

Definition at line 1020 of file Net.cs.

◆ FindBlob()

Blob< T > MyCaffe.common.Net< T >.FindBlob ( string  strName)

Finds a Blob in the Net by name.

Parameters
strNameSpecifies the Blob name.
Returns
If found, the Blob is returned, otherwise null is returned.

Definition at line 2592 of file Net.cs.

◆ FindBottomBlobsOfLayer()

BlobCollection< T > MyCaffe.common.Net< T >.FindBottomBlobsOfLayer ( string  strLayer)

Returns the collection of bottom blobs for a given layer.

Parameters
strLayerSpecifies the layer name.
Returns
The collection of bottom blobs is returned.

Definition at line 2623 of file Net.cs.

◆ FindLastLayer()

Layer< T > MyCaffe.common.Net< T >.FindLastLayer ( LayerParameter.LayerType  type)

Find the last layer with the matching type.

Parameters
typeSpecifies the layer type.
Returns
The layer found (if any) is returned, otherwise null is returned.

Definition at line 2806 of file Net.cs.

◆ FindLayer() [1/2]

Layer< T > MyCaffe.common.Net< T >.FindLayer ( LayerParameter.LayerType type,
string  strName 
)

Find the layer with the matching type, name and or both.

Parameters
typeSpecifies the layer type.
strNameSpecifies the layer name.
Returns
The layer found (if any) is returned, otherwise null is returned.

Definition at line 2748 of file Net.cs.

◆ FindLayer() [2/2]

Layer< T > MyCaffe.common.Net< T >.FindLayer ( string  strType,
string  strName 
)

Find the layer with the matching type, name and or both.

Parameters
strTypeSpecifies the layer type.
strNameSpecifies the layer name.
Returns
The layer found (if any) is returned, otherwise null is returned.

Definition at line 2795 of file Net.cs.

◆ FindLayerIndexOwningBlob()

int MyCaffe.common.Net< T >.FindLayerIndexOwningBlob ( Blob< T >  b)

Finds the index of the Layer that owns a given Blob.

Parameters
bSpecifies the Blob to search for.
Returns
If found, the Layer index is returned, otherwise -1 is returned.

Definition at line 2576 of file Net.cs.

◆ FindLayerOwningBlob()

Layer< T > MyCaffe.common.Net< T >.FindLayerOwningBlob ( Blob< T >  b)

Finds the Layer that owns a given Blob.

Parameters
bSpecifies the Blob to search for.
Returns
If found, the Layer is returned, otherwise null is returned.

Definition at line 2560 of file Net.cs.

◆ FindLayers()

List< Layer< T > > MyCaffe.common.Net< T >.FindLayers ( LayerParameter.LayerType  type)

Find the layers with the matching type.

Parameters
typeSpecifies the type of layer to find.
Returns
The list of layers is returned.

Definition at line 2776 of file Net.cs.

◆ FindLossBottomBlob()

Blob< T > MyCaffe.common.Net< T >.FindLossBottomBlob ( )

Find the bottom blob of the Loss layer if it exists, otherwise null is returned.

Returns
Return the blob of the loss layer or null if not found.

Definition at line 2664 of file Net.cs.

◆ FindTopBlobsOfLayer()

BlobCollection< T > MyCaffe.common.Net< T >.FindTopBlobsOfLayer ( string  strLayer)

Returns the collection of top blobs for a given layer.

Parameters
strLayerSpecifies the layer name.
Returns
The collection of top blobs is returned.

Definition at line 2644 of file Net.cs.

◆ Forward() [1/3]

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().

Returns
The collection of output Blobs is returned.

Definition at line 1445 of file Net.cs.

◆ Forward() [2/3]

BlobCollection< T > MyCaffe.common.Net< T >.Forward ( BlobCollection< T >  colBottom,
out double  dfLoss,
bool  bReshape = false 
)

Run forward using a set of bottom blobs and return the result.

Parameters
colBottom
dfLoss
bReshapeOptionally, specifies to reshape the input to the size of the colBottom blobs supplied.
Returns

Definition at line 1472 of file Net.cs.

◆ Forward() [3/3]

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().

Parameters
dfLossReturns the loss of the operation.
Returns
The collection of output Blobs is returned.

Definition at line 1459 of file Net.cs.

◆ ForwardBackward()

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.

Parameters
colBottomOptionally, specifies input data passed to the Forward pass.
dfLocalLossReturns the local loss of the Forward pass.
stepOptionally, specifies to step forward or backward.
Returns
If EnableBreakOnFirstNaN == true and a NaN is detected, this function returns false, otherwise true is returned.

Definition at line 1943 of file Net.cs.

◆ ForwardDebugInfo()

void MyCaffe.common.Net< T >.ForwardDebugInfo ( int  layer_id)
protected

Helper for displaying debug info in Forward.

Parameters
layer_idSpecifies the Layer index associated with the Blob.

Definition at line 1558 of file Net.cs.

◆ ForwardFromTo()

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.

Parameters
nStartOptionally, specifies the index of the first Layer where the Forward operation is to start.
nEndOptionally, specifies the index of the last Layer to run the Forward operation on.
Returns
The loss is returned.

Definition at line 1402 of file Net.cs.

◆ GetDataSource()

string MyCaffe.common.Net< T >.GetDataSource ( )

Returns the data source used by the network.

Returns
The data source name is returned.

Definition at line 2711 of file Net.cs.

◆ GetDebugInformation()

DebugInformation< T > MyCaffe.common.Net< T >.GetDebugInformation ( bool  bDetectNans)

Returns the DebugInformation for the Net.

Parameters
bDetectNansSpecifies whether or not to detect Nan's in the data.
Returns
The DebugInformation for the Net is returned.

Definition at line 2692 of file Net.cs.

◆ has_blob()

bool MyCaffe.common.Net< T >.has_blob ( string  strBlobName)

Returns whether or not the Net contains a given Blob.

Parameters
strBlobNameSpecifies the Blob name.
Returns
If the Net has the Blob, true is returned, otherwise false is returned.

Definition at line 2234 of file Net.cs.

◆ has_layer()

bool MyCaffe.common.Net< T >.has_layer ( string  strLayer)

Returns whether or not the Net has a given Layer by its name.

Parameters
strLayerSpecifies the Layer name.
Returns
If the Net contains the Layer, true is returned, otherwise false is returned.

Definition at line 2281 of file Net.cs.

◆ Init()

void MyCaffe.common.Net< T >.Init ( NetParameter  p,
Phase  phaseOverride = Phase.NONE,
AutoResetEvent  evtTrainingCompleted = null 
)

Initialize a network with a NetParameter.

Parameters
pSpecifies the NetParameter.
phaseOverrideOptionally, specifies a Phase override for which the Net will run under.
evtTrainingCompletedOptionally, specifies an auto reset event that is set upon the completion of training.

Definition at line 287 of file Net.cs.

◆ InputDebugInfo()

void MyCaffe.common.Net< T >.InputDebugInfo ( int  input_id)
protected

Helper for displaying debug info in Forward about input blobs.

Parameters
input_idSpecifies the index of the input Blob within input_blobs().

Definition at line 1544 of file Net.cs.

◆ InsertSplits()

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.

Parameters
paramSpecifies the original NetParameter.
Returns
A new NetParameter containing split layers is returned.

Definition at line 2347 of file Net.cs.

◆ layer_blobs()

BlobCollection< T > MyCaffe.common.Net< T >.layer_blobs ( string  strLayerName)

Returns the collection of Blobs internal to a Layer.

Parameters
strLayerNameSpecifies the name of the Layer.
Returns
The Layer's internal Blobs are returned in a collection.

Definition at line 2094 of file Net.cs.

◆ layer_by_name()

Layer< T > MyCaffe.common.Net< T >.layer_by_name ( string  strLayer,
bool  bThrowExceptionOnError = true 
)

Returns a Layer given its name.

Parameters
strLayerSpecifies the Layer name.
bThrowExceptionOnErrorOptionally, specifies to throw an exception when the layer is not found. The default = true.
Returns
The Layer with the given name is returned, or null if not found.

Definition at line 2292 of file Net.cs.

◆ layer_index_by_name()

int MyCaffe.common.Net< T >.layer_index_by_name ( string  strLayer)

Returns a Layer's index given its name.

Parameters
strLayerSpecifies the Layer name.
Returns
The index of the Layer with the given name is returned, or -1 if not found.

Definition at line 2315 of file Net.cs.

◆ LoadWeights()

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.

Parameters
rgWeightsSpecifies the weights themselves.
persistSpecifies an interface to the persistance object used to load the weights.
inputWtInfoOptionally, specifies the input blobs to import. Note, when set, the targetWtInfo must also be specified. When null, this parameter is ignored.
targetWtInfoOptionally, specifies the target blobs to import into. Note, when set, the inputWtInfo must also be specified. When null, this parameter is ignored.
strSkipBlobTypeOptionally, specifies a blob type where weights are NOT loaded. See Blob.BLOB_TYPE for the types of Blobs.

Definition at line 2510 of file Net.cs.

◆ param_by_name()

Blob< T > MyCaffe.common.Net< T >.param_by_name ( string  strName,
bool  bThrowExceptionOnError = true 
)

Returns a parameter given its name.

Parameters
strNameSpecifies the Parameter's name.
bThrowExceptionOnErrorOptionally, specifies to throw an exception when the layer is not found. The default = true.
Returns
The Blob with the given name is returned, or null if not found.

Definition at line 2167 of file Net.cs.

◆ ReInitializeParameters()

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.

Parameters
targetSpecifies the weights to target (e.g. weights, bias or both).
rgstrLayersSpecifies the layers to reinitialize, when null or empty, all layers are re-initialized
Returns
If a layer is specified and found, true is returned, otherwise false is returned.

Definition at line 2729 of file Net.cs.

◆ Reshape()

void MyCaffe.common.Net< T >.Reshape ( )

Reshape all layers from the bottom to the top.

This is useful to propagate changes to layer sizes without running a forward pass, e.g. to compute output feature size.

Definition at line 1800 of file Net.cs.

◆ RestorePhase()

void MyCaffe.common.Net< T >.RestorePhase ( )

Restore the network phase to its original state.

Definition at line 831 of file Net.cs.

◆ SaveWeights()

byte[] MyCaffe.common.Net< T >.SaveWeights ( IXPersist< T >  persist,
bool  bSaveDiff = false 
)

Save the weights to a byte array.

Parameters
persistSpecifies an interface to the persistance object used to save the weights.
bSaveDiffSpecifies to save the diff values.
Returns
The byte array containing the weights is returned.

Definition at line 2541 of file Net.cs.

◆ set_debug_info()

void MyCaffe.common.Net< T >.set_debug_info ( bool  bVal)

Sets the debug information flag.

When set, extra debug information is output during each Forward and Backward pass, which will slow down training.

Parameters
bValSpecifies whether to enable/disable debug information.

Definition at line 2330 of file Net.cs.

◆ SetEnablePassthrough()

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.

Parameters
bEnableSpecifies whether or not to enable passthrough.

Definition at line 996 of file Net.cs.

◆ SetLearnedParameters()

void MyCaffe.common.Net< T >.SetLearnedParameters ( BlobCollection< T >  col)

Sets the learned parameters.

Parameters
colSpecifies a collection of Blobs containing the learned parameters.

Definition at line 2108 of file Net.cs.

◆ SetPhase()

Phase MyCaffe.common.Net< T >.SetPhase ( Phase  phase)

Change the phase of the network.

Parameters
phaseSpecifies the new phase.
Returns
The previous phase is returned.

Definition at line 814 of file Net.cs.

◆ ShareTrainedLayersWith()

void MyCaffe.common.Net< T >.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.

Parameters
srcNetSpecifies the source Net whos blobs are shared with the calling Net.
bEnableLogOptionally, specifies to enable the output log (default = false).

Definition at line 1653 of file Net.cs.

◆ ShareWeights()

void MyCaffe.common.Net< T >.ShareWeights ( )

Shares weight data of owner blobs with shared blobs.

Note: this is called by Net::Init, and thus should normally not be called manually.

Definition at line 1923 of file Net.cs.

◆ StateMeetsRule()

bool MyCaffe.common.Net< T >.StateMeetsRule ( NetState  state,
NetStateRule  rule,
string  strLayer 
)

Returns whether NetState state meets NetStateRule rule.

Parameters
stateSpecifies the NetState to test.
ruleSpecifies the NetStateRul to test against the NetState.
strLayerSpecifies the name of the Layer for which the test is taking place.
Returns
If the NetState of the Layer meets the NetStateRule, true is returned, otherwise false is returned.

Definition at line 1062 of file Net.cs.

◆ top_ids()

List< int > MyCaffe.common.Net< T >.top_ids ( int  layer_id)

Returns the ids of the top blobs of layer i.

Parameters
layer_idSpecifies the index of the Layer.
Returns

Definition at line 2038 of file Net.cs.

◆ ToProto()

NetParameter MyCaffe.common.Net< T >.ToProto ( bool  bIncludeBlobs)

Writes the net to a proto.

Returns
A new NetParameter is returned.

Definition at line 1865 of file Net.cs.

◆ Update()

void MyCaffe.common.Net< T >.Update ( )

Updates the network weights based on the diff values computed.

Definition at line 1896 of file Net.cs.

◆ UpdateDebugInfo()

void MyCaffe.common.Net< T >.UpdateDebugInfo ( int  param_id)
protected

Helper for displaying debug info in Update.

Parameters
param_idSpecifies the parameter index associated with the Blob.

Definition at line 1622 of file Net.cs.

Property Documentation

◆ ActiveLabelCounts

string MyCaffe.common.Net< T >.ActiveLabelCounts
get

Returns the active label counts observed during training.

Definition at line 913 of file Net.cs.

◆ blob_loss_weights

List<double> MyCaffe.common.Net< T >.blob_loss_weights
get

Returns the collection of blob loss weights.

Definition at line 2068 of file Net.cs.

◆ blob_names

List<string> MyCaffe.common.Net< T >.blob_names
get

Returns the blob names.

Definition at line 1986 of file Net.cs.

◆ blobs

Returns the blobs.

Definition at line 1994 of file Net.cs.

◆ BoostQueryHitPercents

string MyCaffe.common.Net< T >.BoostQueryHitPercents
get

Return the boost query hit percentages for the active datasource.

Definition at line 973 of file Net.cs.

◆ bottom_need_backward

List<List<bool> > MyCaffe.common.Net< T >.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.

Definition at line 2060 of file Net.cs.

◆ bottom_vecs

List<BlobCollection<T> > MyCaffe.common.Net< 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.

Definition at line 2019 of file Net.cs.

◆ Cuda

CudaDnn<T> MyCaffe.common.Net< T >.Cuda
get

Returns the instance of CudaDnn used by this network.

Definition at line 2820 of file Net.cs.

◆ EnableBreakOnFirstNaN

bool MyCaffe.common.Net< T >.EnableBreakOnFirstNaN
getset

Enable/disable break the first NaN functionality where training stops immediately upon detecting a NaN in one of the Layer blobs.

Definition at line 844 of file Net.cs.

◆ EnableDetailedNanDetection

bool MyCaffe.common.Net< T >.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).

Definition at line 854 of file Net.cs.

◆ EnableLayerDebugging

bool MyCaffe.common.Net< T >.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.

This option dramatically slows down training and is only recommended during debugging.

Definition at line 866 of file Net.cs.

◆ input_blob_indices

List<int> MyCaffe.common.Net< T >.input_blob_indices
get

Returns a list of the input Blob indexes.

Definition at line 2224 of file Net.cs.

◆ input_blobs

BlobCollection<T> MyCaffe.common.Net< T >.input_blobs
get

Returns the collection of input Blobs.

Definition at line 2200 of file Net.cs.

◆ LabelQueryEpochs

string MyCaffe.common.Net< T >.LabelQueryEpochs
get

Return the label query epochs for the active datasource.

Definition at line 954 of file Net.cs.

◆ LabelQueryHitPercents

string MyCaffe.common.Net< T >.LabelQueryHitPercents
get

Return the label query hit percentages for the active datasource.

Definition at line 935 of file Net.cs.

◆ layer_names

List<string> MyCaffe.common.Net< T >.layer_names
get

Returns the layer names.

Definition at line 1978 of file Net.cs.

◆ layer_need_backward

List<bool> MyCaffe.common.Net< T >.layer_need_backward
get

Returns a collection of items that tell whether each layer nees a backward pass or not.

Definition at line 2076 of file Net.cs.

◆ layers

List<Layer<T> > MyCaffe.common.Net< T >.layers
get

Returns the layers.

Definition at line 2002 of file Net.cs.

◆ learnable_parameters

BlobCollection<T> MyCaffe.common.Net< T >.learnable_parameters
get

Returns the learnable parameters.

Definition at line 2116 of file Net.cs.

◆ name

string MyCaffe.common.Net< T >.name
get

Returns the network name.

Definition at line 1970 of file Net.cs.

◆ net_param

NetParameter MyCaffe.common.Net< T >.net_param
get

Returns the net parameter.

Definition at line 1856 of file Net.cs.

◆ num_inputs

int MyCaffe.common.Net< T >.num_inputs
get

Returns the number of inputs.

Definition at line 2184 of file Net.cs.

◆ num_outputs

int MyCaffe.common.Net< T >.num_outputs
get

Returns the number of outputs.

Definition at line 2192 of file Net.cs.

◆ output_blob_indices

List<int> MyCaffe.common.Net< T >.output_blob_indices
get

Returns a list of the output Blob indexes.

Definition at line 2216 of file Net.cs.

◆ output_blobs

BlobCollection<T> MyCaffe.common.Net< T >.output_blobs
get

Returns the collection of output Blobs.

Definition at line 2208 of file Net.cs.

◆ param_display_names

List<string> MyCaffe.common.Net< T >.param_display_names
get

Returns the list of parameter display names.

Definition at line 2156 of file Net.cs.

◆ param_names_index

DictionaryEx<string, int> MyCaffe.common.Net< T >.param_names_index
get

Returns the dictionary look for parameter names to their indexes.

Definition at line 2140 of file Net.cs.

◆ param_owners

List<int> MyCaffe.common.Net< T >.param_owners
get

Returns the list of parameter owner indexes.

Definition at line 2148 of file Net.cs.

◆ parameters

BlobCollection<T> MyCaffe.common.Net< T >.parameters
get

Returns the parameters.

Definition at line 2084 of file Net.cs.

◆ params_lr

List<double?> MyCaffe.common.Net< T >.params_lr
get

Returns the learnable parameter learning rate multipliers.

Definition at line 2124 of file Net.cs.

◆ params_weight_decay

List<double?> MyCaffe.common.Net< T >.params_weight_decay
get

Returns the learnable parameter decay multipliers.

Definition at line 2132 of file Net.cs.

◆ phase

Phase MyCaffe.common.Net< T >.phase
get

Returns the network phase: TRAIN or TEST

Definition at line 2010 of file Net.cs.

◆ top_vecs

List<BlobCollection<T> > MyCaffe.common.Net< 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.

Definition at line 2028 of file Net.cs.

Event Documentation

◆ OnGetIteration

EventHandler<GetIterationArgs> MyCaffe.common.Net< T >.OnGetIteration

Specifies the OnGetIteration event that fires when a layer needs to get the current iteration from the solver.

Definition at line 136 of file Net.cs.

◆ OnGetWorkspace

EventHandler<WorkspaceArgs> MyCaffe.common.Net< T >.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.

Definition at line 128 of file Net.cs.

◆ OnSetWorkspace

EventHandler<WorkspaceArgs> MyCaffe.common.Net< T >.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.

Definition at line 132 of file Net.cs.


The documentation for this class was generated from the following file: