Package apple.metalperformanceshaders
Class MPSCNNConvolutionGradient
- java.lang.Object
-
- org.moe.natj.general.NativeObject
-
- org.moe.natj.objc.ObjCObject
-
- apple.NSObject
-
- apple.metalperformanceshaders.MPSKernel
-
- apple.metalperformanceshaders.MPSCNNBinaryKernel
-
- apple.metalperformanceshaders.MPSCNNGradientKernel
-
- apple.metalperformanceshaders.MPSCNNConvolutionGradient
-
- All Implemented Interfaces:
NSCoding,NSCopying,NSSecureCoding,NSObject
- Direct Known Subclasses:
MPSCNNFullyConnectedGradient
public class MPSCNNConvolutionGradient extends MPSCNNGradientKernel
MPSCNNConvolutionGradient [@dependency] This depends on Metal.framework The MPSCNNConvolutionGradient implementents backward propagation of gradient i.e. it computes the gradient of loss function with respect input data of corresonding forward convolution and gradient of loss function with respect to weights and bias of corresponding convolution in forward pass. Gradient with respect to data ============================== Gradient with respect to input data of corresponding forward convolution will be written in destination image passed to encode call of MPSCNNConvolutionGradient. This step is similar to convolution transpose in that the strided convolution in forward pass become zero filled convolution in backward propagation of gradients. The difference between MPSCNNConvolutionTranspose and gradient wrt data is how the weights, that are provided by data source, are interpreted. MPSCNNConvolution and MPSCNNConvolutionTranspose interpret weights provided by data source as weights[outputFeatureChannels][kernelWidth][kernelHeight][inputFeatureChannels] whereas convoution gradient with respect to data interpret the weights as weights[inputFeatureChannels][kernelWidth][kernelHeight][outputFeatureChannels] i.e. weights are transposed in inputFeatureChannels/outputFeatureChannels dimension and also rotated 180 degress in spatial dimension User should use the same data source provider to initialize MPSCNNConvolutionGradient as is used to initialize corresponding forward MPSCNNConvolution. Implementation will do the transposition/shuffling needed. Thus, while the forward MPSCNNConvolution takes sourceImage of inputFeatureChannels and convolves it with Wt[outputFeatureChannels][kernelHeight][kernelWidth][inputFeatureChannels] to produce destinationImage of outputFeatureChannels, MPSConvolutionGradient takes sourceGradient of outputFeatureChannels which is out of previous layer (nomally neuron backward layer), convolves it with transposed and rotated weights and produces destinationGradient of inputFeatureChannels. If the user decide to double buffer data source provider i.e. different data source providers are passed to forward MPSCNNConvolution object and corresponding MPSCNNConvolutionGradient object, it is user responsibility to make sure both data source providers provide same weights/bias data and have same properties in convolution descriptor else behavior is undefined. Gradient with respect to weights and bias ========================================= Gradient with respect to weights and bias are returned in MPSCNNConvolutionGradientState object to be used in weights update functions. If I denotes the input image to corresponding MPSCNNConvolution in forward pass and E denoates the loss gradient from previous layer (normally neuron backward layer) in backward pass, gradient of E with respect to weights is delta_E/delta_Wkpqc = sum_i sum_j [ E(i, j, k) * I( secondaryStrideInPixelX*i + secondaryOffset.x + secondaryDilationRateX*p, secondaryStrideinPixelY*i + secondaryOffset.y + secondaryDilationRateY*q, c) ] where i goes over 0..W-1 and j goes over 0..H-1, (W,H) being width and height of E. p in [0, secondaryKernelWidth-1] q in [0, secondaryKernelHeight-1] c in [0, inputeFeatureChannels/groups - 1] k in [0, outputFeatureChannels] and gradient with respect to bias delta_E/delta_bk = sum_i sum_j [ E(i, j, k) ] These gradients with respect to weights and bias are returned as buffers in MPSCNNConvolutionGradientState object passed in the encode call. These are consumed by MPSCNNConvolution object's -updateWeightsAndBias:MPSCNNConvolutionGradientState* method for CPU side update and encodeWeightsAndBiasUpdate:commandBuffer:MPSCNNConvolutionGradientState* method of MPSCNNConvolution object for GPU side update. UPdated weights and biases are computed as Wkpqc_new = Wkpqc_old + delta_E/delta_Wkpqc bk_new = bk_old + delta_E/delta_bk Note that MPSCNNConvolutionGradientState objects's buffers that contain gradients, for CPU side update, will only contain valid data after command buffer is complete so its only makes sense to call -updateWeightsAndBias method on MPSCNNConvolution objects after command bufer is complete. One can achieve this by enqueueing a command buffer completion handler block that make this call. Since MPSCNNConvolutionGradientState is used across command buffers i.e. its created in forward pass, consumed by MPSCNNConvolutionGradient in backward pass in same command buffer and passed onto MPSCNNConvolution updateWeightsAndBias method after completion of command buffer, it cannot be a temporary state. In order to gaurantee consistency between forward pass (MPSCNNConvolution) and weights gradient computation in this filter, certain requirements must be met. 1) Dimensions of loss gradient E from previous layer in backward pass must be equal to clipRect.size of corresponding MPSCNNConvolution in forward pass. This is to gaurantee that only those pixels for which weights/bias contributed in destination of forward pass end up contributing to weights/bias gradient update. If the dimension of loss gradient E from previous layer is not equal to clipRect.size of corresponding forward MPSCNNConvolution, i) one can insert a slice operation to extract out the region of size clipRect.size from appropriate offset in E and set primaryOffset = 0 Or ii) set primatryOffset to offset in E at which valid data starts and make sure data outside is zeroed. 2) secondaryOffset should be set to what offset property of MPSCNNConvolution was set to in forward pass. Currently back propagation for gradients is only supported for regualar convolution and depthwise convolution. Back propagation sub-pixel convolution are not supported. So channelMultiplier and subPixelScaleFactor must be one. Note on setting correct offsets =============================== If the forward convolution is called with offset = _offset; kernelWidth = kW; kernelHeight = kH; strideInPixelsX = sX; strideInPixelsY = sY; dilationRateX = dX; dilationRateY = dY; thus dilated filter parameters are kW_Dilated = (kW - 1)*dX + 1; kH_Dilated = (kH - 1)*dY + 1; Then the correct offset can be computed as follows. Convoluton Gradient with Data ============================= Convolution gradient with data of forward convolution with stride > 1 is essentially normal convoution with unit stride, on an image that is formed by inserting strideInPixelsX-1 zeros in between each column and strideInPixelsY-1 zeros in between each row of input gradient (output gradient of last layer) with kernel weights that are rotated by 180 degrees in spatial dimension (MPSCNNConvolutionGradient does this rotation internally). primaryOffset property defines offset in original input gradient coordinate system. In order to translate it in zero filled intermediate image coordinate system, kernelOffsetX and kernelOffsetY properties can be used as follows offsetInZeroFilledImageX = primaryOffset.x * primaryStrideInPixelsX + kernelOffsetX; offsetInZeroFilledImageY = primaryOffset.y * primaryStrideInPixelsY + kernelOffsetY; This is what internally MPSCNNConvolutionGradient do. In order to correctly match forward convolution offset setting (so that padding policy is consistent), application should set primaryOffset.x = 0; primaryOffset.y = 0; kernelOffset.x = -_offset.x + (~(NSInteger) kW_Dilated & 1L); kernelOffset.y = -_offset.y + (~(NSInteger) kH_Dilated & 1L); Convolution gradient with data does not use secondaryOffset. Convolution Gradient with Weights and Biases ============================================ For consistent padding policy with respect to forward convolution, secondaryOffset.x = _offset.x - kW_Dilated/2 secondaryOffset.y = _offset.y - kH_Dilated/2 Convolution gradient with weights and biases does not use primaryOffset (or it is assumed to be zero) as summation is over entire gradient image and only gradient image without any padding is currently accepted. If previous layer produces gradient image with padding, slice operation should be used to extract out the gradient which will be input to MPSCNNConvolutionGradient. Note that if application uses encode method that return destination gradient on left hand side and consumes MPSCNNConvolutionGradientState object produced by forward MPSCNNConvolution, all these parameters are set automatically for the application i.e. applicaiton does not need to worry about setting these.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class apple.NSObject
NSObject.Function_instanceMethodForSelector_ret, NSObject.Function_methodForSelector_ret
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedMPSCNNConvolutionGradient(org.moe.natj.general.Pointer peer)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean_supportsSecureCoding()This property must return YES on all classes that allow secure coding.static booleanaccessInstanceVariablesDirectly()static MPSCNNConvolutionGradientalloc()static java.lang.ObjectallocWithZone(org.moe.natj.general.ptr.VoidPtr zone)static booleanautomaticallyNotifiesObserversForKey(java.lang.String key)static voidcancelPreviousPerformRequestsWithTarget(java.lang.Object aTarget)static voidcancelPreviousPerformRequestsWithTargetSelectorObject(java.lang.Object aTarget, org.moe.natj.objc.SEL aSelector, java.lang.Object anArgument)longchannelMultiplier()Channel multiplier.static NSArray<java.lang.String>classFallbacksForKeyedArchiver()static org.moe.natj.objc.ClassclassForKeyedUnarchiver()MPSCNNConvolutionDataSourcedataSource()[@property] dataSource dataSource with which gradient object was createdstatic java.lang.StringdebugDescription_static()static java.lang.Stringdescription_static()longgradientOption()[@property] gradientOption Option to control which gradient to compute.longgroups()[@property] groups Number of groups input and output channels are divided into.static longhash_static()MPSCNNConvolutionGradientinit()MPSCNNConvolutionGradientinitWithCoder(NSCoder aDecoder)NS_DESIGNATED_INITIALIZERMPSCNNConvolutionGradientinitWithCoderDevice(NSCoder aDecoder, java.lang.Object device)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.MPSCNNConvolutionGradientinitWithDevice(java.lang.Object device)Standard init with default properties per filter typeMPSCNNConvolutionGradientinitWithDeviceWeights(MTLDevice device, MPSCNNConvolutionDataSource weights)Initializes a convolution gradient (with respect to weights and bias) object.static NSObject.Function_instanceMethodForSelector_retinstanceMethodForSelector(org.moe.natj.objc.SEL aSelector)static NSMethodSignatureinstanceMethodSignatureForSelector(org.moe.natj.objc.SEL aSelector)static booleaninstancesRespondToSelector(org.moe.natj.objc.SEL aSelector)static booleanisSubclassOfClass(org.moe.natj.objc.Class aClass)static NSSet<java.lang.String>keyPathsForValuesAffectingValueForKey(java.lang.String key)static java.lang.Objectnew_objc()voidreloadWeightsAndBiasesFromDataSource()CPU side reload.voidreloadWeightsAndBiasesWithCommandBufferState(MTLCommandBuffer commandBuffer, MPSCNNConvolutionWeightsAndBiasesState state)GPU side reload.static booleanresolveClassMethod(org.moe.natj.objc.SEL sel)static booleanresolveInstanceMethod(org.moe.natj.objc.SEL sel)booleanserializeWeightsAndBiases()Property to control serialization of weights and bias.voidsetGradientOption(long value)[@property] gradientOption Option to control which gradient to compute.voidsetSerializeWeightsAndBiases(boolean value)Property to control serialization of weights and bias.static voidsetVersion_static(long aVersion)longsourceGradientFeatureChannels()[@property] sourceGradientFeatureChannels The number of feature channels per pixel in the gradient image (primarySource) of encode call.longsourceImageFeatureChannels()[@property] sourceImageFeatureChannels The number of feature channels per pixel in the input image to forward convolution which is used here as secondarySource.static org.moe.natj.objc.Classsuperclass_static()static booleansupportsSecureCoding()static longversion_static()-
Methods inherited from class apple.metalperformanceshaders.MPSCNNGradientKernel
encodeToCommandBufferSourceGradientSourceImageGradientState, encodeToCommandBufferSourceGradientSourceImageGradientStateDestinationGradient, kernelOffsetX, kernelOffsetY, setKernelOffsetX, setKernelOffsetY
-
Methods inherited from class apple.metalperformanceshaders.MPSCNNBinaryKernel
appendBatchBarrier, clipRect, destinationFeatureChannelOffset, destinationImageAllocator, destinationImageDescriptorForSourceImagesSourceStates, encodeToCommandBufferPrimaryImageSecondaryImage, encodeToCommandBufferPrimaryImageSecondaryImageDestinationImage, encodeToCommandBufferPrimaryImageSecondaryImageDestinationStateDestinationStateIsTemporary, encodingStorageSizeForPrimaryImageSecondaryImageSourceStatesDestinationImage, isBackwards, isResultStateReusedAcrossBatch, isStateModified, padding, primaryDilationRateX, primaryDilationRateY, primaryEdgeMode, primaryKernelHeight, primaryKernelWidth, primaryOffset, primarySourceFeatureChannelMaxCount, primarySourceFeatureChannelOffset, primaryStrideInPixelsX, primaryStrideInPixelsY, resultStateForPrimaryImageSecondaryImageSourceStatesDestinationImage, secondaryDilationRateX, secondaryDilationRateY, secondaryEdgeMode, secondaryKernelHeight, secondaryKernelWidth, secondaryOffset, secondarySourceFeatureChannelMaxCount, secondarySourceFeatureChannelOffset, secondaryStrideInPixelsX, secondaryStrideInPixelsY, setClipRect, setDestinationFeatureChannelOffset, setDestinationImageAllocator, setPadding, setPrimaryEdgeMode, setPrimaryOffset, setPrimarySourceFeatureChannelMaxCount, setPrimarySourceFeatureChannelOffset, setPrimaryStrideInPixelsX, setPrimaryStrideInPixelsY, setSecondaryEdgeMode, setSecondaryOffset, setSecondarySourceFeatureChannelMaxCount, setSecondarySourceFeatureChannelOffset, setSecondaryStrideInPixelsX, setSecondaryStrideInPixelsY, temporaryResultStateForCommandBufferPrimaryImageSecondaryImageSourceStatesDestinationImage
-
Methods inherited from class apple.metalperformanceshaders.MPSKernel
copyWithZone, copyWithZoneDevice, device, encodeWithCoder, label, options, setLabel, setOptions
-
Methods inherited from class apple.NSObject
accessibilityActivate, accessibilityActivationPoint, accessibilityAssistiveTechnologyFocusedIdentifiers, accessibilityAttributedHint, accessibilityAttributedLabel, accessibilityAttributedUserInputLabels, accessibilityAttributedValue, accessibilityContainerType, accessibilityCustomActions, accessibilityCustomRotors, accessibilityDecrement, accessibilityDragSourceDescriptors, accessibilityDropPointDescriptors, accessibilityElementAtIndex, accessibilityElementCount, accessibilityElementDidBecomeFocused, accessibilityElementDidLoseFocus, accessibilityElementIsFocused, accessibilityElements, accessibilityElementsHidden, accessibilityFrame, accessibilityHint, accessibilityIncrement, accessibilityLabel, accessibilityLanguage, accessibilityNavigationStyle, accessibilityPath, accessibilityPerformEscape, accessibilityPerformMagicTap, accessibilityRespondsToUserInteraction, accessibilityScroll, accessibilityTextualContext, accessibilityTraits, accessibilityUserInputLabels, accessibilityValue, accessibilityViewIsModal, addObserverForKeyPathOptionsContext, attemptRecoveryFromErrorOptionIndex, attemptRecoveryFromErrorOptionIndexDelegateDidRecoverSelectorContextInfo, autoContentAccessingProxy, awakeAfterUsingCoder, awakeFromNib, class_objc, classForCoder, classForKeyedArchiver, copy, dealloc, debugDescription, description, dictionaryWithValuesForKeys, didChangeValueForKey, didChangeValueForKeyWithSetMutationUsingObjects, didChangeValuesAtIndexesForKey, doesNotRecognizeSelector, fileManagerShouldProceedAfterError, fileManagerWillProcessPath, finalize_objc, forwardingTargetForSelector, forwardInvocation, hash, indexOfAccessibilityElement, isAccessibilityElement, isEqual, isKindOfClass, isMemberOfClass, isProxy, methodForSelector, methodSignatureForSelector, mutableArrayValueForKey, mutableArrayValueForKeyPath, mutableCopy, mutableOrderedSetValueForKey, mutableOrderedSetValueForKeyPath, mutableSetValueForKey, mutableSetValueForKeyPath, observationInfo, observeValueForKeyPathOfObjectChangeContext, performSelector, performSelectorInBackgroundWithObject, performSelectorOnMainThreadWithObjectWaitUntilDone, performSelectorOnMainThreadWithObjectWaitUntilDoneModes, performSelectorOnThreadWithObjectWaitUntilDone, performSelectorOnThreadWithObjectWaitUntilDoneModes, performSelectorWithObject, performSelectorWithObjectAfterDelay, performSelectorWithObjectAfterDelayInModes, performSelectorWithObjectWithObject, prepareForInterfaceBuilder, provideImageDataBytesPerRowOrigin_Size_UserInfo, removeObserverForKeyPath, removeObserverForKeyPathContext, replacementObjectForCoder, replacementObjectForKeyedArchiver, respondsToSelector, self, setAccessibilityActivationPoint, setAccessibilityAttributedHint, setAccessibilityAttributedLabel, setAccessibilityAttributedUserInputLabels, setAccessibilityAttributedValue, setAccessibilityContainerType, setAccessibilityCustomActions, setAccessibilityCustomRotors, setAccessibilityDragSourceDescriptors, setAccessibilityDropPointDescriptors, setAccessibilityElements, setAccessibilityElementsHidden, setAccessibilityFrame, setAccessibilityHint, setAccessibilityLabel, setAccessibilityLanguage, setAccessibilityNavigationStyle, setAccessibilityPath, setAccessibilityRespondsToUserInteraction, setAccessibilityTextualContext, setAccessibilityTraits, setAccessibilityUserInputLabels, setAccessibilityValue, setAccessibilityViewIsModal, setIsAccessibilityElement, setNilValueForKey, setObservationInfo, setShouldGroupAccessibilityChildren, setValueForKey, setValueForKeyPath, setValueForUndefinedKey, setValuesForKeysWithDictionary, shouldGroupAccessibilityChildren, superclass, validateValueForKeyError, validateValueForKeyPathError, valueForKey, valueForKeyPath, valueForUndefinedKey, willChangeValueForKey, willChangeValueForKeyWithSetMutationUsingObjects, willChangeValuesAtIndexesForKey
-
-
-
-
Method Detail
-
accessInstanceVariablesDirectly
public static boolean accessInstanceVariablesDirectly()
-
alloc
public static MPSCNNConvolutionGradient alloc()
-
allocWithZone
public static java.lang.Object allocWithZone(org.moe.natj.general.ptr.VoidPtr zone)
-
automaticallyNotifiesObserversForKey
public static boolean automaticallyNotifiesObserversForKey(java.lang.String key)
-
cancelPreviousPerformRequestsWithTarget
public static void cancelPreviousPerformRequestsWithTarget(java.lang.Object aTarget)
-
cancelPreviousPerformRequestsWithTargetSelectorObject
public static void cancelPreviousPerformRequestsWithTargetSelectorObject(java.lang.Object aTarget, org.moe.natj.objc.SEL aSelector, java.lang.Object anArgument)
-
channelMultiplier
public long channelMultiplier()
Channel multiplier. For convolution created with MPSCNNDepthWiseConvolutionDescriptor, it is the number of output feature channels for each input channel. See MPSCNNDepthWiseConvolutionDescriptor for more details. Default is 0 which means regular CNN convolution. Currently only channelMultiplier of 1 is supported i.e. inputChannels == outputChannels
-
classFallbacksForKeyedArchiver
public static NSArray<java.lang.String> classFallbacksForKeyedArchiver()
-
classForKeyedUnarchiver
public static org.moe.natj.objc.Class classForKeyedUnarchiver()
-
dataSource
public MPSCNNConvolutionDataSource dataSource()
[@property] dataSource dataSource with which gradient object was created
-
debugDescription_static
public static java.lang.String debugDescription_static()
-
description_static
public static java.lang.String description_static()
-
gradientOption
public long gradientOption()
[@property] gradientOption Option to control which gradient to compute. Default is MPSCNNConvolutionGradientOptionAll which means both gradient with respect to data and gradient with respect to weight and bias are computed.
-
groups
public long groups()
[@property] groups Number of groups input and output channels are divided into.
-
hash_static
public static long hash_static()
-
init
public MPSCNNConvolutionGradient init()
- Overrides:
initin classMPSCNNGradientKernel
-
initWithCoder
public MPSCNNConvolutionGradient initWithCoder(NSCoder aDecoder)
Description copied from interface:NSCodingNS_DESIGNATED_INITIALIZER- Specified by:
initWithCoderin interfaceNSCoding- Overrides:
initWithCoderin classMPSCNNGradientKernel
-
initWithCoderDevice
public MPSCNNConvolutionGradient initWithCoderDevice(NSCoder aDecoder, java.lang.Object device)
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.- Overrides:
initWithCoderDevicein classMPSCNNGradientKernel- Parameters:
aDecoder- The NSCoder subclass with your serialized MPSKerneldevice- The MTLDevice on which to make the MPSKernel- Returns:
- A new MPSKernel object, or nil if failure.
-
initWithDevice
public MPSCNNConvolutionGradient initWithDevice(java.lang.Object device)
Description copied from class:MPSCNNGradientKernelStandard init with default properties per filter type- Overrides:
initWithDevicein classMPSCNNGradientKernel- Parameters:
device- The device that the filter will be used on. May not be NULL.- Returns:
- A pointer to the newly initialized object. This will fail, returning nil if the device is not supported. Devices must be MTLFeatureSet_iOS_GPUFamily2_v1 or later.
-
initWithDeviceWeights
public MPSCNNConvolutionGradient initWithDeviceWeights(MTLDevice device, MPSCNNConvolutionDataSource weights)
Initializes a convolution gradient (with respect to weights and bias) object.- Parameters:
device- The MTLDevice on which this MPSCNNConvolutionGradient filter will be usedweights- A pointer to a object that conforms to the MPSCNNConvolutionDataSource protocol. Note that same data source as provided to forward convolution should be used.- Returns:
- A valid MPSCNNConvolutionGradient object or nil, if failure.
-
instanceMethodForSelector
public static NSObject.Function_instanceMethodForSelector_ret instanceMethodForSelector(org.moe.natj.objc.SEL aSelector)
-
instanceMethodSignatureForSelector
public static NSMethodSignature instanceMethodSignatureForSelector(org.moe.natj.objc.SEL aSelector)
-
instancesRespondToSelector
public static boolean instancesRespondToSelector(org.moe.natj.objc.SEL aSelector)
-
isSubclassOfClass
public static boolean isSubclassOfClass(org.moe.natj.objc.Class aClass)
-
keyPathsForValuesAffectingValueForKey
public static NSSet<java.lang.String> keyPathsForValuesAffectingValueForKey(java.lang.String key)
-
new_objc
public static java.lang.Object new_objc()
-
reloadWeightsAndBiasesFromDataSource
public void reloadWeightsAndBiasesFromDataSource()
CPU side reload. Reload the updated weights and biases from data provider into internal weights and bias buffers. Weights and biases gradients needed for update are obtained from MPSCNNConvolutionGradientState object. Data provider passed in init call is used for this purpose.
-
reloadWeightsAndBiasesWithCommandBufferState
public void reloadWeightsAndBiasesWithCommandBufferState(MTLCommandBuffer commandBuffer, MPSCNNConvolutionWeightsAndBiasesState state)
GPU side reload. Reload the updated weights and biases from update buffer produced by application enqueued metal kernel into internal weights and biases buffer. Weights and biases gradients needed for update are obtained from MPSCNNConvolutionGradientState object's gradientForWeights and gradientForBiases metal buffer.- Parameters:
commandBuffer- Metal command buffer on which application update kernel was enqueued consuming MPSCNNConvolutionGradientState's gradientForWeights and gradientForBiases buffer and producing updateBuffer metal buffer.state- MPSCNNConvolutionWeightsAndBiasesState containing weights and biases buffers which have updated weights produced by application's update kernel.
-
resolveClassMethod
public static boolean resolveClassMethod(org.moe.natj.objc.SEL sel)
-
resolveInstanceMethod
public static boolean resolveInstanceMethod(org.moe.natj.objc.SEL sel)
-
serializeWeightsAndBiases
public boolean serializeWeightsAndBiases()
Property to control serialization of weights and bias. During serialization of convolution object in -encodeWithCoder call, weights and biases are saved so that convolution object can be properly unserialized/restored in -initWithCoder call. If data source provied is NSSecureCoding compliant, data source is serialized else weights and biases are serialized. As weights/biases data may be several MB and these are same for both gradient and forward convolution object, application may already have weights/biases on disk through convolution, it can save disk space by setting this property false so convolution gradient object does not end up storing another copy of weights/biases. Default is NO. When application decides to set it to NO, it MUST call -(void) reloadWeightsAndBiasesFromDataSource after initWithCoder has initialized convolution object.
-
setGradientOption
public void setGradientOption(long value)
[@property] gradientOption Option to control which gradient to compute. Default is MPSCNNConvolutionGradientOptionAll which means both gradient with respect to data and gradient with respect to weight and bias are computed.
-
setSerializeWeightsAndBiases
public void setSerializeWeightsAndBiases(boolean value)
Property to control serialization of weights and bias. During serialization of convolution object in -encodeWithCoder call, weights and biases are saved so that convolution object can be properly unserialized/restored in -initWithCoder call. If data source provied is NSSecureCoding compliant, data source is serialized else weights and biases are serialized. As weights/biases data may be several MB and these are same for both gradient and forward convolution object, application may already have weights/biases on disk through convolution, it can save disk space by setting this property false so convolution gradient object does not end up storing another copy of weights/biases. Default is NO. When application decides to set it to NO, it MUST call -(void) reloadWeightsAndBiasesFromDataSource after initWithCoder has initialized convolution object.
-
setVersion_static
public static void setVersion_static(long aVersion)
-
sourceGradientFeatureChannels
public long sourceGradientFeatureChannels()
[@property] sourceGradientFeatureChannels The number of feature channels per pixel in the gradient image (primarySource) of encode call. This is same is outputFeatureChannels or the feature channels of destination image in forward convolution i.e. dataSource.descriptor.outputFeatureChannels
-
sourceImageFeatureChannels
public long sourceImageFeatureChannels()
[@property] sourceImageFeatureChannels The number of feature channels per pixel in the input image to forward convolution which is used here as secondarySource. This is same as dataSource.descriptor.inputFeatureChannels. This is also the number of feature channels in destinatin image here i.e. gradient with respect to data.
-
superclass_static
public static org.moe.natj.objc.Class superclass_static()
-
supportsSecureCoding
public static boolean supportsSecureCoding()
-
_supportsSecureCoding
public boolean _supportsSecureCoding()
Description copied from interface:NSSecureCodingThis property must return YES on all classes that allow secure coding. Subclasses of classes that adopt NSSecureCoding and override initWithCoder: must also override this method and return YES. The Secure Coding Guide should be consulted when writing methods that decode data.- Specified by:
_supportsSecureCodingin interfaceNSSecureCoding- Overrides:
_supportsSecureCodingin classMPSCNNGradientKernel
-
version_static
public static long version_static()
-
-