MPSCNNPoolingMaxGradient(3) | MetalPerformanceShaders.framework | MPSCNNPoolingMaxGradient(3) |
MPSCNNPoolingMaxGradient
#import <MPSCNNPooling.h>
Inherits MPSCNNPoolingGradient.
(nonnull instancetype) -
initWithDevice:kernelWidth:kernelHeight:strideInPixelsX:strideInPixelsY:
(nullable instancetype) - initWithCoder:device:
This depends on Metal.framework Specifies the filter for computing the gradient of the max pooling filter. The operation backpropagates a gradient vector using chain rule.
Dilated Max pooling forward pass is defined as:
out(x) = max_{dx in Window(x)} in(s*x+D*dx), where
the pooling window definition 'Window(x)' follows MPSCNNPooling specification, 's' is the pixel stride and in() is the source input image and D is the dilation factor. For MPSCNNPoolingMaxGradient the dilationRate 'D' is one. NOTE: For even-sized pooling windows with dilation rate greater than one the effective pooling window is centered around s*x with non-even windows leaning towards top-left corner. For example if kernel width = 2, dilation rate = 3, then the pooling considers positions '-2' and '+1' relative to the pooling window center 's*x'.
Hence the partial derivative of the output value wrt. to the input value needed in the gradient backpropagation in MPSCNNPoolingGradient is:
d out(x)/d in(y) = delta_{x_m, y}, where
delta_{x,y} is the Kronecker delta symbol (see MPSCNNPoolingAverageGradient) and x_m is the index of the maximum value in the corresponding pooling window.
In practice this means that the gradient value for the destination image at pixel 'x' is the sum over these contributions coming from all pooling windows that contribute to the max pooling computation in the forward pass, multiplied by the input gradient value in the source area of the corresponding pooling window. If there are multiple maximal values within a single pooling window one of them is picked for the gradient and this decision is implementation specific, which means that it can vary between different architectures and even between different filter parameters.
Note: The gradient max pooling needs the secondary input image in order to compute the indices of maximal values for each pooling window, but this means redundant computations. Later we may add encode calls to MPSCNNPoolingMax that produce a state that contains the coordinates of the maximal values to be consumed by the gradient filters.
NSSecureCoding compatability See MPSKernel::initWithCoder.
Parameters:
Returns:
Reimplemented from MPSCNNPoolingGradient.
Initialize a gradient max pooling filter
Parameters:
Returns:
Reimplemented from MPSCNNPoolingGradient.
Generated automatically by Doxygen for MetalPerformanceShaders.framework from the source code.
Mon Jul 9 2018 | Version MetalPerformanceShaders-119.3 |