({{, (RefLink[ImageAugmentationLayer, paclet:ref/ImageAugmentationLayer])[{h,w}] 
represents a net layer that applies random image transformations to produce images of height h and width w.}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[ImageAugmentationLayer, paclet:ref/ImageAugmentationLayer]) operates on images represented as (Subscript[c, 0])×(Subscript[h, 0])×(Subscript[w, 0]) arrays.

(RefLink[ImageAugmentationLayer, paclet:ref/ImageAugmentationLayer]) does random cropping and other transformations.

(RefLink[ImageAugmentationLayer, paclet:ref/ImageAugmentationLayer])[…][input] explicitly computes the output from applying the layer.

(RefLink[ImageAugmentationLayer, paclet:ref/ImageAugmentationLayer])[…][{(Subscript[input, 1]),(Subscript[input, 2]),…}] explicitly computes outputs for each of the (Subscript[input, i]).

When given a (RefLink[NumericArray, paclet:ref/NumericArray]) as input, the output will be a (RefLink[NumericArray, paclet:ref/NumericArray]).

(RefLink[ImageAugmentationLayer, paclet:ref/ImageAugmentationLayer]) is typically used inside (RefLink[NetChain, paclet:ref/NetChain]), (RefLink[NetGraph, paclet:ref/NetGraph]), etc.

The following optional parameters can be included:

(RefLink[ImageAugmentationLayer, paclet:ref/ImageAugmentationLayer]) exposes the following ports for use in (RefLink[NetGraph, paclet:ref/NetGraph]) etc.:

When it cannot be inferred from other layers in a larger net, the option "Input"->{c,(Subscript[h, 0]),(Subscript[w, 0])} can be used to fix the input dimensions of (RefLink[ImageAugmentationLayer, paclet:ref/ImageAugmentationLayer]).

(RefLink[ImageAugmentationLayer, paclet:ref/ImageAugmentationLayer]) only randomly transforms the input during training. During evaluation, (RefLink[ImageAugmentationLayer, paclet:ref/ImageAugmentationLayer]) resizes the input by taking the center crop, unless (RefLink[NetEvaluationMode, paclet:ref/NetEvaluationMode])->"Train" is specified when applying the layer.

OpenersPrimaryExamplesSection(Spacer1)Examples  (4)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Create an (RefLink[ImageAugmentationLayer, paclet:ref/ImageAugmentationLayer]) whose output dimensions are {n,80,80}:

ImageAugmentationLayer[{80,80}]

Create an (RefLink[ImageAugmentationLayer, paclet:ref/ImageAugmentationLayer]) that takes an image of size 128×128 and returns an image crop of size 80×80:

augment=ImageAugmentationLayer[{80,80},"Input"->NetEncoder[{"Image",{128,128}}],"Output"->NetDecoder["Image"]]

Apply the layer to an image, obtaining the center crop:

augment[]

Apply the layer to an image, specifying that training behavior be used:

augment[,NetEvaluationMode->"Train"]

The layer threads across a batch of examples:

augment[{,}]

OpenersExampleSection1(Spacer1)Options  (1)

OpenersExampleSubsection0(Spacer1)"ReflectionProbabilities"  (1)

Create an (RefLink[ImageAugmentationLayer, paclet:ref/ImageAugmentationLayer]) that randomly reflects an image about the vertical axis with probability 0.9 during training:

augment=ImageAugmentationLayer[{64,64},"Input"->NetEncoder[{"Image",{64,64}}],"Output"->NetDecoder["Image"],"ReflectionProbabilities"-> {0,0.9}]

Apply the layer to an image, using training behavior:

augment[,NetEvaluationMode->"Train"]

OpenersExampleSection2(Spacer1)Possible Issues  (1)

Currently, any randomness invoked by (RefLink[NetEvaluationMode, paclet:ref/NetEvaluationMode])->"Train" is not affected by (RefLink[SeedRandom, paclet:ref/SeedRandom]) and (RefLink[BlockRandom, paclet:ref/BlockRandom]):

augment=ImageAugmentationLayer[{32,32},"Input"->NetEncoder[{"Image",{32,32}}],"Output"->NetDecoder["Image"],"ReflectionProbabilities"-> {0.5,0.5}]

Table[BlockRandom[augment[,NetEvaluationMode->"Train"]],8]

Table[BlockRandom[RandomReal[]],8]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[SpatialTransformationLayer, paclet:ref/SpatialTransformationLayer])  ▪  (RefLink[ConvolutionLayer, paclet:ref/ConvolutionLayer])  ▪  (RefLink[PoolingLayer, paclet:ref/PoolingLayer])  ▪  (RefLink[ResizeLayer, paclet:ref/ResizeLayer])  ▪  (RefLink[NetChain, paclet:ref/NetChain])  ▪  (RefLink[NetGraph, paclet:ref/NetGraph])  ▪  (RefLink[NetTrain, paclet:ref/NetTrain])  ▪  (RefLink[NetEvaluationMode, paclet:ref/NetEvaluationMode])  ▪  (RefLink[ImageTransformation, paclet:ref/ImageTransformation])  ▪  (RefLink[ImageCrop, paclet:ref/ImageCrop])  ▪  (RefLink[ImageReflect, paclet:ref/ImageReflect])  ▪  (RefLink[ImageRotate, paclet:ref/ImageRotate])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Neural Networks in the Wolfram Language, paclet:tutorial/NeuralNetworksOverview])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Neural Networks, paclet:guide/NeuralNetworks])}})}})