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

The BlobCollection contains a list of Blobs. More...

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

Public Member Functions

 BlobCollection ()
 The BlobCollection constructor. More...
 
Blob< T > FindBlob (string strName)
 Finds a given blob in the collection based on its name. More...
 
void Insert (int nIdx, Blob< T > b)
 Insert a blob at the given index. More...
 
void Add (Blob< T > b)
 Add a new Blob to the collection. More...
 
void Add (BlobCollection< T > rg)
 Add another BlobCollection to this one. More...
 
bool Remove (Blob< T > b)
 If it exists, remove a Blob from the collection. More...
 
void RemoveAt (int nIdx)
 Remove a Blob at a given index in the collection. More...
 
void Clear (bool bDispose=false)
 Remove all items from the collection. More...
 
bool Contains (Blob< T > blob)
 Returns whether or not the collection contains a given blob. More...
 
BlobCollection< T > FindRelatedBlobs (Blob< T > b)
 Find all Blobs in the collection that contain (in part or in whole) the name of a given Blob. More...
 
IEnumerator< Blob< T > > GetEnumerator ()
 Get the enumerator for the collection. More...
 
BlobCollection< T > Clone ()
 Copy the collection and return it as a new collection. More...
 
void ReshapeLike (BlobCollection< T > src)
 Reshapes all blobs in the collection to the sizes of the source. More...
 
void ReshapeLike (Blob< T > blob)
 Reshapes all blobs in the collection to the sizes of the source. More...
 
void Reshape (int[] rgShape)
 Reshapes all blobs in the collection to the given shape. More...
 
void Reshape (int nN, int nC, int nH, int nW)
 Reshapes all blobs in the collection to the given shape. More...
 
void CopyFrom (BlobCollection< T > bSrc, bool bCopyDiff=false)
 Copy the data or diff from another BlobCollection into this one. More...
 
void Accumulate (CudaDnn< T > cuda, BlobCollection< T > src, bool bAccumulateDiff)
 Accumulate the diffs from one BlobCollection into another. More...
 
void SetDiff (double df)
 Set all blob diff to the value specified. More...
 
void SetData (double df)
 Set all blob data to the value specified. More...
 
BlobCollection< T > MathSub (BlobCollection< T > col, bool bSkipFirstItem)
 Create a new collection of cloned Blobs created by calling MathSub to subtract the Blobs in this collection from another collection. More...
 
BlobCollection< T > MathAdd (BlobCollection< T > colA, double dfScale, bool bSkipFirstItem)
 Create a new collection of cloned Blobs created by calling MathAdd to add the Blobs in this collection to another collection. More...
 
BlobCollection< T > MathDiv (double dfVal, bool bSkipFirstItem)
 Create a new collection of cloned Blobs created by calling MathDif to divide the Blobs in this collection with a scalar. More...
 
void Save (BinaryWriter bw, bool bData, bool bDiff)
 Save the collection to a binary writer. More...
 
bool Share (Blob< T > b, List< int > rgMinShape, bool bThrowExceptions, bool bAllowEndsWith=false)
 Share the first Blob found with the same name as the given Blob. More...
 
bool SnapshotRequested (bool bReset)
 Returns whether or not any blobs have a snapshot request set to true. More...
 
Dictionary< string, Tuple< double, double, double, double > > CollectMinMax (Blob< T > blobWork, bool bDiff=false)
 Collect all min/max, inf and nan values from all Blobs in the collection. More...
 
void Dispose ()
 Release all resource used by the collection and its Blobs. More...
 

Static Public Member Functions

static BlobCollection< T > Load (CudaDnn< T > cuda, Log log, BinaryReader br, bool bData, bool bDiff)
 Loads a new collection from a binary reader. More...
 

Properties

int Count [get]
 Returns the number of items in the collection. More...
 
Blob< T > this[int nIdx] [getset]
 Get/set an item within the collection at a given index. More...
 
Blob< T > this[string strName] [get]
 Get the item with the specified name, or throw an exception if not found. More...
 

Detailed Description

The BlobCollection contains a list of Blobs.

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

Definition at line 15 of file BlobCollection.cs.

Constructor & Destructor Documentation

◆ BlobCollection()

The BlobCollection constructor.

Definition at line 22 of file BlobCollection.cs.

Member Function Documentation

◆ Accumulate()

void MyCaffe.common.BlobCollection< T >.Accumulate ( CudaDnn< T >  cuda,
BlobCollection< T >  src,
bool  bAccumulateDiff 
)

Accumulate the diffs from one BlobCollection into another.

Parameters
cudaSpecifies the CudaDnn instance used to add the blobs into this collection.
srcSpecifies the source BlobCollection to add into this one.
bAccumulateDiffSpecifies to accumulate diffs when true, and the data otherwise.

Definition at line 283 of file BlobCollection.cs.

◆ Add() [1/2]

void MyCaffe.common.BlobCollection< T >.Add ( Blob< T >  b)

Add a new Blob to the collection.

Parameters
bSpecifies the Blob to add.

Definition at line 92 of file BlobCollection.cs.

◆ Add() [2/2]

void MyCaffe.common.BlobCollection< T >.Add ( BlobCollection< T >  rg)

Add another BlobCollection to this one.

Parameters
rgSpecifies the blob collection to add.

Definition at line 101 of file BlobCollection.cs.

◆ Clear()

void MyCaffe.common.BlobCollection< T >.Clear ( bool  bDispose = false)

Remove all items from the collection.

Parameters
bDisposeOptionally, call Dispose on each item removed.

Definition at line 135 of file BlobCollection.cs.

◆ Clone()

Copy the collection and return it as a new collection.

Returns
The new collection is returned.

Definition at line 198 of file BlobCollection.cs.

◆ CollectMinMax()

Dictionary< string, Tuple< double, double, double, double > > MyCaffe.common.BlobCollection< T >.CollectMinMax ( Blob< T >  blobWork,
bool  bDiff = false 
)

Collect all min/max, inf and nan values from all Blobs in the collection.

Parameters
blobWorkSpecifies a work blob.
bDiffSpecifies to collect the values on the diff (true) vs. the data (false).
Returns
A dictionary of the values with associated blob names is returned.

Definition at line 513 of file BlobCollection.cs.

◆ Contains()

bool MyCaffe.common.BlobCollection< T >.Contains ( Blob< T >  blob)

Returns whether or not the collection contains a given blob.

Parameters
blobSpecifies the blob to look for.
Returns
If the blob is in the collection, true is returned, otherwise false is returned.

Definition at line 153 of file BlobCollection.cs.

◆ CopyFrom()

void MyCaffe.common.BlobCollection< T >.CopyFrom ( BlobCollection< T >  bSrc,
bool  bCopyDiff = false 
)

Copy the data or diff from another BlobCollection into this one.

Parameters
bSrcSpecifies the src BlobCollection to copy.
bCopyDiffOptionally, specifies to copy the diff instead of the data (default = false).

Definition at line 266 of file BlobCollection.cs.

◆ Dispose()

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

Release all resource used by the collection and its Blobs.

Definition at line 542 of file BlobCollection.cs.

◆ FindBlob()

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

Finds a given blob in the collection based on its name.

Parameters
strNameSpecifies the name of the blob to find.
Returns
If found, the blob is returned, othweriwse null is returned.

Definition at line 67 of file BlobCollection.cs.

◆ FindRelatedBlobs()

BlobCollection< T > MyCaffe.common.BlobCollection< T >.FindRelatedBlobs ( Blob< T >  b)

Find all Blobs in the collection that contain (in part or in whole) the name of a given Blob.

Parameters
bSpecifies the Blob to look for.
Returns
A new collection of all Blobs that match are returned.

Definition at line 163 of file BlobCollection.cs.

◆ GetEnumerator()

IEnumerator< Blob< T > > MyCaffe.common.BlobCollection< T >.GetEnumerator ( )

Get the enumerator for the collection.

Returns
The enumerator is returned.

Definition at line 180 of file BlobCollection.cs.

◆ Insert()

void MyCaffe.common.BlobCollection< T >.Insert ( int  nIdx,
Blob< T >  b 
)

Insert a blob at the given index.

Parameters
nIdxSpecifies the index where the blob should be added.
bSpecifies the blob to add.

Definition at line 83 of file BlobCollection.cs.

◆ Load()

static BlobCollection< T > MyCaffe.common.BlobCollection< T >.Load ( CudaDnn< T >  cuda,
Log  log,
BinaryReader  br,
bool  bData,
bool  bDiff 
)
static

Loads a new collection from a binary reader.

Parameters
cudaSpecifies the instance of CudaDnn to use for the Cuda connection.
logSpecifies the Log to use for output.
brSpecifies the binary reader.
bDataSpecifies whether or not to read the data.
bDiffSpecifies whether or not to read the diff.
Returns

Definition at line 428 of file BlobCollection.cs.

◆ MathAdd()

BlobCollection< T > MyCaffe.common.BlobCollection< T >.MathAdd ( BlobCollection< T >  colA,
double  dfScale,
bool  bSkipFirstItem 
)

Create a new collection of cloned Blobs created by calling MathAdd to add the Blobs in this collection to another collection.

Calculation: Y = Clone(colA) * dfScale + this

Parameters
colASpecifies the collection that will be cloned.
dfScaleSpecifies the scale that will be applied to the clone of this collection
bSkipFirstItemSpecifies whether or not to skip the first item.
Returns

Definition at line 366 of file BlobCollection.cs.

◆ MathDiv()

BlobCollection< T > MyCaffe.common.BlobCollection< T >.MathDiv ( double  dfVal,
bool  bSkipFirstItem 
)

Create a new collection of cloned Blobs created by calling MathDif to divide the Blobs in this collection with a scalar.

Parameters
dfValSpecifies the divisor.
bSkipFirstItemSpecifies whether or not to skip the first item.
Returns

Definition at line 389 of file BlobCollection.cs.

◆ MathSub()

BlobCollection< T > MyCaffe.common.BlobCollection< T >.MathSub ( BlobCollection< T >  col,
bool  bSkipFirstItem 
)

Create a new collection of cloned Blobs created by calling MathSub to subtract the Blobs in this collection from another collection.

Calculation: Y = Clone(colA) - this

Parameters
colSpecifies the collection that this collection will be subtracted from.
bSkipFirstItemSpecifies whether or not to skip the first item.
Returns

Definition at line 340 of file BlobCollection.cs.

◆ Remove()

bool MyCaffe.common.BlobCollection< T >.Remove ( Blob< T >  b)

If it exists, remove a Blob from the collection.

Parameters
bSpecifies the Blob.
Returns
If the Blob is found and removed, true is returned, otherwise false is returned.

Definition at line 117 of file BlobCollection.cs.

◆ RemoveAt()

void MyCaffe.common.BlobCollection< T >.RemoveAt ( int  nIdx)

Remove a Blob at a given index in the collection.

Parameters
nIdxSpecifies the index.

Definition at line 126 of file BlobCollection.cs.

◆ Reshape() [1/2]

void MyCaffe.common.BlobCollection< T >.Reshape ( int  nN,
int  nC,
int  nH,
int  nW 
)

Reshapes all blobs in the collection to the given shape.

Parameters
nNSpecifies the number of items.
nCSpecifies the number of channels.
nHSpecifies the spatial height.
nWSpecifies the spatial width.

Definition at line 253 of file BlobCollection.cs.

◆ Reshape() [2/2]

void MyCaffe.common.BlobCollection< T >.Reshape ( int[]  rgShape)

Reshapes all blobs in the collection to the given shape.

Parameters
rgShapeSpecifies the shape to use.

Definition at line 238 of file BlobCollection.cs.

◆ ReshapeLike() [1/2]

void MyCaffe.common.BlobCollection< T >.ReshapeLike ( Blob< T >  blob)

Reshapes all blobs in the collection to the sizes of the source.

Parameters
blobSpecifies the source blob.

Definition at line 226 of file BlobCollection.cs.

◆ ReshapeLike() [2/2]

void MyCaffe.common.BlobCollection< T >.ReshapeLike ( BlobCollection< T >  src)

Reshapes all blobs in the collection to the sizes of the source.

Parameters
srcSpecifies the source collection to reshape to.

Definition at line 214 of file BlobCollection.cs.

◆ Save()

void MyCaffe.common.BlobCollection< T >.Save ( BinaryWriter  bw,
bool  bData,
bool  bDiff 
)

Save the collection to a binary writer.

Parameters
bwSpecifies the binary writer.
bDataSpecifies whether or not to save the data.
bDiffSpecifies whether or not to save the diff.

Definition at line 409 of file BlobCollection.cs.

◆ SetData()

void MyCaffe.common.BlobCollection< T >.SetData ( double  df)

Set all blob data to the value specified.

Parameters
dfSpecifies the value to set all blob data to.

Definition at line 323 of file BlobCollection.cs.

◆ SetDiff()

void MyCaffe.common.BlobCollection< T >.SetDiff ( double  df)

Set all blob diff to the value specified.

Parameters
dfSpecifies the value to set all blob diff to.

Definition at line 311 of file BlobCollection.cs.

◆ Share()

bool MyCaffe.common.BlobCollection< T >.Share ( Blob< T >  b,
List< int >  rgMinShape,
bool  bThrowExceptions,
bool  bAllowEndsWith = false 
)

Share the first Blob found with the same name as the given Blob.

Parameters
bSpecifies the Blob that will share the found Blob.
rgMinShapeSpecifies the minimum shape required to share.
bThrowExceptionsSpecifies whether or not th throw an Exception if the sizes do not match.
bAllowEndsWithOptionally, allow name comparison where the share blob name ends with the 'b' blob name (default = false).
Returns

Definition at line 449 of file BlobCollection.cs.

◆ SnapshotRequested()

bool MyCaffe.common.BlobCollection< T >.SnapshotRequested ( bool  bReset)

Returns whether or not any blobs have a snapshot request set to true.

Returns
If any blob in the colleciton has their snapshot request set to true, then true is returned.

Definition at line 489 of file BlobCollection.cs.

Property Documentation

◆ Count

int MyCaffe.common.BlobCollection< T >.Count
get

Returns the number of items in the collection.

Definition at line 29 of file BlobCollection.cs.

◆ this[int nIdx]

Blob<T> MyCaffe.common.BlobCollection< T >.this[int nIdx]
getset

Get/set an item within the collection at a given index.

Parameters
nIdxSpecifies the index of the item to access.
Returns
The item at the index is returned.

Definition at line 39 of file BlobCollection.cs.

◆ this[string strName]

Blob<T> MyCaffe.common.BlobCollection< T >.this[string strName]
get

Get the item with the specified name, or throw an exception if not found.

Parameters
strNameSpecifies the name of the blob to find.
Returns
The blob with the matching name is returned.

Definition at line 50 of file BlobCollection.cs.


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