Caffe
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
caffe::DataTransformer< Dtype > Class Template Reference

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

#include <data_transformer.hpp>

Public Member Functions

 DataTransformer (const TransformationParameter &param, Phase phase)
 
void InitRand ()
 Initialize the Random number generations if needed by the transformation.
 
void Transform (const Datum &datum, Blob< Dtype > *transformed_blob)
 Applies the transformation defined in the data layer's transform_param block to the data. More...
 
void Transform (const vector< Datum > &datum_vector, Blob< Dtype > *transformed_blob)
 Applies the transformation defined in the data layer's transform_param block to a vector of Datum. More...
 
void Transform (Blob< Dtype > *input_blob, Blob< Dtype > *transformed_blob)
 Applies the same transformation defined in the data layer's transform_param block to all the num images in a input_blob. More...
 
vector< int > InferBlobShape (const Datum &datum)
 Infers the shape of transformed_blob will have when the transformation is applied to the data. More...
 
vector< int > InferBlobShape (const vector< Datum > &datum_vector)
 Infers the shape of transformed_blob will have when the transformation is applied to the data. It uses the first element to infer the shape of the blob. More...
 

Protected Member Functions

virtual int Rand (int n)
 Infers the shape of transformed_blob will have when the transformation is applied to the data. It uses the first element to infer the shape of the blob. More...
 
void Transform (const Datum &datum, Dtype *transformed_data)
 

Protected Attributes

TransformationParameter param_
 
shared_ptr< Caffe::RNGrng_
 
Phase phase_
 
Blob< Dtype > data_mean_
 
vector< Dtype > mean_values_
 

Detailed Description

template<typename Dtype>
class caffe::DataTransformer< Dtype >

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

Member Function Documentation

◆ InferBlobShape() [1/2]

template<typename Dtype >
vector< int > caffe::DataTransformer< Dtype >::InferBlobShape ( const Datum &  datum)

Infers the shape of transformed_blob will have when the transformation is applied to the data.

Parameters
datumDatum containing the data to be transformed.

◆ InferBlobShape() [2/2]

template<typename Dtype >
vector< int > caffe::DataTransformer< Dtype >::InferBlobShape ( const vector< Datum > &  datum_vector)

Infers the shape of transformed_blob will have when the transformation is applied to the data. It uses the first element to infer the shape of the blob.

Parameters
datum_vectorA vector of Datum containing the data to be transformed.

◆ Rand()

template<typename Dtype >
int caffe::DataTransformer< Dtype >::Rand ( int  n)
protectedvirtual

Infers the shape of transformed_blob will have when the transformation is applied to the data. It uses the first element to infer the shape of the blob.

Parameters
mat_vectorA vector of Mat containing the data to be transformed. Generates a random integer from Uniform({0, 1, ..., n-1}).
nThe upperbound (exclusive) value of the random number.
Returns
A uniformly random integer value from ({0, 1, ..., n-1}).

◆ Transform() [1/3]

template<typename Dtype >
void caffe::DataTransformer< Dtype >::Transform ( const Datum &  datum,
Blob< Dtype > *  transformed_blob 
)

Applies the transformation defined in the data layer's transform_param block to the data.

Parameters
datumDatum containing the data to be transformed.
transformed_blobThis is destination blob. It can be part of top blob's data if set_cpu_data() is used. See data_layer.cpp for an example.

◆ Transform() [2/3]

template<typename Dtype >
void caffe::DataTransformer< Dtype >::Transform ( const vector< Datum > &  datum_vector,
Blob< Dtype > *  transformed_blob 
)

Applies the transformation defined in the data layer's transform_param block to a vector of Datum.

Parameters
datum_vectorA vector of Datum containing the data to be transformed.
transformed_blobThis is destination blob. It can be part of top blob's data if set_cpu_data() is used. See memory_layer.cpp for an example.

◆ Transform() [3/3]

template<typename Dtype >
void caffe::DataTransformer< Dtype >::Transform ( Blob< Dtype > *  input_blob,
Blob< Dtype > *  transformed_blob 
)

Applies the same transformation defined in the data layer's transform_param block to all the num images in a input_blob.

Parameters
input_blobA Blob containing the data to be transformed. It applies the same transformation to all the num images in the blob.
transformed_blobThis is destination blob, it will contain as many images as the input blob. It can be part of top blob's data.

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