MyCaffe
1.12.2.41
Deep learning software for Windows C# programmers.
|
The PersistCaffe class is used to load and save weight files in the .caffemodel format. More...
Public Member Functions | |
PersistCaffe (Log log, bool bFailOnFirstTry) | |
The PersistCaffe constructor. More... | |
bool | IsMyCaffe (byte[] rgWeights, out string strVer) |
This method returns whether or not the weights have been marked as 'mycaffe.ai'. More... | |
byte[] | SaveSolverState (SolverState state, SolverParameter.SolverType type=SolverParameter.SolverType.SGD) |
Save the solver state to a byte array. More... | |
SolverState | LoadSolverState (byte[] rgState, SolverParameter.SolverType type=SolverParameter.SolverType.SGD) |
Load the solver state from a byte array. More... | |
BlobCollection< T > | LoadWeights (byte[] rgWeights, List< string > rgExpectedShapes, BlobCollection< T > colBlobs, bool bSizeToFit, out bool bLoadedDiffs, List< string > inputWtInfo=null, List< string > targetWtInfo=null, string strSkipBlobType=null) |
Loads new weights into a BlobCollection More... | |
WeightInfo< T > | LoadWeightInfo (byte[] rgWeights) |
Returns the weight information describing the weights containined within the weight bytes. More... | |
WeightInfo< T > | LoadWeightInfo (BlobCollection< T > colBlobs) |
Returns the weight information describing the weights containined within the Blob collection. More... | |
byte[] | SaveWeights (BlobCollection< T > colBlobs, bool bSaveDiffs=false) |
Save the weights to a byte array. More... | |
BlobProto | LoadBlobProto (byte[] rg, int nFieldId) |
The LoadBlobProto function loads a BlobProto from a proto buffer. More... | |
BlobProto | LoadBlobProto (string strFile, int nFieldId) |
The LoadBlobProto function loads a BlobProto from a file. More... | |
Properties | |
string | MyCaffeTag [get] |
This tag is used to mark the ending section of each weighting file with 'MyCaffe' specific information. More... | |
The PersistCaffe class is used to load and save weight files in the .caffemodel format.
T | Specifies the base type float or double. Using float is recommended to conserve GPU memory. |
Definition at line 19 of file PersistCaffe.cs.
MyCaffe.common.PersistCaffe< T >.PersistCaffe | ( | Log | log, |
bool | bFailOnFirstTry | ||
) |
The PersistCaffe constructor.
log | Specifies the log used for output. |
bFailOnFirstTry | Specifies whether or not to try to load the weights file. On the first try the Caffe model format is attempted, and on the second the MyCaffe format is used. |
Definition at line 30 of file PersistCaffe.cs.
bool MyCaffe.common.PersistCaffe< T >.IsMyCaffe | ( | byte[] | rgWeights, |
out string | strVer | ||
) |
This method returns whether or not the weights have been marked as 'mycaffe.ai'.
rgWeights | Specifies the weights. |
strVer | Returns the version of this file. |
Definition at line 51 of file PersistCaffe.cs.
BlobProto MyCaffe.common.PersistCaffe< T >.LoadBlobProto | ( | byte[] | rg, |
int | nFieldId | ||
) |
The LoadBlobProto function loads a BlobProto from a proto buffer.
rg | Specifies the bytes containing the BlobProto in proto buffer format. |
nFieldId | Specifies the field ID to use for the BlobProto. |
Definition at line 353 of file PersistCaffe.cs.
BlobProto MyCaffe.common.PersistCaffe< T >.LoadBlobProto | ( | string | strFile, |
int | nFieldId | ||
) |
The LoadBlobProto function loads a BlobProto from a file.
strFile | Specifies the binary file containing the blob proto. |
nFieldId | Specifies the field ID to use for the BlobProto. |
Definition at line 450 of file PersistCaffe.cs.
SolverState MyCaffe.common.PersistCaffe< T >.LoadSolverState | ( | byte[] | rgState, |
SolverParameter.SolverType | type = SolverParameter.SolverType.SGD |
||
) |
Load the solver state from a byte array.
rgState | Specifies the byte array containing the solver state. |
type | Specifies the solver type. |
Implements MyCaffe.common.IXPersist< T >.
Definition at line 116 of file PersistCaffe.cs.
WeightInfo< T > MyCaffe.common.PersistCaffe< T >.LoadWeightInfo | ( | BlobCollection< T > | colBlobs | ) |
Returns the weight information describing the weights containined within the Blob collection.
colBlobs | Specifies the Blob collection containing the weights. |
Implements MyCaffe.common.IXPersist< T >.
Definition at line 267 of file PersistCaffe.cs.
WeightInfo< T > MyCaffe.common.PersistCaffe< T >.LoadWeightInfo | ( | byte[] | rgWeights | ) |
Returns the weight information describing the weights containined within the weight bytes.
rgWeights | Specifies the bytes containing the weights. |
Implements MyCaffe.common.IXPersist< T >.
Definition at line 252 of file PersistCaffe.cs.
BlobCollection< T > MyCaffe.common.PersistCaffe< T >.LoadWeights | ( | byte[] | rgWeights, |
List< string > | rgExpectedShapes, | ||
BlobCollection< T > | colBlobs, | ||
bool | bSizeToFit, | ||
out bool | bLoadedDiffs, | ||
List< string > | inputWtInfo = null , |
||
List< string > | targetWtInfo = null , |
||
string | strSkipBlobType = null |
||
) |
Loads new weights into a BlobCollection
NOTE: In order to maintain compatibility with the C++ Caffe, extra MyCaffe features may be added to the end of the weight file. After saving weights (see SaveWeights) in the format used by the C++ Caffe, MyCaffe writes the bytes "mycaffe.ai". All information after these bytes are specific to MyCaffe and allow for loading weights for models by Blob name and shape and loosen the C++ Caffe requirement that the 'number' of blobs match. Adding this functionality allows for training model, changing the model structure, and then re-using the trained weights in the new model.
rgWeights | Specifies the weights themselves. |
rgExpectedShapes | Specifies a list of expected shapes for each Blob where the weights are to be loaded. |
colBlobs | Specifies the Blobs to load with the weights. |
bSizeToFit | Specifies wether or not the weights should be re-sized. Note: resizing can render the weights useless, especially in deeper, layers. |
bLoadedDiffs | Returns whether or not the diffs were loaded. |
inputWtInfo | Optionally, specifies the weight info describing the input weight blobs to import by name. Note when used the number of blobs must match the number of targetWtInfo blobs. Otherwise, when null this parameter is ignored. |
targetWtInfo | Optionally, specifies the weight info describing the target weight blobs to import by name. Note when used the number of blobs must match the number of inputWtInfo blobs. Otherwise, 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. |
Implements MyCaffe.common.IXPersist< T >.
Definition at line 209 of file PersistCaffe.cs.
byte[] MyCaffe.common.PersistCaffe< T >.SaveSolverState | ( | SolverState | state, |
SolverParameter.SolverType | type = SolverParameter.SolverType.SGD |
||
) |
Save the solver state to a byte array.
state | Specifies the solver state to save. |
type | Specifies the solver type. |
Implements MyCaffe.common.IXPersist< T >.
Definition at line 75 of file PersistCaffe.cs.
byte[] MyCaffe.common.PersistCaffe< T >.SaveWeights | ( | BlobCollection< T > | colBlobs, |
bool | bSaveDiffs = false |
||
) |
Save the weights to a byte array.
NOTE: In order to maintain compatibility with the C++ Caffe, extra MyCaffe features may be added to the end of the weight file. After saving weights in the format used by the C++ Caffe, MyCaffe writes the bytes "mycaffe.ai". All information after these bytes are specific to MyCaffe and allow for loading weights for models by Blob name and shape and loosen the C++ Caffe requirement that the 'number' of blobs match. Adding this functionality allows for training model, changing the model structure, and then re-using the trained weights in the new model.
colBlobs | Specifies the Blobs to save with the weights. |
bSaveDiffs | Optionally, specifies to save the diff values - currently this parameter is not used. |
Implements MyCaffe.common.IXPersist< T >.
Definition at line 291 of file PersistCaffe.cs.
|
get |
This tag is used to mark the ending section of each weighting file with 'MyCaffe' specific information.
Definition at line 40 of file PersistCaffe.cs.