class nbla::ImageAugmentation

template<typename T>
class ImageAugmentation : public nbla::BaseFunction<const vector<int>&, const vector<int>&, float, float, float, float, float, bool, bool, float, bool, float, float, bool, float, int>

ImageAugmentation randomly alters the input image.

Inputs:

  • N-D array of three or more dimensions

Outputs:

  • N-D array.

Template Parameters:

T – Data type for computation and score variable.

Param shape:

The output image data size.

Param pad:

Border padding values for each spatial axis (height and width). Padding will be added both sides of the dimension.

Param min_scale:

The minimum scale ratio when randomly scaling the image. For example, to scale down to 0.8 times the size of the original image, specify “0.8”. To not apply random scaling, set both min_scale and max_scale to “1.0”.

Param max_scale:

The maximum scale ratio when randomly scaling the image. For example, to scale down to 2 times the size of the original image, specify “2.0”.

Param angle:

The rotation angle range in radians when randomly rotating the image. The image is randomly rotated in the -Angle to +Angle range. For example, to rotate in a +-15 degree range, specify “0.26” (15 degrees/360 degrees * 2PI). To not apply random rotation, specify “0.0”.

Param aspect_ratio:

The aspect ratio range when randomly deforming the image. For example, to deform aspect ratio of image from 1:1.3 to 1.3:1, specify “1.3”. To not apply random deforming, specify “1.0”.

Param distortion:

The distortion range when randomly distorting the image. To not apply distortion, specify “0.0”.

Param flip_lr:

Whether to randomly flip the image horizontally at 50% probability.

Param flip_ud:

Whether to randomly flip the image vertically at 50% probability.

Param brightness:

The range of values to randomly add to the brightness. A random value in the -Brightness to +Brightness range is added to the brightness. For example, to vary the brightness in the -0.05 to +0.05 range, specify “0.05”. To not apply random addition to brightness, specify “0.0”.

Param brightness_each:

Whether to apply the random addition to brightness (as specified by brightness) to each color channel. True: brightness is added based on a different random number for each channel. False: brightness is added based on a random number common to all channels.

Param contrast:

The range in which to randomly very the image contrast. The contrast is varied in the 1/Contrast times to Contrast times range. The output brightness is equal to (input - contrast_center) * contrast + contrast_center. For example, to vary the contrast in the 0.91 times to 1.1 times range, specify “1.1”. To not apply random contrast variation, specify “1.0”.

Param contrast_center:

Intensity center used for applying contrast.

Param contrast_each:

Whether to apply the random contrast variation (as specified by contrast) to each color channel. True: contrast is varied based on a different random number for each channel. False: contrast is varied based on a random number common to all channels.

Param noise:

Sigma of normal random number to be added.

Param seed:

Random seed.

Public Functions

inline virtual shared_ptr<Function> copy() const

Copy another instance of Function with the same context.

inline virtual vector<dtypes> in_types()

Get input dtypes.

Last in_type will be used repeatedly if size of in_types is smaller than size of inputs

inline virtual vector<dtypes> out_types()

Get output dtypes.

Last out_type will be used repeatedly if size of out_types is smaller than size of outputs

inline virtual int min_inputs()

Get minimum number of inputs.

This is meant to be used in setup function with in_types which is used to get maximum number of inputs.

inline virtual int min_outputs()

Get minimum number of outputs.

This is meant to be used in setup function with out_types which is used to get max number of outputs.

inline virtual string name()

Get function name in string.

inline virtual vector<string> allowed_array_classes()

Get array classes that are allowed to be specified by Context.

inline virtual bool need_setup_recompute(int o) const

A flag for checking if setup_recompute() is needed.

Checking if o-th output’ data requires setup_recompute().

Note

setup_recompute() will skipped during forward execution if none of outputs requires setup_recompute().

Parameters:

o[in] Output variable index.

inline virtual bool grad_depends_output_data(int i, int o) const

Dependency flag for checking if in-grad depends on out-data.

Checking if i-th input’ gradient computation requires o-th output’s data or not.

Note

If any of inputs requires an output variable data when computing its gradient, this function must be overridden to return appropriate boolean value. Otherwise, backward computation will be incorrect.

Parameters:
  • i[in] Input variable index.

  • o[in] Output variable index.