![]() |
MyCaffe
1.12.2.41
Deep learning software for Windows C# programmers.
|
An interface for classes that perform optimization on Nets - this class serves as the base class for all solvers. More...
Public Member Functions | |
| Solver (CudaDnn< T > cuda, Log log, SolverParameter p, CancelEvent evtCancel, AutoResetEvent evtForceSnapshot, AutoResetEvent evtForceTest, IXDatabaseBase db, IXPersist< T > persist, int nSolverCount=1, int nSolverRank=0, Net< T > shareNet=null, onGetWorkspace getws=null, onSetWorkspace setws=null) | |
| The Solver constructor. More... | |
| void | Dispose () |
| Discards the resources (GPU and Host) used by this Solver. More... | |
| bool | ForceOnTrainingIterationEvent () |
| Force an OnTrainingIterationEvent to fire. More... | |
| void | Init (SolverParameter p, Net< T > shareNet=null) |
| Initializes the Solver. More... | |
| void | Reset () |
| Reset the iterations of the net. More... | |
| virtual void | Solve (int nIterationOverride=-1, byte[] rgWeights=null, byte[] rgState=null, TRAIN_STEP step=TRAIN_STEP.NONE) |
| The main entry of the solver function. In default, iter will be zero. Pass in a non-zero iter number to resume training for a pre-trained net. More... | |
| bool | Step (int nIters, TRAIN_STEP step=TRAIN_STEP.NONE, bool bZeroDiffs=true, bool bApplyUpdates=true, bool bDisableOutput=false, bool bDisableProgress=false, double? dfLossOverride=null, bool? bAllowSnapshot=null) |
| Steps a set of iterations through a training cycle. More... | |
| void | Restore (byte[] rgWeights, byte[] rgState, string strSkipBlobTypes=null) |
| The restore method simply calls the RestoreSolverState method of the inherited class. More... | |
| void | Snapshot (bool bForced, bool bScheduled, bool bUpdateDatabase=true) |
| The snapshot function implements the basic snapshotting utility that stores the learned net. This method calls the SnapshotSolverState method of the inherited class. More... | |
| SnapshotArgs | GetSnapshotArgs (byte[] rgState, byte[] rgWeights, double dfAccuracy, double dfError, int nIteration, SNAPSHOT_WEIGHT_UPDATE_METHOD wtUpdt) |
| The GetSnapshotArgs method fills out a snapshot args structure. More... | |
| double | TestAll (int nIterationOverride=-1) |
| Run a TestAll by running all test Nets. More... | |
| double | TestDetection (int nIterationOverride=-1, int nTestNetId=0) |
| Run an SSD detection test on a given test Net by running it through its iterations. More... | |
| double | TestClassification (int nIterationOverride=-1, int nTestNetId=0) |
| Run a test on a given test Net by running it through its iterations. More... | |
| void | UpdateSmoothedLoss (double dfLoss, int nStartIter, int nAverageLoss=0) |
| Update the avaraged loss value. More... | |
| abstract double | ApplyUpdate (int nIterationOverride=-1) |
| Make and apply the update value for the current iteration. More... | |
Static Public Member Functions | |
| static SGDSolver< T > | Create (CudaDnn< T > cuda, Log log, ProjectEx p, CancelEvent evtCancel, AutoResetEvent evtForceSnapshot, AutoResetEvent evtForceTest, IXDatabaseBase db, IXPersist< T > persist, int nSolverCount=1, int nSolverRank=0, Net< T > shareNet=null, onGetWorkspace getws=null, onSetWorkspace setws=null) |
| Create a new Solver based on the project containing the SolverParameter. More... | |
| static SGDSolver< T > | Create (CudaDnn< T > cuda, Log log, SolverParameter solverParam, CancelEvent evtCancel, AutoResetEvent evtForceSnapshot, AutoResetEvent evtForceTest, IXDatabaseBase db, IXPersist< T > persist, int nSolverCount=1, int nSolverRank=0, Net< T > shareNet=null, onGetWorkspace getws=null, onSetWorkspace setws=null) |
| Create a new Solver based on the project containing the SolverParameter. More... | |
Protected Member Functions | |
| virtual void | dispose () |
| Override that allows discarding of resources (GPU and Host) used by this Solver. More... | |
| void | InitTrainNet (Net< T > shareNet=null) |
| Initializes the Net used by the solver for training. More... | |
| void | InitTestNets () |
| Initializes the Net used by the Solver for testing. More... | |
| abstract byte[] | SnapshotSolverState () |
| Save the current solver state. More... | |
| abstract void | RestoreSolverState (byte[] rgState) |
| Restore a solver state. More... | |
Protected Attributes | |
| CudaDnn< T > | m_cuda |
| Specifies the instance of CudaDnn used by the Solver that provides a connection to Cuda. More... | |
| Log | m_log |
| Specifies the Log for output. More... | |
| SolverParameter | m_param |
| Specifies the SolverParameter that defines how the Solver operates. More... | |
| Net< T > | m_net |
| Specifies the training Net. More... | |
| List< Net< T > > | m_rgTestNets = new List<Net<T>>() |
| Specifies the testing Nets. More... | |
| int | m_nIter |
| Specifies the current iteration. More... | |
| int | m_nCurrentStep |
| Specifies the current step. More... | |
| List< double > | m_rgLosses = new List<double>() |
| Specifies the Losses used to calculate the smoothed Loss. More... | |
| double | m_dfSmoothedLoss = 0 |
| Specifies the smoothed loss protected for derived classes to use. More... | |
| double? | m_dfIterAccuracy = null |
| Specifies the iteration accuracy calculated when a blob exists with the name 'accuracy'. More... | |
| int | m_nSolverCount = 1 |
| Specifies the Solver count in a multi-GPU training session. More... | |
| int | m_nSolverRank = 0 |
| Specifies the Solver rank of this solver, where rank == 0 is the root Solver. More... | |
| IXPersist< T > | m_persist |
| Specifies the persistance object used to save weight and solver states. More... | |
| double | m_dfLearningRateOverride = 0 |
| Optionally, specifies a learning rate override (default = 0, which ignores this setting). More... | |
Properties | |
| double | LearningRateOverride [getset] |
| Get/set the learning rate override. When 0, this setting is ignored. More... | |
| int | TrainingTimeLimitInMinutes [getset] |
| Get/set the training time limit in minutes. When set to 0, no time limit is imposed on training. More... | |
| SNAPSHOT_WEIGHT_UPDATE_METHOD | SnapshotWeightUpdateMethod [getset] |
| Get/set the snapshot weight update method. More... | |
| IXDatabaseBase | Database [get] |
| Returns the in-memory MyCaffeDatabase used. More... | |
| bool | EnableTesting [getset] |
| When enabled, the training cycle calls TestAll periodically based on the SolverParameter. Otherwise testing is not performed. More... | |
| bool | EnableBlobDebugging [getset] |
| When enabled, the OnTrainingIteration event is set extra debugging information describing the state of each Blob used by the Solver. 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... | |
| bool | EnableBreakOnFirstNaN [getset] |
| When enabled (requires EnableBlobDebugging = true), the Solver immediately stop training upon detecting the first NaN withing the training Net. More... | |
| bool | EnableDetailedNanDetection [getset] |
| When enabled (requires EnableBlobDebugging = true), the detailed Nan (and Infinity) detection is perofmed on each blob when training Net. More... | |
| bool | EnableSingleStep [getset] |
| When enabled (requires EnableBlobDebugging = true), the Solver only runs one training cycle. More... | |
| bool | WeightsUpdated [getset] |
| Get/set when the weights have been updated. More... | |
| object | Tag [getset] |
| Returns a generic tag associated with the Solver. More... | |
| Net< T > | TestingNet [get] |
| Returns the testing Net used by the solver. More... | |
| Net< T > | TrainingNet [get] |
| Returns the training Net used by the solver. More... | |
| CudaDnn< T > | Cuda [get] |
| Returns the CudaDnn instance used by the Solver. More... | |
| string | ActiveLabelCounts [get] |
| Returns a string describing the labels detected in the training along with the % that each label has participated in the 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... | |
| int | CurrentIteration [get] |
| Returns the current training iteration. More... | |
| int | MaximumIteration [get] |
| Returns the maximum training iterations. More... | |
| int | TrainingIterations [get] |
| Returns the current training iterations remaining. More... | |
| int? | TestingIterations [get] |
| Returns the current testing iterations remaining. More... | |
| int | TrainingIterationOverride [getset] |
| Get/set the training iteration override. More... | |
| int | TestingIterationOverride [getset] |
| Get/set the testing iteration override. More... | |
| AutoResetEvent | CompletedEvent [get] |
| Returns an auto reset event that is set upon training completion. More... | |
| CancelEvent | CancelEvent [get] |
| Returns the cancel event which when set cancels the current operation run by the Solver. More... | |
| double | smoothed_loss [get] |
| Returns the smoothed loss. More... | |
| SolverParameter | parameter [get] |
| Returns the SolverParameter used. More... | |
| Net< T > | net [get] |
| Returns the main training Net. More... | |
| List< Net< T > > | test_nets [get] |
| Returns the testing Nets. More... | |
| int | iter [get] |
| Returns the current training iteration. More... | |
| SolverParameter.SolverType | type [get] |
| Returns the type of solver. More... | |
| bool | forceSnapshot [get] |
| Returns whether or not a snapshot has been forced. More... | |
| bool | forceTest [get] |
| Returns whether or not a test has been forced. More... | |
| int | solver_count [get] |
| Returns the solver count in a multi-GPU session. More... | |
| int | solver_rank [get] |
| Returns this Solver's rank in a multi-GPU session. More... | |
| bool? | is_root_solver [get] |
| Returns whether or not this is the root solver. More... | |
Events | |
| EventHandler | OnStart |
| The OnStart event fires at the start of each training iteration. More... | |
| EventHandler | OnAborted |
| The OnAborted event fires after aborting a training cycle. More... | |
| EventHandler< GradientsReadyArgs > | OnGradientsReady |
| The OnGradientsReady event fires after the gradients of a Solver are ready for distribution to other Solvers in a multi-GPU training session. More... | |
| EventHandler< SnapshotArgs > | OnSnapshot |
| The OnSnapshot event fires when the Solver detects that a snapshot is needed. More... | |
| EventHandler< TrainingIterationArgs< T > > | OnTrainingIteration |
| The OnTrainingIteration event fires at the end of each training iteration. More... | |
| EventHandler< TestingIterationArgs< T > > | OnTestingIteration |
| The OnTestingIteration event fires at the end of each testing iteration. More... | |
| EventHandler< TestResultArgs< T > > | OnTestResults |
| When specified, the OnTestResults event fires after each single test run. The recipient is responsible for setting the accuracy. More... | |
| EventHandler< TestArgs > | OnTest |
| When specified, the OnTest event fires during a TestAll and overrides the call to Test. More... | |
| EventHandler | OnTestStart |
| The OnTestStart event fires at the start of each testing iteration. More... | |
| EventHandler< CustomForwardBackArgs< T > > | OnCustomForwardBack |
| The OnCustomForwardBack allows for overriding the forward/backward operations within the solver. More... | |
| 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... | |
An interface for classes that perform optimization on Nets - this class serves as the base class for all solvers.
Requires implementation of ApplyUpdate to compute a parameter update given the current state of the Net parameters.
| T | Specifies the base type float or double. Using float is recommended to conserve GPU memory. |
| MyCaffe.solvers.Solver< T >.Solver | ( | CudaDnn< T > | cuda, |
| Log | log, | ||
| SolverParameter | p, | ||
| CancelEvent | evtCancel, | ||
| AutoResetEvent | evtForceSnapshot, | ||
| AutoResetEvent | evtForceTest, | ||
| IXDatabaseBase | db, | ||
| IXPersist< T > | persist, | ||
| int | nSolverCount = 1, |
||
| int | nSolverRank = 0, |
||
| Net< T > | shareNet = null, |
||
| onGetWorkspace | getws = null, |
||
| onSetWorkspace | setws = null |
||
| ) |
The Solver constructor.
| cuda | Specifies the instance of CudaDnn to use. |
| log | Specifies the Log for output. |
| p | Specifies teh SolverParameter. |
| evtCancel | Specifies a CancelEvent used to cancel the current operation (e.g. training, testing) for which the Solver is performing. |
| evtForceSnapshot | Specifies an automatic reset event that causes the Solver to perform a Snapshot when set. |
| evtForceTest | Specifies an automatic reset event that causes teh Solver to run a testing cycle when set. |
| db | Specifies the in-memory MyCaffeDatabase. |
| persist | Specifies the peristence used for loading and saving weights. |
| nSolverCount | Specifies the number of Solvers participating in a multi-GPU session. |
| nSolverRank | Specifies the rank of this Solver in a multi-GPU session. |
| shareNet | Optionally, specifies the net to share when creating the training network (default = null, meaning no share net is used). |
| getws | Optionally, specifies the handler for getting the workspace. |
| setws | Optionally, specifies the handler for setting the workspace. |
|
pure virtual |
Make and apply the update value for the current iteration.
| nIterationOverride | Optionally, specifies an iteration override, or -1 which is ignored. |
Implemented in MyCaffe.solvers.LBFGSSolver< T >, and MyCaffe.solvers.SGDSolver< T >.
|
static |
Create a new Solver based on the project containing the SolverParameter.
| cuda | Specifies the CudaDnn instance that the new Solver will use. |
| log | Specifies the Log for output that the new Solver will use. |
| p | Specifies the project to use in initialzing the new Solver. |
| evtCancel | Specifies the CancelEvent that the new Solver will use. |
| evtForceSnapshot | Specifies the force snapshot event that the new Solver will use. |
| evtForceTest | Specifies the force test event that the new Solver will use. |
| db | Specifies the in-memory MyCaffeDatabase that the new Solver will use. |
| persist | Specifies the peristence used for loading and saving weights. |
| nSolverCount | Specifies the number of Solvers participating in a multi-GPu session. |
| nSolverRank | Specifies the rank of the new Solver. |
| shareNet | Optionally, specifies the net to share when creating the training network (default = null, meaning no share net is used). |
| getws | Optionally, specifies the handler for getting the workspace. |
| setws | Optionally, specifies the handler for setting the workspace. |
|
static |
Create a new Solver based on the project containing the SolverParameter.
| cuda | Specifies the CudaDnn instance that the new Solver will use. |
| log | Specifies the Log for output that the new Solver will use. |
| solverParam | Specifies the SolverParameter used to create the Solver. |
| evtCancel | Specifies the CancelEvent that the new Solver will use. |
| evtForceSnapshot | Specifies the force snapshot event that the new Solver will use. |
| evtForceTest | Specifies the force test event that the new Solver will use. |
| db | Specifies the in-memory MyCaffeDatabase that the new Solver will use. |
| persist | Specifies the peristence used for loading and saving weights. |
| nSolverCount | Specifies the number of Solvers participating in a multi-GPu session. |
| nSolverRank | Specifies the rank of the new Solver. |
| shareNet | Optionally, specifies the net to share when creating the training network (default = null, meaning no share net is used). |
| getws | Optionally, specifies the handler for getting the workspace. |
| setws | Optionally, specifies the handler for setting the workspace. |
| void MyCaffe.solvers.Solver< T >.Dispose | ( | ) |
|
protectedvirtual |
Override that allows discarding of resources (GPU and Host) used by this Solver.
Reimplemented in MyCaffe.solvers.LBFGSSolver< T >, and MyCaffe.solvers.SGDSolver< T >.
| bool MyCaffe.solvers.Solver< T >.ForceOnTrainingIterationEvent | ( | ) |
| SnapshotArgs MyCaffe.solvers.Solver< T >.GetSnapshotArgs | ( | byte[] | rgState, |
| byte[] | rgWeights, | ||
| double | dfAccuracy, | ||
| double | dfError, | ||
| int | nIteration, | ||
| SNAPSHOT_WEIGHT_UPDATE_METHOD | wtUpdt | ||
| ) |
The GetSnapshotArgs method fills out a snapshot args structure.
| rgState | Specifies the state bytes or null. |
| rgWeights | Specifies the weight bytes or null. |
| dfAccuracy | Specifies the accuracy. |
| dfError | Specifies the error. |
| nIteration | Specifies the interation. |
| wtUpdt | Specifies the weight update method. |
| void MyCaffe.solvers.Solver< T >.Init | ( | SolverParameter | p, |
| Net< T > | shareNet = null |
||
| ) |
|
protected |
|
protected |
| void MyCaffe.solvers.Solver< T >.Reset | ( | ) |
| void MyCaffe.solvers.Solver< T >.Restore | ( | byte[] | rgWeights, |
| byte[] | rgState, | ||
| string | strSkipBlobTypes = null |
||
| ) |
The restore method simply calls the RestoreSolverState method of the inherited class.
| rgWeights | Specifies the weights to load, or null to ignore. |
| rgState | Specifies the state to load, or null to ignore. |
| strSkipBlobTypes | Specifies the blob types to ignore and not load, or null to ignore. |
|
protectedpure virtual |
Restore a solver state.
Implemented in MyCaffe.solvers.LBFGSSolver< T >, and MyCaffe.solvers.SGDSolver< T >.
| void MyCaffe.solvers.Solver< T >.Snapshot | ( | bool | bForced, |
| bool | bScheduled, | ||
| bool | bUpdateDatabase = true |
||
| ) |
The snapshot function implements the basic snapshotting utility that stores the learned net. This method calls the SnapshotSolverState method of the inherited class.
| bForced | Specifies whehter or not to force the snapshot. |
| bScheduled | Specifies whether or not the snapshot is a scheduled snapshot that occurs at regular intervals, or a snapshot based on an improving accuracy. |
| bUpdateDatabase | Optionally, specifies to update the database (default = true). |
|
protectedpure virtual |
Save the current solver state.
Implemented in MyCaffe.solvers.LBFGSSolver< T >, and MyCaffe.solvers.SGDSolver< T >.
|
virtual |
The main entry of the solver function. In default, iter will be zero. Pass in a non-zero iter number to resume training for a pre-trained net.
| nIterationOverride | Optionally, specifies an iteration override value to use for the number of iterations run. The default is -1, which ignores the parameter. |
| rgWeights | Optionally, specifies weights to load via the Restore method. The default is null which ignores the parameter. |
| rgState | Optionally, specifies the state to load via the Restore method. The default is null which ignores the parameter. |
| step | Optionally, specifies to single step the training pass - typically this is used during debugging. The default = TRAIN_STEP.NONE which runs the solver in the normal manner. |
| bool MyCaffe.solvers.Solver< T >.Step | ( | int | nIters, |
| TRAIN_STEP | step = TRAIN_STEP.NONE, |
||
| bool | bZeroDiffs = true, |
||
| bool | bApplyUpdates = true, |
||
| bool | bDisableOutput = false, |
||
| bool | bDisableProgress = false, |
||
| double? | dfLossOverride = null, |
||
| bool? | bAllowSnapshot = null |
||
| ) |
Steps a set of iterations through a training cycle.
| nIters | Specifies the number of steps to iterate. |
| step | Optionally, specifies to single step the training pass - typically this is used during debugging. The default = TRAIN_STEP.NONE for no stepping. |
| bZeroDiffs | Optionally, specifies whether or not to zero out the gradient diffs (default = true). |
| bApplyUpdates | Optionally, specifies to apply the gradient updates to the weights (default = true). |
| bDisableOutput | Optionally, disable the output to the log. |
| bDisableProgress | Optionally, disables the progress updating to the log. |
| dfLossOverride | Optionally, specifies a loss override which can be useful when using a backward step only. |
| bAllowSnapshot | Optionally, specifies whether or not a snapshot is allowed even during TRAIN_STEP. |
| double MyCaffe.solvers.Solver< T >.TestAll | ( | int | nIterationOverride = -1 | ) |
Run a TestAll by running all test Nets.
Depending on the eval_type tests are run as Test (default), TestClassification (for SSD Classification), or TestDetection (for SSD Detection).
| nIterationOverride | Specifies an override to the iterations to run. |
| double MyCaffe.solvers.Solver< T >.TestClassification | ( | int | nIterationOverride = -1, |
| int | nTestNetId = 0 |
||
| ) |
Run a test on a given test Net by running it through its iterations.
| nIterationOverride | Specifies an override the the number of iterations to run. |
| nTestNetId | Specifies the ID of the test Net to run. |
| double MyCaffe.solvers.Solver< T >.TestDetection | ( | int | nIterationOverride = -1, |
| int | nTestNetId = 0 |
||
| ) |
Run an SSD detection test on a given test Net by running it through its iterations.
| nIterationOverride | Specifies an override the the number of iterations to run. |
| nTestNetId | Specifies the ID of the test Net to run. |
| void MyCaffe.solvers.Solver< T >.UpdateSmoothedLoss | ( | double | dfLoss, |
| int | nStartIter, | ||
| int | nAverageLoss = 0 |
||
| ) |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
get |
|
get |
|
get |
|
get |
|
get |
|
get |
|
getset |
|
getset |
|
getset |
When enabled (requires EnableBlobDebugging = true), the detailed Nan (and Infinity) detection is perofmed on each blob when training Net.
IMPORTANT: The use of this setting is only recommended on TCC enabled drivers.
|
getset |
|
getset |
|
getset |
|
getprotected |
|
get |
|
get |
|
get |
|
get |
|
get |
|
getset |
|
get |
|
get |
|
get |
|
get |
|
getset |
|
get |
|
get |
|
getset |
|
get |
|
getset |
|
get |
|
get |
|
getset |
|
get |
|
get |
|
getset |
|
get |
|
getset |
| EventHandler MyCaffe.solvers.Solver< T >.OnAborted |
| EventHandler<CustomForwardBackArgs<T> > MyCaffe.solvers.Solver< T >.OnCustomForwardBack |
| EventHandler<WorkspaceArgs> MyCaffe.solvers.Solver< T >.OnGetWorkspace |
| EventHandler<GradientsReadyArgs> MyCaffe.solvers.Solver< T >.OnGradientsReady |
| EventHandler<WorkspaceArgs> MyCaffe.solvers.Solver< T >.OnSetWorkspace |
| EventHandler<SnapshotArgs> MyCaffe.solvers.Solver< T >.OnSnapshot |
| EventHandler MyCaffe.solvers.Solver< T >.OnStart |
| EventHandler<TestArgs> MyCaffe.solvers.Solver< T >.OnTest |
| EventHandler<TestingIterationArgs<T> > MyCaffe.solvers.Solver< T >.OnTestingIteration |
| EventHandler<TestResultArgs<T> > MyCaffe.solvers.Solver< T >.OnTestResults |
| EventHandler MyCaffe.solvers.Solver< T >.OnTestStart |
| EventHandler<TrainingIterationArgs<T> > MyCaffe.solvers.Solver< T >.OnTrainingIteration |