MyCaffe
1.12.2.41
Deep learning software for Windows C# programmers.
|
The ComputeGraph class provides a simple computation graph of operations used in a forward pass that are stored in an array on each call and then unwound with calls that calculate the gradients on the backward pass. More...
Public Member Functions | |
ComputeGraph (CudaDnn< T > cuda, Log log, int nAxis, bool bNeedsBackprop=true, bool bClipGradients=false, bool bCheckNans=false, bool bAddDebug=false) | |
The constructor. More... | |
void | Dispose () |
Release all resources used. More... | |
void | DebugOp (params Blob< T >[] rgB) |
DebugOp operation places a debug stub in the backpropagation chain for debugging only. More... | |
Blob< T > | Round (Blob< T > b, int nDecimals=6) |
Round operation, rounds the values to the nearest specified decimal. More... | |
Blob< T > | PeekRow (Blob< T > btm, Blob< T > top, int ix) |
PeeKRow operation copies data and diffs from one row from within the bottom matrix and places it in the top vector. More... | |
void | PeekItem (Blob< T > btm, Blob< T > top, int ix) |
PeekItem operation copies a single item from the bottom to the top. More... | |
Blob< T > | CopyToRow (Blob< T > btm, Blob< T > top, int ix, bool bCopyDiff=false) |
CopyToRow operation copies the bottom vector into the top matrix. More... | |
void | CopyToCache (Blob< T > btm, Cache< T > cache) |
CopyToCache operation copies the blob into the cache. More... | |
Blob< T > | tanh (Blob< T > btm, Blob< T > top) |
'tanh' operation runs the tanh on each item in the btm and places the results in the top. More... | |
Blob< T > | sigmoid (Blob< T > btm, Blob< T > top) |
'sigmoid' operation runs the sigmoid on each item in the btm and places the results in the top. More... | |
Blob< T > | eltmul (Blob< T > btm1, Blob< T > btm2, Blob< T > top) |
'elthmul' operation mutliplies each element of the 'btm1' with the 'btm2' and places the results in 'top'. More... | |
Blob< T > | scalemul (Blob< T > btm1, Blob< T > btm2, Blob< T > top, int nIdx=0) |
'scalemul' operation mutliplies each element of the 'btm1' with the first item within 'btm2' and places the results in 'top'. More... | |
Blob< T > | mul (Blob< T > btm1, Blob< T > btm2, Blob< T > top, bool bAccumulateGrad=true) |
'mul' operation performs a blas gemm operation on the 'btm1' matrix with the 'btm2' matrix and places the results in 'top'. More... | |
Blob< T > | add (Blob< T > btm1, Blob< T > btm2, Blob< T > top, bool bAccumulateGrad=true) |
'elthmul' operation adds each element of the 'btm1' with the 'btm2' and places the results in 'top'. More... | |
Blob< T > | clear_grad (Blob< T > b) |
'clear_grad' operation only runs on the backward pass and zeros out the gradients on an input. More... | |
void | clear_grad (BlobCollection< T > rg) |
'clear_grad' operation only runs on the backward pass and zeros out the gradients of the inputs. More... | |
Blob< T > | softmax (Blob< T > btm, Blob< T > top) |
'softmax' operation runs the softmax on each item in the btm and places the results in the top. More... | |
void | BackwardOne (int nIdx) |
Runs a backward operation at a given index. More... | |
void | Backward (bool bClear=false) |
Runs a backward operation on all items starting from the last and running through the first. More... | |
void | Clear () |
Clears all backward operations from the list. More... | |
Properties | |
Dictionary< string, Blob< T >[]> | Debug [get] |
Returns a dictionary of Blobs used during each operation, only filled when 'bAddDebug' = true in the constructor. More... | |
string | marker [getset] |
Get/set a string marker added to the debug information and used to indicate where in the code a given operation takes place. More... | |
bool | needs_backprop [getset] |
Get/set whether or not to back propagate. More... | |
int | axis [get] |
Returns the axis on which all operations are performed. More... | |
int | BackwardCount [get] |
Returns the backward operation count. More... | |
The ComputeGraph class provides a simple computation graph of operations used in a forward pass that are stored in an array on each call and then unwound with calls that calculate the gradients on the backward pass.
This class is a re-write of the ComputeGraph originally created by Mohamed Ashmawy in the open-source project mashmawy/Seq2SeqLearn distributed under the MIT license.
T | Specifies the base type. |
Definition at line 21 of file ComputeGraph.cs.
MyCaffe.common.ComputeGraph< T >.ComputeGraph | ( | CudaDnn< T > | cuda, |
Log | log, | ||
int | nAxis, | ||
bool | bNeedsBackprop = true , |
||
bool | bClipGradients = false , |
||
bool | bCheckNans = false , |
||
bool | bAddDebug = false |
||
) |
The constructor.
cuda | Specifies the connection to CUDA. |
log | Specifies the general output log. |
nAxis | Specifies the axis under which to perform all of the actions in the graph. |
bNeedsBackprop | Optionally, specifies whether or not to back propagate (default = true). |
bClipGradients | Optionally, specifies whether or not to clip the gradients (default = false, Debug only). |
bCheckNans | Optionally, specifies whether or not to check for nans (default = false, Debug only). |
bAddDebug | Optionally, specifies to add debug information (default = false, Debug only). |
Definition at line 45 of file ComputeGraph.cs.
Blob< T > MyCaffe.common.ComputeGraph< T >.add | ( | Blob< T > | btm1, |
Blob< T > | btm2, | ||
Blob< T > | top, | ||
bool | bAccumulateGrad = true |
||
) |
'elthmul' operation adds each element of the 'btm1' with the 'btm2' and places the results in 'top'.
btm1 | Specifies the first input. |
btm2 | Specifies the second input. |
top | Specifies the output. |
bAccumulateGrad | Optionally, specifies whether or not to acumulate the gradients (default = true). |
Definition at line 538 of file ComputeGraph.cs.
void MyCaffe.common.ComputeGraph< T >.Backward | ( | bool | bClear = false | ) |
Runs a backward operation on all items starting from the last and running through the first.
bClear | Optionally, specifies to clear the list of operations upon completing (default = false). |
Definition at line 684 of file ComputeGraph.cs.
void MyCaffe.common.ComputeGraph< T >.BackwardOne | ( | int | nIdx | ) |
Runs a backward operation at a given index.
nIdx | Specifies the index of the backward operation to run. |
Definition at line 675 of file ComputeGraph.cs.
void MyCaffe.common.ComputeGraph< T >.Clear | ( | ) |
Clears all backward operations from the list.
Definition at line 698 of file ComputeGraph.cs.
Blob< T > MyCaffe.common.ComputeGraph< T >.clear_grad | ( | Blob< T > | b | ) |
'clear_grad' operation only runs on the backward pass and zeros out the gradients on an input.
b | Specifies the input. |
Definition at line 576 of file ComputeGraph.cs.
void MyCaffe.common.ComputeGraph< T >.clear_grad | ( | BlobCollection< T > | rg | ) |
'clear_grad' operation only runs on the backward pass and zeros out the gradients of the inputs.
rg | Specifies an array of inputs. |
Definition at line 594 of file ComputeGraph.cs.
void MyCaffe.common.ComputeGraph< T >.CopyToCache | ( | Blob< T > | btm, |
Cache< T > | cache | ||
) |
CopyToCache operation copies the blob into the cache.
btm | Specifies the input vector to copy. |
cache | Specifies the cache. |
Definition at line 322 of file ComputeGraph.cs.
Blob< T > MyCaffe.common.ComputeGraph< T >.CopyToRow | ( | Blob< T > | btm, |
Blob< T > | top, | ||
int | ix, | ||
bool | bCopyDiff = false |
||
) |
CopyToRow operation copies the bottom vector into the top matrix.
btm | Specifies the input vector. |
top | Specifies the output matrix. |
ix | Specifies the row into which the data is copied within the top. |
bCopyDiff | Optionally, specifies to copy the diff and the data. |
Definition at line 290 of file ComputeGraph.cs.
void MyCaffe.common.ComputeGraph< T >.DebugOp | ( | params Blob< T >[] | rgB | ) |
DebugOp operation places a debug stub in the backpropagation chain for debugging only.
Definition at line 186 of file ComputeGraph.cs.
void MyCaffe.common.ComputeGraph< T >.Dispose | ( | ) |
Release all resources used.
Definition at line 60 of file ComputeGraph.cs.
Blob< T > MyCaffe.common.ComputeGraph< T >.eltmul | ( | Blob< T > | btm1, |
Blob< T > | btm2, | ||
Blob< T > | top | ||
) |
'elthmul' operation mutliplies each element of the 'btm1' with the 'btm2' and places the results in 'top'.
btm1 | Specifies the first input. |
btm2 | Specifies the second input. |
top | Specifies the output. |
Definition at line 412 of file ComputeGraph.cs.
Blob< T > MyCaffe.common.ComputeGraph< T >.mul | ( | Blob< T > | btm1, |
Blob< T > | btm2, | ||
Blob< T > | top, | ||
bool | bAccumulateGrad = true |
||
) |
'mul' operation performs a blas gemm operation on the 'btm1' matrix with the 'btm2' matrix and places the results in 'top'.
btm1 | Specifies the first input. |
btm2 | Specifies the second input. |
top | Specifies the output. |
bAccumulateGrad | Optionally, specifies to accumulate the gradient (default = true). |
Definition at line 494 of file ComputeGraph.cs.
void MyCaffe.common.ComputeGraph< T >.PeekItem | ( | Blob< T > | btm, |
Blob< T > | top, | ||
int | ix | ||
) |
PeekItem operation copies a single item from the bottom to the top.
btm | Specifies the input vector. |
top | Specifies the output matrix. |
ix | Specifies the row into which the data is copied within the top. |
Definition at line 264 of file ComputeGraph.cs.
Blob< T > MyCaffe.common.ComputeGraph< T >.PeekRow | ( | Blob< T > | btm, |
Blob< T > | top, | ||
int | ix | ||
) |
PeeKRow operation copies data and diffs from one row from within the bottom matrix and places it in the top vector.
btm | Specifies the input matrix. |
top | Specifies the output vector. |
ix | Specifies the row within the input matrix to copy. |
Definition at line 232 of file ComputeGraph.cs.
Blob< T > MyCaffe.common.ComputeGraph< T >.Round | ( | Blob< T > | b, |
int | nDecimals = 6 |
||
) |
Round operation, rounds the values to the nearest specified decimal.
b | Specifies the blob to round. |
nDecimals | Optionally, specifies the decimals (defautl = 6). |
Definition at line 209 of file ComputeGraph.cs.
Blob< T > MyCaffe.common.ComputeGraph< T >.scalemul | ( | Blob< T > | btm1, |
Blob< T > | btm2, | ||
Blob< T > | top, | ||
int | nIdx = 0 |
||
) |
'scalemul' operation mutliplies each element of the 'btm1' with the first item within 'btm2' and places the results in 'top'.
btm1 | Specifies the first input. |
btm2 | Specifies the second input. |
top | Specifies the output. |
nIdx | Specifies the index of btm2 to use for scaling. |
Definition at line 451 of file ComputeGraph.cs.
Blob< T > MyCaffe.common.ComputeGraph< T >.sigmoid | ( | Blob< T > | btm, |
Blob< T > | top | ||
) |
'sigmoid' operation runs the sigmoid on each item in the btm and places the results in the top.
btm | Specifies the input data. |
top | Specifies the output data. |
Definition at line 377 of file ComputeGraph.cs.
Blob< T > MyCaffe.common.ComputeGraph< T >.softmax | ( | Blob< T > | btm, |
Blob< T > | top | ||
) |
'softmax' operation runs the softmax on each item in the btm and places the results in the top.
btm | Specifies the input data. |
top | Specifies the output data. |
Definition at line 608 of file ComputeGraph.cs.
Blob< T > MyCaffe.common.ComputeGraph< T >.tanh | ( | Blob< T > | btm, |
Blob< T > | top | ||
) |
'tanh' operation runs the tanh on each item in the btm and places the results in the top.
btm | Specifies the input data. |
top | Specifies the output data. |
Definition at line 343 of file ComputeGraph.cs.
|
get |
Returns the axis on which all operations are performed.
Definition at line 104 of file ComputeGraph.cs.
|
get |
Returns the backward operation count.
Definition at line 666 of file ComputeGraph.cs.
|
get |
Returns a dictionary of Blobs used during each operation, only filled when 'bAddDebug' = true in the constructor.
Definition at line 78 of file ComputeGraph.cs.
|
getset |
Get/set a string marker added to the debug information and used to indicate where in the code a given operation takes place.
Definition at line 86 of file ComputeGraph.cs.
|
getset |
Get/set whether or not to back propagate.
Definition at line 95 of file ComputeGraph.cs.