MyCaffe  1.11.7.7
Deep learning software for Windows C# programmers.
MyCaffe.data.DataTransformer< T > Class Template Reference

Applies common transformations to the input data, such as scaling, mirroring, subtracting the image mean... More...

Inheritance diagram for MyCaffe.data.DataTransformer< T >:

Public Member Functions

 DataTransformer (CudaDnn< T > cuda, Log log, TransformationParameter p, Phase phase, int nC, int nH, int nW, SimpleDatum imgMean=null)
 The DataTransformer constructor. More...
 
void Dispose ()
 Cleanup all resources used. More...
 
void Update (int nDataSize=0, SimpleDatum imgMean=null)
 Resync the transformer with changes in its parameter. More...
 
List< int > InferBlobShape (SimpleDatum d)
 Infers the shape the transformed blob will have when the transformation is applied to the data. More...
 
int[] InferBlobShape (SimpleDatum d, int[] rgShape)
 Infers the shape the transformed blob will have when the transformation is applied to the data. More...
 
int[] InferBlobShape (List< Datum > rgD, int[] rgShape)
 Infers the shape the transformed blob will have when the transformation is applied to the data. More...
 
List< int > InferBlobShape (int nChannels, int nWidth, int nHeight)
 Infers the shape of the transformed blow will have with the given channel, width and height. More...
 
virtual void InitRand ()
 Initialize the underlying random number generator. More...
 
int TransformLabel (SimpleDatum sd)
 When active (label_mapping.Active = true), transforms the label if mapped using the label and boost. Otherwise if not active or not mapped, no label changes are made. More...
 
void Transform (List< Datum > rgDatum, Blob< T > blobTransformed, CudaDnn< T > cuda, Log log)
 Transforms a list of Datum and places the transformed data into a Blob. More...
 
void Transform (List< SimpleDatum > rgDatum, Blob< T > blobTransformed, CudaDnn< T > cuda, Log log, bool bJustFill=false)
 Transforms a list of Datum and places the transformed data into a Blob. More...
 
void Transform (SimpleDatum[] rgDatum, Blob< T > blobTransformed, CudaDnn< T > cuda, Log log, bool bJustFill=false)
 Transforms a list of Datum and places the transformed data into a Blob. More...
 
AnnotationGroupCollection Transform (SimpleDatum d, Blob< T > blob)
 Transforms a Datum and places the dat ainto a Blob. More...
 
AnnotationGroupCollection Transform (SimpleDatum d, Blob< T > blob, out bool bDoMirror)
 Transforms a Datum and places the dat ainto a Blob. More...
 
T[] Transform (SimpleDatum d, out bool bMirror, NormalizedBBox crop_bbox=null)
 Transform the data into an array of transformed values. More...
 
T[] Transform (SimpleDatum d)
 Transform the data into an array of transformed values. More...
 
T[] Transform (SimpleDatum d, out AnnotationGroupCollection rgTransformedAnnoVec, out bool bMirror, bool bResize=true)
 Transform the data into an array of transformed values. More...
 
AnnotationGroupCollection TransformAnnotation (SimpleDatum d, NormalizedBBox crop_bbox, bool bMirror, bool bResize)
 Transform the annotation data. More...
 
void SetRange (Blob< T > b)
 Scales the data of a Blob to fit in a given range based on the DataTransformers parameters. More...
 
SimpleDatum CropImage (SimpleDatum d, NormalizedBBox bbox)
 Crop the SimpleDatum according to the bbox. More...
 
SimpleDatum ExpandImage (SimpleDatum d, NormalizedBBox expand_bbox, float fExpandRatio)
 Expand the SimpleDatum according to the bbox. More...
 
SimpleDatum ExpandImage (SimpleDatum d)
 Expand the datum and adjust the AnnotationGroup. More...
 
SimpleDatum DistortImage (SimpleDatum d)
 Distort the SimpleDatum. More...
 
void DistortImage (Blob< T > b)
 Distort the images within a Blob. More...
 
SimpleDatum MaskImage (SimpleDatum d)
 Maks out portions of the SimpleDatum. More...
 
float[] MaskData (int[] rgShape, float[] rgData)
 Mask out the data based on the shape of the specified SimpleDatum. More...
 
Datum UnTransform (Blob< T > blob, bool bIncludeMean=true)
 Reverse the transformation made when calling Transform. More...
 

Protected Member Functions

virtual int Rand (int n)
 Generates a random integer from Uniform({0, 1, ..., n-1}). More...
 

Properties

TransformationParameter param [get]
 Returns the TransformationParameter used. More...
 
SimpleDatum ImageMean [getset]
 Get/set the image mean. More...
 
Tuple< double, double > LastRange [get]
 Returns the last min/max observed. More...
 

Detailed Description

Applies common transformations to the input data, such as scaling, mirroring, subtracting the image mean...

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

Definition at line 22 of file DataTransformer.cs.

Constructor & Destructor Documentation

◆ DataTransformer()

MyCaffe.data.DataTransformer< T >.DataTransformer ( CudaDnn< T >  cuda,
Log  log,
TransformationParameter  p,
Phase  phase,
int  nC,
int  nH,
int  nW,
SimpleDatum  imgMean = null 
)

The DataTransformer constructor.

Parameters
cudaSpecifies the connection to the CudaDnn dll which is only needed when using the bbox or image transformation functionality.
logSpecifies the Log used for output.
pSpecifies the TransformationParameter used to create the DataTransformer.
phaseSpecifies the Phase under which the DataTransformer is run.
nCSpecifies the channels.
nHSpecifies the height.
nWSpecifies the width.
imgMeanOptionally, specifies the image mean to use.

Definition at line 53 of file DataTransformer.cs.

Member Function Documentation

◆ CropImage()

Crop the SimpleDatum according to the bbox.

Parameters
dSpecifies the SimpleDatum to crop.
bboxSpecifies the bounding box.
Returns
The cropped SimpleDatum is returned.

Definition at line 1006 of file DataTransformer.cs.

◆ Dispose()

void MyCaffe.data.DataTransformer< T >.Dispose ( )

Cleanup all resources used.

Definition at line 81 of file DataTransformer.cs.

◆ DistortImage() [1/2]

void MyCaffe.data.DataTransformer< T >.DistortImage ( Blob< T >  b)

Distort the images within a Blob.

Parameters
bSpecifies the Blob to distort.

Definition at line 1259 of file DataTransformer.cs.

◆ DistortImage() [2/2]

Distort the SimpleDatum.

Parameters
dSpecifies the SimpleDatum to distort.

Note this function only applies when the distortion parameter 'use_gpu' = false, otherwise the distoration is applied after the data is transferred to the GPU.

Returns
The distorted SimpleDatum is returned.

Definition at line 1239 of file DataTransformer.cs.

◆ ExpandImage() [1/2]

Expand the datum and adjust the AnnotationGroup.

Parameters
dSpecifies the datum to expand.
Returns
The newly expanded datum is returned.

Definition at line 1202 of file DataTransformer.cs.

◆ ExpandImage() [2/2]

SimpleDatum MyCaffe.data.DataTransformer< T >.ExpandImage ( SimpleDatum  d,
NormalizedBBox  expand_bbox,
float  fExpandRatio 
)

Expand the SimpleDatum according to the bbox.

Parameters
dSpecifies the SimpleDatum to expand.
expand_bboxSpecifies the bounding box.
fExpandRatioSpecifies the expansion ratio.
Returns
The expanded SimpleDatum is returned.

Definition at line 1099 of file DataTransformer.cs.

◆ InferBlobShape() [1/4]

List< int > MyCaffe.data.DataTransformer< T >.InferBlobShape ( int  nChannels,
int  nWidth,
int  nHeight 
)

Infers the shape of the transformed blow will have with the given channel, width and height.

Parameters
nChannelsSpecifies the channels.
nWidthSpecifies the width.
nHeightSpecifies the height.
Returns
The inferred blob shape is returned.

Definition at line 296 of file DataTransformer.cs.

◆ InferBlobShape() [2/4]

int[] MyCaffe.data.DataTransformer< T >.InferBlobShape ( List< Datum rgD,
int[]  rgShape 
)

Infers the shape the transformed blob will have when the transformation is applied to the data.

Parameters
rgDA list of data containing the data to be transformed.
rgShapeSpecifies the shape vector.
Returns
The inferred shape.

Use the first datum in the vector to InferBlobShape.

Definition at line 276 of file DataTransformer.cs.

◆ InferBlobShape() [3/4]

List< int > MyCaffe.data.DataTransformer< T >.InferBlobShape ( SimpleDatum  d)

Infers the shape the transformed blob will have when the transformation is applied to the data.

Parameters
dData containing the data to be transformed.
Returns
The inferred shape.

Definition at line 226 of file DataTransformer.cs.

◆ InferBlobShape() [4/4]

int[] MyCaffe.data.DataTransformer< T >.InferBlobShape ( SimpleDatum  d,
int[]  rgShape 
)

Infers the shape the transformed blob will have when the transformation is applied to the data.

Parameters
dData containing the data to be transformed.
rgShapeSpecifies the shape vector to fill.
Returns
The inferred shape.

Definition at line 240 of file DataTransformer.cs.

◆ InitRand()

virtual void MyCaffe.data.DataTransformer< T >.InitRand ( )
virtual

Initialize the underlying random number generator.

Definition at line 323 of file DataTransformer.cs.

◆ MaskData()

float[] MyCaffe.data.DataTransformer< T >.MaskData ( int[]  rgShape,
float[]  rgData 
)

Mask out the data based on the shape of the specified SimpleDatum.

Parameters
rgShapeSpecifies the shape of the data.
rgDataSpecifies the data.
Returns
The newly masked data is returned.

Definition at line 1340 of file DataTransformer.cs.

◆ MaskImage()

Maks out portions of the SimpleDatum.

Parameters
dSpecifies the SimpleDatum to mask.
Returns
The masked SimpleDatum is returned.

Definition at line 1294 of file DataTransformer.cs.

◆ Rand()

virtual int MyCaffe.data.DataTransformer< T >.Rand ( int  n)
protectedvirtual

Generates a random integer from Uniform({0, 1, ..., n-1}).

Parameters
nThe upper bound (exclusive) value of the random number.
Returns
A uniformly random integer value from ({0, 1, ..., n-1}).

Definition at line 336 of file DataTransformer.cs.

◆ SetRange()

void MyCaffe.data.DataTransformer< T >.SetRange ( Blob< T >  b)

Scales the data of a Blob to fit in a given range based on the DataTransformers parameters.

Parameters
b

Definition at line 985 of file DataTransformer.cs.

◆ Transform() [1/8]

void MyCaffe.data.DataTransformer< T >.Transform ( List< Datum rgDatum,
Blob< T >  blobTransformed,
CudaDnn< T >  cuda,
Log  log 
)

Transforms a list of Datum and places the transformed data into a Blob.

Parameters
rgDatumSpecifies a List of Datum to be transformed.
blobTransformedSpecifies the Blob where all transformed data is placed.
cudaSpecifies the CudaDnn connection to Cuda.
logSpecifies a Log for all output.

Definition at line 373 of file DataTransformer.cs.

◆ Transform() [2/8]

void MyCaffe.data.DataTransformer< T >.Transform ( List< SimpleDatum rgDatum,
Blob< T >  blobTransformed,
CudaDnn< T >  cuda,
Log  log,
bool  bJustFill = false 
)

Transforms a list of Datum and places the transformed data into a Blob.

Parameters
rgDatumSpecifies a List of SimpleDatum to be transformed.
blobTransformedSpecifies the Blob where all transformed data is placed.
cudaSpecifies the CudaDnn connection to Cuda.
logSpecifies a Log for all output.
bJustFillOptionally, specifies to just fill the data blob with the data without actually transforming it.

Definition at line 410 of file DataTransformer.cs.

◆ Transform() [3/8]

T[] MyCaffe.data.DataTransformer< T >.Transform ( SimpleDatum  d)

Transform the data into an array of transformed values.

Parameters
dData to transform.
Returns
Transformed data.

Definition at line 873 of file DataTransformer.cs.

◆ Transform() [4/8]

Transforms a Datum and places the dat ainto a Blob.

Parameters
dSpecifies the Datum to transform.
blobSpecifies the Blob where the transformed data is placed.
Returns
When a datum contains annotations, the tranformed annotation groups are returned, otherwise null is returned.

Definition at line 464 of file DataTransformer.cs.

◆ Transform() [5/8]

AnnotationGroupCollection MyCaffe.data.DataTransformer< T >.Transform ( SimpleDatum  d,
Blob< T >  blob,
out bool  bDoMirror 
)

Transforms a Datum and places the dat ainto a Blob.

Parameters
dSpecifies the Datum to transform.
blobSpecifies the Blob where the transformed data is placed.
bDoMirrorReturns whether or not a mirror took place.
Returns
When a datum contains annotations, the tranformed annotation groups are returned, otherwise null is returned.

Definition at line 477 of file DataTransformer.cs.

◆ Transform() [6/8]

T[] MyCaffe.data.DataTransformer< T >.Transform ( SimpleDatum  d,
out AnnotationGroupCollection  rgTransformedAnnoVec,
out bool  bMirror,
bool  bResize = true 
)

Transform the data into an array of transformed values.

Parameters
dData to transform.
rgTransformedAnnoVecReturns the list of transfomed annoations.
bMirrorReturns whether or not a mirror occurred.
bResizeSpecifies to resize the data.
Returns
Transformed data.

Definition at line 887 of file DataTransformer.cs.

◆ Transform() [7/8]

T[] MyCaffe.data.DataTransformer< T >.Transform ( SimpleDatum  d,
out bool  bMirror,
NormalizedBBox  crop_bbox = null 
)

Transform the data into an array of transformed values.

Parameters
dData to transform.
bMirrorReturns whether or not a mirror occurred.
crop_bboxOptionally, specifies a crop bbox to fill out.
Returns
Transformed data.

Definition at line 518 of file DataTransformer.cs.

◆ Transform() [8/8]

void MyCaffe.data.DataTransformer< T >.Transform ( SimpleDatum[]  rgDatum,
Blob< T >  blobTransformed,
CudaDnn< T >  cuda,
Log  log,
bool  bJustFill = false 
)

Transforms a list of Datum and places the transformed data into a Blob.

Parameters
rgDatumSpecifies a Array of SimpleDatum to be transformed.
blobTransformedSpecifies the Blob where all transformed data is placed.
cudaSpecifies the CudaDnn connection to Cuda.
logSpecifies a Log for all output.
bJustFillOptionally, specifies to just fill the data blob with the data without actually transforming it.

Definition at line 423 of file DataTransformer.cs.

◆ TransformAnnotation()

AnnotationGroupCollection MyCaffe.data.DataTransformer< T >.TransformAnnotation ( SimpleDatum  d,
NormalizedBBox  crop_bbox,
bool  bMirror,
bool  bResize 
)

Transform the annotation data.

Parameters
dData to transform.
crop_bboxSpecifies the crop_bbox defined for the data.
bMirrorSpecifies to mirror the data.
bResizeSpecifies to resize the data.
Returns

Definition at line 907 of file DataTransformer.cs.

◆ TransformLabel()

int MyCaffe.data.DataTransformer< T >.TransformLabel ( SimpleDatum  sd)

When active (label_mapping.Active = true), transforms the label if mapped using the label and boost. Otherwise if not active or not mapped, no label changes are made.

Parameters
sdSpecifies the SimpleDatum whos label is to be transformed.
Returns
The new label is returned - this value is also set as the new label for the SimpleDatum.

Definition at line 355 of file DataTransformer.cs.

◆ UnTransform()

Datum MyCaffe.data.DataTransformer< T >.UnTransform ( Blob< T >  blob,
bool  bIncludeMean = true 
)

Reverse the transformation made when calling Transform.

Parameters
blobSpecifies the input blob.
bIncludeMeanSpecifies whether or not to add the mean back.
Returns
The de-processed output Datum is returned.

Definition at line 1379 of file DataTransformer.cs.

◆ Update()

void MyCaffe.data.DataTransformer< T >.Update ( int  nDataSize = 0,
SimpleDatum  imgMean = null 
)

Resync the transformer with changes in its parameter.

Definition at line 93 of file DataTransformer.cs.

Property Documentation

◆ ImageMean

Get/set the image mean.

Definition at line 181 of file DataTransformer.cs.

◆ LastRange

Tuple<double, double> MyCaffe.data.DataTransformer< T >.LastRange
get

Returns the last min/max observed.

Definition at line 344 of file DataTransformer.cs.

◆ param

Returns the TransformationParameter used.

Definition at line 173 of file DataTransformer.cs.


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