Package apple.metalperformanceshaders
Class MPSGRUDescriptor
- java.lang.Object
-
- org.moe.natj.general.NativeObject
-
- org.moe.natj.objc.ObjCObject
-
- apple.NSObject
-
- apple.metalperformanceshaders.MPSRNNDescriptor
-
- apple.metalperformanceshaders.MPSGRUDescriptor
-
- All Implemented Interfaces:
NSObject
public class MPSGRUDescriptor extends MPSRNNDescriptor
MPSGRUDescriptor [@dependency] This depends on Metal.framework The MPSGRUDescriptor specifies a GRU (Gated Recurrent Unit) block/layer descriptor. The RNN layer initialized with a MPSGRUDescriptor transforms the input data (image or matrix), and previous output with a set of filters, each producing one feature map in the output data according to the Gated unit formulae detailed below. The user may provide the GRU unit a single input or a sequence of inputs. The layer also supports p-norm gating (Detailed in: https://arxiv.org/abs/1608.03639 ). Description of operation: Let x_j be the input data (at time index t of sequence, j index containing quadruplet: batch index, x,y and feature index (x=y=0 for matrices)). Let h0_j be the recurrent input (previous output) data from previous time step (at time index t-1 of sequence). Let h_i be the proposed new output. Let h1_i be the output data produced at this time step. Let Wz_ij, Uz_ij, be the input gate weights for input and recurrent input data respectively Let bi_i be the bias for the input gate Let Wr_ij, Ur_ij be the recurrent gate weights for input and recurrent input data respectively Let br_i be the bias for the recurrent gate Let Wh_ij, Uh_ij, Vh_ij, be the output gate weights for input, recurrent gate and input gate respectively Let bh_i be the bias for the output gate Let gz(x), gr(x), gh(x) be the neuron activation function for the input, recurrent and output gates Let p > 0 be a scalar variable (typicall p >= 1.0) that defines the p-norm gating norm value. Then the output of the Gated Recurrent Unit layer is computed as follows: z_i = gz( Wz_ij * x_j + Uz_ij * h0_j + bz_i ) r_i = gr( Wr_ij * x_j + Ur_ij * h0_j + br_i ) c_i = Uh_ij * (r_j h0_j) + Vh_ij * (z_j h0_j) h_i = gh( Wh_ij * x_j + c_i + bh_i ) h1_i = ( 1 - z_i ^ p)^(1/p) h_i + z_i h0_i The '*' stands for convolution (see @ref MPSRNNImageInferenceLayer) or matrix-vector/matrix multiplication (see @ref MPSRNNMatrixInferenceLayer). Summation is over index j (except for the batch index), but there is no summation over repeated index i - the output index. Note that for validity all intermediate images have to be of same size and all U and V matrices have to be square (ie. outputFeatureChannels == inputFeatureChannels in those). Also the bias terms are scalars wrt. spatial dimensions. The conventional GRU block is achieved by setting Vh = 0 (nil) and the so-called Minimal Gated Unit is achieved with Uh = 0. (The Minimal Gated Unit is detailed in: https://arxiv.org/abs/1603.09420 and there they call z_i the value of the forget gate).
-
-
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 protectedMPSGRUDescriptor(org.moe.natj.general.Pointer peer)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static booleanaccessInstanceVariablesDirectly()static MPSGRUDescriptoralloc()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)static NSArray<java.lang.String>classFallbacksForKeyedArchiver()static org.moe.natj.objc.ClassclassForKeyedUnarchiver()static java.lang.ObjectcreateGRUDescriptorWithInputFeatureChannelsOutputFeatureChannels(long inputFeatureChannels, long outputFeatureChannels)Creates a GRU descriptor.static java.lang.StringdebugDescription_static()static java.lang.Stringdescription_static()booleanflipOutputGates()[@property] flipOutputGates If YES then the GRU-block output formula is changed to: h1_i = ( 1 - z_i ^ p)^(1/p) h0_i + z_i h_i.floatgatePnormValue()[@property] gatePnormValue The p-norm gating norm value as specified by the GRU formulae.static longhash_static()MPSGRUDescriptorinit()MPSCNNConvolutionDataSourceinputGateInputWeights()[@property] inputGateInputWeights Contains weights 'Wz_ij', bias 'bz_i' and neuron 'gz' from the GRU formula.MPSCNNConvolutionDataSourceinputGateRecurrentWeights()[@property] inputGateRecurrentWeights Contains weights 'Uz_ij' from the GRU formula.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()MPSCNNConvolutionDataSourceoutputGateInputGateWeights()[@property] outputGateInputGateWeights Contains weights 'Vh_ij' - can be used to implement the "Minimally Gated Unit".MPSCNNConvolutionDataSourceoutputGateInputWeights()[@property] outputGateInputWeights Contains weights 'Wh_ij', bias 'bh_i' and neuron 'gh' from the GRU formula.MPSCNNConvolutionDataSourceoutputGateRecurrentWeights()[@property] outputGateRecurrentWeights Contains weights 'Uh_ij' from the GRU formula.MPSCNNConvolutionDataSourcerecurrentGateInputWeights()[@property] recurrentGateInputWeights Contains weights 'Wr_ij', bias 'br_i' and neuron 'gr' from the GRU formula.MPSCNNConvolutionDataSourcerecurrentGateRecurrentWeights()[@property] recurrentGateRecurrentWeights Contains weights 'Ur_ij' from the GRU formula.static booleanresolveClassMethod(org.moe.natj.objc.SEL sel)static booleanresolveInstanceMethod(org.moe.natj.objc.SEL sel)voidsetFlipOutputGates(boolean value)[@property] flipOutputGates If YES then the GRU-block output formula is changed to: h1_i = ( 1 - z_i ^ p)^(1/p) h0_i + z_i h_i.voidsetGatePnormValue(float value)[@property] gatePnormValue The p-norm gating norm value as specified by the GRU formulae.voidsetInputGateInputWeights(MPSCNNConvolutionDataSource value)[@property] inputGateInputWeights Contains weights 'Wz_ij', bias 'bz_i' and neuron 'gz' from the GRU formula.voidsetInputGateRecurrentWeights(MPSCNNConvolutionDataSource value)[@property] inputGateRecurrentWeights Contains weights 'Uz_ij' from the GRU formula.voidsetOutputGateInputGateWeights(MPSCNNConvolutionDataSource value)[@property] outputGateInputGateWeights Contains weights 'Vh_ij' - can be used to implement the "Minimally Gated Unit".voidsetOutputGateInputWeights(MPSCNNConvolutionDataSource value)[@property] outputGateInputWeights Contains weights 'Wh_ij', bias 'bh_i' and neuron 'gh' from the GRU formula.voidsetOutputGateRecurrentWeights(MPSCNNConvolutionDataSource value)[@property] outputGateRecurrentWeights Contains weights 'Uh_ij' from the GRU formula.voidsetRecurrentGateInputWeights(MPSCNNConvolutionDataSource value)[@property] recurrentGateInputWeights Contains weights 'Wr_ij', bias 'br_i' and neuron 'gr' from the GRU formula.voidsetRecurrentGateRecurrentWeights(MPSCNNConvolutionDataSource value)[@property] recurrentGateRecurrentWeights Contains weights 'Ur_ij' from the GRU formula.static voidsetVersion_static(long aVersion)static org.moe.natj.objc.Classsuperclass_static()static longversion_static()-
Methods inherited from class apple.metalperformanceshaders.MPSRNNDescriptor
inputFeatureChannels, layerSequenceDirection, outputFeatureChannels, setInputFeatureChannels, setLayerSequenceDirection, setOutputFeatureChannels, setUseFloat32Weights, setUseLayerInputUnitTransformMode, useFloat32Weights, useLayerInputUnitTransformMode
-
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 MPSGRUDescriptor 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)
-
classFallbacksForKeyedArchiver
public static NSArray<java.lang.String> classFallbacksForKeyedArchiver()
-
classForKeyedUnarchiver
public static org.moe.natj.objc.Class classForKeyedUnarchiver()
-
createGRUDescriptorWithInputFeatureChannelsOutputFeatureChannels
public static java.lang.Object createGRUDescriptorWithInputFeatureChannelsOutputFeatureChannels(long inputFeatureChannels, long outputFeatureChannels)Creates a GRU descriptor.- Parameters:
inputFeatureChannels- The number of feature channels in the input image/matrix. Must be >= 1.outputFeatureChannels- The number of feature channels in the output image/matrix. Must be >= 1.- Returns:
- A valid MPSGRUDescriptor object or nil, if failure.
-
debugDescription_static
public static java.lang.String debugDescription_static()
-
description_static
public static java.lang.String description_static()
-
flipOutputGates
public boolean flipOutputGates()
[@property] flipOutputGates If YES then the GRU-block output formula is changed to: h1_i = ( 1 - z_i ^ p)^(1/p) h0_i + z_i h_i. Defaults to NO.
-
gatePnormValue
public float gatePnormValue()
[@property] gatePnormValue The p-norm gating norm value as specified by the GRU formulae. Defaults to 1.0f.
-
hash_static
public static long hash_static()
-
init
public MPSGRUDescriptor init()
- Overrides:
initin classMPSRNNDescriptor
-
inputGateInputWeights
public MPSCNNConvolutionDataSource inputGateInputWeights()
[@property] inputGateInputWeights Contains weights 'Wz_ij', bias 'bz_i' and neuron 'gz' from the GRU formula. If nil then assumed zero weights, bias and no neuron (identity mapping). Defaults to nil.
-
inputGateRecurrentWeights
public MPSCNNConvolutionDataSource inputGateRecurrentWeights()
[@property] inputGateRecurrentWeights Contains weights 'Uz_ij' from the GRU formula. If nil then assumed zero weights. Defaults to nil.
-
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()
-
outputGateInputGateWeights
public MPSCNNConvolutionDataSource outputGateInputGateWeights()
[@property] outputGateInputGateWeights Contains weights 'Vh_ij' - can be used to implement the "Minimally Gated Unit". If nil then assumed zero weights. Defaults to nil.
-
outputGateInputWeights
public MPSCNNConvolutionDataSource outputGateInputWeights()
[@property] outputGateInputWeights Contains weights 'Wh_ij', bias 'bh_i' and neuron 'gh' from the GRU formula. If nil then assumed zero weights, bias and no neuron (identity mapping).Defaults to nil.
-
outputGateRecurrentWeights
public MPSCNNConvolutionDataSource outputGateRecurrentWeights()
[@property] outputGateRecurrentWeights Contains weights 'Uh_ij' from the GRU formula. If nil then assumed zero weights. Defaults to nil.
-
recurrentGateInputWeights
public MPSCNNConvolutionDataSource recurrentGateInputWeights()
[@property] recurrentGateInputWeights Contains weights 'Wr_ij', bias 'br_i' and neuron 'gr' from the GRU formula. If nil then assumed zero weights, bias and no neuron (identity mapping).Defaults to nil.
-
recurrentGateRecurrentWeights
public MPSCNNConvolutionDataSource recurrentGateRecurrentWeights()
[@property] recurrentGateRecurrentWeights Contains weights 'Ur_ij' from the GRU formula. If nil then assumed zero weights.Defaults to nil.
-
resolveClassMethod
public static boolean resolveClassMethod(org.moe.natj.objc.SEL sel)
-
resolveInstanceMethod
public static boolean resolveInstanceMethod(org.moe.natj.objc.SEL sel)
-
setFlipOutputGates
public void setFlipOutputGates(boolean value)
[@property] flipOutputGates If YES then the GRU-block output formula is changed to: h1_i = ( 1 - z_i ^ p)^(1/p) h0_i + z_i h_i. Defaults to NO.
-
setGatePnormValue
public void setGatePnormValue(float value)
[@property] gatePnormValue The p-norm gating norm value as specified by the GRU formulae. Defaults to 1.0f.
-
setInputGateInputWeights
public void setInputGateInputWeights(MPSCNNConvolutionDataSource value)
[@property] inputGateInputWeights Contains weights 'Wz_ij', bias 'bz_i' and neuron 'gz' from the GRU formula. If nil then assumed zero weights, bias and no neuron (identity mapping). Defaults to nil.
-
setInputGateRecurrentWeights
public void setInputGateRecurrentWeights(MPSCNNConvolutionDataSource value)
[@property] inputGateRecurrentWeights Contains weights 'Uz_ij' from the GRU formula. If nil then assumed zero weights. Defaults to nil.
-
setOutputGateInputGateWeights
public void setOutputGateInputGateWeights(MPSCNNConvolutionDataSource value)
[@property] outputGateInputGateWeights Contains weights 'Vh_ij' - can be used to implement the "Minimally Gated Unit". If nil then assumed zero weights. Defaults to nil.
-
setOutputGateInputWeights
public void setOutputGateInputWeights(MPSCNNConvolutionDataSource value)
[@property] outputGateInputWeights Contains weights 'Wh_ij', bias 'bh_i' and neuron 'gh' from the GRU formula. If nil then assumed zero weights, bias and no neuron (identity mapping).Defaults to nil.
-
setOutputGateRecurrentWeights
public void setOutputGateRecurrentWeights(MPSCNNConvolutionDataSource value)
[@property] outputGateRecurrentWeights Contains weights 'Uh_ij' from the GRU formula. If nil then assumed zero weights. Defaults to nil.
-
setRecurrentGateInputWeights
public void setRecurrentGateInputWeights(MPSCNNConvolutionDataSource value)
[@property] recurrentGateInputWeights Contains weights 'Wr_ij', bias 'br_i' and neuron 'gr' from the GRU formula. If nil then assumed zero weights, bias and no neuron (identity mapping).Defaults to nil.
-
setRecurrentGateRecurrentWeights
public void setRecurrentGateRecurrentWeights(MPSCNNConvolutionDataSource value)
[@property] recurrentGateRecurrentWeights Contains weights 'Ur_ij' from the GRU formula. If nil then assumed zero weights.Defaults to nil.
-
setVersion_static
public static void setVersion_static(long aVersion)
-
superclass_static
public static org.moe.natj.objc.Class superclass_static()
-
version_static
public static long version_static()
-
-