.TH "MPSCNNBatchNormalizationStatisticsGradient" 3 "Mon Jul 9 2018" "Version MetalPerformanceShaders-119.3" "MetalPerformanceShaders.framework" \" -*- nroff -*- .ad l .nh .SH NAME MPSCNNBatchNormalizationStatisticsGradient .SH SYNOPSIS .br .PP .PP \fC#import \fP .PP Inherits \fBMPSCNNGradientKernel\fP\&. .SS "Instance Methods" .in +1c .ti -1c .RI "(nonnull instancetype) \- \fBinitWithDevice:fusedNeuronDescriptor:\fP" .br .ti -1c .RI "(nullable instancetype) \- \fBinitWithCoder:device:\fP" .br .ti -1c .RI "(void) \- \fBencodeBatchToCommandBuffer:sourceGradients:sourceImages:batchNormalizationState:\fP" .br .ti -1c .RI "(\fBMPSImage\fP *__nonnull) \- \fBencodeToCommandBuffer:sourceGradient:sourceImage:gradientState:\fP" .br .ti -1c .RI "(void) \- \fBencodeToCommandBuffer:sourceGradient:sourceImage:gradientState:destinationGradient:\fP" .br .ti -1c .RI "(\fBMPSImageBatch\fP *__nonnull) \- \fBencodeBatchToCommandBuffer:sourceGradients:sourceImages:gradientStates:\fP" .br .ti -1c .RI "(void) \- \fBencodeBatchToCommandBuffer:sourceGradients:sourceImages:gradientStates:destinationGradients:\fP" .br .in -1c .SS "Additional Inherited Members" .SH "Detailed Description" .PP This depends on Metal\&.framework \fBMPSCNNBatchNormalizationStatisticsGradient\fP updates a \fBMPSCNNBatchNormalizationState\fP with the gradient of the loss function with respect to the batch statistics and batch normalization weights used to perform a batch normalization\&. .SH "Method Documentation" .PP .SS "\- (void) encodeBatchToCommandBuffer: (nonnull id< MTLCommandBuffer >) commandBuffer(\fBMPSImageBatch\fP *__nonnull) sourceGradients(\fBMPSImageBatch\fP *__nonnull) sourceImages(\fBMPSCNNBatchNormalizationState\fP *__nonnull) batchNormalizationState" Encode this operation to a command buffer\&. .PP \fBParameters:\fP .RS 4 \fIcommandBuffer\fP The command buffer\&. .br \fIsourceGradients\fP An MPSImageBatch containing the gradient of the loss function with respect to the results of batch normalization on the source images\&. .br \fIsourceImages\fP An MPSImageBatch containing the source images for batch normalization\&. .br \fIbatchNormalizationState\fP \fBA\fP valid \fBMPSCNNBatchNormalizationState\fP object which has been previously updated using a \fBMPSCNNBatchNormalizationStatistics\fP kernel and the source images\&. Upon completion of the command buffer, will contain the (possibly partially updated) gradients for the loss function with respect to the scale and bias parameters used to compute the batch normalization\&. The state will be considered to be completely updated when all MPSImages in the training batch have been processed\&. If the state is temporary its read count will be decremented\&. .RE .PP .SS "\- (\fBMPSImageBatch\fP*__nonnull) encodeBatchToCommandBuffer: (__nonnull id< MTLCommandBuffer >) commandBuffer(\fBMPSImageBatch\fP *__nonnull) sourceGradients(\fBMPSImageBatch\fP *__nonnull) sourceImages(\fBMPSStateBatch\fP *__nonnull) gradientStates" Encode a gradient filter and return a gradient During training, gradient filters are used to calculate the gradient associated with the loss for each feature channel in the forward pass source image\&. For those nodes that are trainable, these are then used to refine the value used in the trainable parameter\&. They consume a source gradient image which contains the gradients corresponding with the forward pass destination image, and calculate the gradients corresponding to the forward pass source image\&. .PP \fBA\fP gradient filter consumes a \fBMPSNNGradientState\fP object which captured various forward pass properties such as offset and edgeMode at the time the forward pass was encoded\&. These are transferred to the \fBMPSCNNBinaryKernel\fP secondary image properties automatically when this method creates its destination image\&. .PP \fBParameters:\fP .RS 4 \fIcommandBuffer\fP The MTLCommandBuffer on which to encode .br \fIsourceGradients\fP The gradient images from the 'next' filter in the graph .br \fIsourceImages\fP The images used as source image from the forward pass .br \fIgradientStates\fP The \fBMPSNNGradientState\fP or \fBMPSNNBinaryGradientState\fP subclass produced by the forward pass .RE .PP .PP Reimplemented from \fBMPSCNNGradientKernel\fP\&. .SS "\- (void) encodeBatchToCommandBuffer: (__nonnull id< MTLCommandBuffer >) commandBuffer(\fBMPSImageBatch\fP *__nonnull) sourceGradients(\fBMPSImageBatch\fP *__nonnull) sourceImages(\fBMPSStateBatch\fP *__nonnull) gradientStates(\fBMPSImageBatch\fP *__nonnull) destinationGradients" Encode a gradient filter and return a gradient During training, gradient filters are used to calculate the gradient associated with the loss for each feature channel in the forward pass source image\&. For those nodes that are trainable, these are then used to refine the value used in the trainable parameter\&. They consume a source gradient image which contains the gradients corresponding with the forward pass destination image, and calculate the gradients corresponding to the forward pass source image\&. .PP \fBA\fP gradient filter consumes a \fBMPSNNGradientState\fP object which captured various forward pass properties such as offset and edgeMode at the time the forward pass was encoded\&. These are transferred to the \fBMPSCNNBinaryKernel\fP secondary image properties automatically when you use -[\fBMPSCNNGradientKernel\fP destinationImageDescriptorForSourceImages:sourceStates:]\&. If you do not call this method, then you are responsible for configuring all of the primary and secondary image properties in \fBMPSCNNBinaryKernel\fP\&. Please see class description for expected ordering of operations\&. .PP \fBParameters:\fP .RS 4 \fIcommandBuffer\fP The MTLCommandBuffer on which to encode .br \fIsourceGradients\fP The gradient images from the 'next' filter in the graph .br \fIsourceImages\fP The image used as source images from the forward pass .br \fIgradientStates\fP An array of the \fBMPSNNGradientState\fP or \fBMPSNNBinaryGradientState\fP subclass produced by the forward pass .br \fIdestinationGradients\fP The MPSImages into which to write the filter result .RE .PP .PP Reimplemented from \fBMPSCNNGradientKernel\fP\&. .SS "\- (\fBMPSImage\fP*__nonnull) encodeToCommandBuffer: (__nonnull id< MTLCommandBuffer >) commandBuffer(\fBMPSImage\fP *__nonnull) sourceGradient(\fBMPSImage\fP *__nonnull) sourceImage(\fBMPSState\fP *__nonnull) gradientState" Encode a gradient filter and return a gradient During training, gradient filters are used to calculate the gradient associated with the loss for each feature channel in the forward pass source image\&. For those nodes that are trainable, these are then used to refine the value used in the trainable parameter\&. They consume a source gradient image which contains the gradients corresponding with the forward pass destination image, and calculate the gradients corresponding to the forward pass source image\&. .PP \fBA\fP gradient filter consumes a \fBMPSNNGradientState\fP object which captured various forward pass properties such as offset and edgeMode at the time the forward pass was encoded\&. These are transferred to the \fBMPSCNNBinaryKernel\fP secondary image properties automatically when this method creates its destination image\&. .PP \fBParameters:\fP .RS 4 \fIcommandBuffer\fP The MTLCommandBuffer on which to encode .br \fIsourceGradient\fP The gradient image from the 'next' filter in the graph (in the inference direction) .br \fIsourceImage\fP The image used as source image by the forward inference pass .br \fIgradientState\fP The \fBMPSNNGradientState\fP or \fBMPSNNBinaryGradientState\fP subclass produced by the forward inference pass .RE .PP \fBReturns:\fP .RS 4 The result gradient from the gradient filter .RE .PP .PP Reimplemented from \fBMPSCNNGradientKernel\fP\&. .SS "\- (void) encodeToCommandBuffer: (__nonnull id< MTLCommandBuffer >) commandBuffer(\fBMPSImage\fP *__nonnull) sourceGradient(\fBMPSImage\fP *__nonnull) sourceImage(\fBMPSState\fP *__nonnull) gradientState(\fBMPSImage\fP *__nonnull) destinationGradient" Encode a gradient filter and return a gradient During training, gradient filters are used to calculate the gradient associated with the loss for each feature channel in the forward pass source image\&. For those nodes that are trainable, these are then used to refine the value used in the trainable parameter\&. They consume a source gradient image which contains the gradients corresponding with the forward pass destination image, and calculate the gradients corresponding to the forward pass source image\&. .PP \fBA\fP gradient filter consumes a \fBMPSNNGradientState\fP object which captured various forward pass properties such as offset and edgeMode at the time the forward pass was encoded\&. These are transferred to the \fBMPSCNNBinaryKernel\fP secondary image properties automatically when you use -[\fBMPSCNNGradientKernel\fP destinationImageDescriptorForSourceImages:sourceStates:]\&. If you do not call this method, then you are responsible for configuring all of the primary and secondary image properties in \fBMPSCNNBinaryKernel\fP\&. Please see class description for expected ordering of operations\&. .PP \fBParameters:\fP .RS 4 \fIcommandBuffer\fP The MTLCommandBuffer on which to encode .br \fIsourceGradient\fP The gradient image from the 'next' filter in the graph .br \fIsourceImage\fP The image used as source image from the forward pass .br \fIgradientState\fP The \fBMPSNNGradientState\fP and \fBMPSNNBinaryGradientState\fP subclass produced by the forward pass .br \fIdestinationGradient\fP The \fBMPSImage\fP into which to write the filter result .RE .PP .PP Reimplemented from \fBMPSCNNGradientKernel\fP\&. .SS "\- (nullable instancetype) \fBinitWithCoder:\fP (NSCoder *__nonnull) aDecoder(nonnull id< MTLDevice >) device" \fBNSSecureCoding\fP 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 a subclass of NSCoder that implements the protocol to tell MPS the MTLDevice to use\&. .PP \fBParameters:\fP .RS 4 \fIaDecoder\fP The NSCoder subclass with your serialized \fBMPSKernel\fP .br \fIdevice\fP The MTLDevice on which to make the \fBMPSKernel\fP .RE .PP \fBReturns:\fP .RS 4 \fBA\fP new \fBMPSCNNBatchNormalizationStatisticsGradient\fP object, or nil if failure\&. .RE .PP .PP Reimplemented from \fBMPSCNNGradientKernel\fP\&. .SS "\- (nonnull instancetype) \fBinitWithDevice:\fP (nonnull id< MTLDevice >) device(\fBMPSNNNeuronDescriptor\fP *__nullable) fusedNeuronDescriptor" Initializes a batch normalization statistics gradient kernel using a device and neuron descriptor\&. .PP \fBParameters:\fP .RS 4 \fIdevice\fP The MTLDevice on which this filter will be used .br \fIfusedNeuronDescriptor\fP \fBA\fP \fBMPSNNNeuronDescriptor\fP object which specifies a neuron activation function whose gradient should be applied prior to computing the statistics of the input gradient\&. This neuron descriptor should match that used in the corresponding forward batch normalization kernel\&. .RE .PP \fBReturns:\fP .RS 4 \fBA\fP valid \fBMPSCNNBatchNormalizationStatisticsGradient\fP object or nil, if failure\&. .RE .PP .SH "Author" .PP Generated automatically by Doxygen for MetalPerformanceShaders\&.framework from the source code\&.