MPSCNNSpatialNormalizationGradient(3) | MetalPerformanceShaders.framework | MPSCNNSpatialNormalizationGradient(3) |
MPSCNNSpatialNormalizationGradient
#import <MPSCNNNormalization.h>
Inherits MPSCNNGradientKernel.
(nonnull instancetype) -
initWithDevice:kernelWidth:kernelHeight:
(nullable instancetype) - initWithCoder:device:
float alpha
float beta
float delta
This depends on Metal.framework Specifies the spatial normalization gradient filter. The spatial normalization for a feature channel applies the filter over local regions which extend spatially, but are in separate feature channels (i.e., they have shape 1 x kernelWidth x kernelHeight). For each feature channel, the function computes the sum of squares of X inside each rectangle, N2(i,j). It then divides each element of X as follows: Y(i,j) = X(i,j) / (delta + alpha/(kw*kh) * N2(i,j))^beta, where kw and kh are the kernelWidth and the kernelHeight. It is the end-users responsibility to ensure that the combination of the parameters delta and alpha does not result in a situation where the denominator becomes zero - in such situations the resulting pixel-value is undefined.
T(i,j) = (delta + alpha/(kw*kh) * N2(i,j)) N = kw * kh
OutputGradient: dZ/dX(i,j) = T(i,j)^(-beta) * ( dZ/dY(i,j) - (2*alpha*beta*X(i,j)/T(i,j)) * (sum_{l,k in L(i),K(j)} dZ/dY(l,k)*X(l,k)) ) N is the kernel size. The window R(k) itself is defined as: L(i) = [i-floor((kw-1)/2), i+floor(kw/2] K(j) = [j-floor((kh-1)/2), j+floor(kh/2]
For correct gradient computation all parameters must be the same as the original normalization filter.
NSSecureCoding compatability While the standard NSSecureCoding/NSCoding method -initWithCoder: should work, since the file can't know which device your data is allocated on, we have to guess and may guess incorrectly. To avoid that problem, use initWithCoder:device instead.
Parameters:
Returns:
Reimplemented from MPSCNNGradientKernel.
Initialize a spatial normalization filter
Parameters:
Returns:
NOTE: For now, kernelWidth must be equal to kernelHeight
The value of alpha. Default is 1.0. Must be non-negative.
The value of beta. Default is 5.0
The value of delta. Default is 1.0
Generated automatically by Doxygen for MetalPerformanceShaders.framework from the source code.
Mon Jul 9 2018 | Version MetalPerformanceShaders-119.3 |