.TH "MPSGRUDescriptor" 3 "Mon Jul 9 2018" "Version MetalPerformanceShaders-119.3" "MetalPerformanceShaders.framework" \" -*- nroff -*- .ad l .nh .SH NAME MPSGRUDescriptor .SH SYNOPSIS .br .PP .PP \fC#import \fP .PP Inherits \fBMPSRNNDescriptor\fP\&. .SS "Class Methods" .in +1c .ti -1c .RI "(nonnull instancetype) + \fBcreateGRUDescriptorWithInputFeatureChannels:outputFeatureChannels:\fP" .br .in -1c .SS "Properties" .in +1c .ti -1c .RI "id< \fBMPSCNNConvolutionDataSource\fP > \fBinputGateInputWeights\fP" .br .ti -1c .RI "id< \fBMPSCNNConvolutionDataSource\fP > \fBinputGateRecurrentWeights\fP" .br .ti -1c .RI "id< \fBMPSCNNConvolutionDataSource\fP > \fBrecurrentGateInputWeights\fP" .br .ti -1c .RI "id< \fBMPSCNNConvolutionDataSource\fP > \fBrecurrentGateRecurrentWeights\fP" .br .ti -1c .RI "id< \fBMPSCNNConvolutionDataSource\fP > \fBoutputGateInputWeights\fP" .br .ti -1c .RI "id< \fBMPSCNNConvolutionDataSource\fP > \fBoutputGateRecurrentWeights\fP" .br .ti -1c .RI "id< \fBMPSCNNConvolutionDataSource\fP > \fBoutputGateInputGateWeights\fP" .br .ti -1c .RI "float \fBgatePnormValue\fP" .br .ti -1c .RI "BOOL \fBflipOutputGates\fP" .br .in -1c .SH "Detailed Description" .PP This depends on Metal\&.framework The \fBMPSGRUDescriptor\fP specifies a GRU (Gated Recurrent Unit) block/layer descriptor\&. The RNN layer initialized with a \fBMPSGRUDescriptor\fP 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 )\&. .PP .nf Description of operation: .fi .PP .PP 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\&. .PP 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 .PP 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 .PP 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 .PP 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\&. .PP Then the output of the Gated Recurrent Unit layer is computed as follows: .PP .nf 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 .fi .PP .PP The '*' stands for convolution (see \fBMPSRNNImageInferenceLayer\fP) or matrix-vector/matrix multiplication (see \fBMPSRNNMatrixInferenceLayer\fP)\&. 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)\&. .SH "Method Documentation" .PP .SS "+ (nonnull instancetype) createGRUDescriptorWithInputFeatureChannels: (NSUInteger) inputFeatureChannels(NSUInteger) outputFeatureChannels" Creates a GRU descriptor\&. .PP \fBParameters:\fP .RS 4 \fIinputFeatureChannels\fP The number of feature channels in the input image/matrix\&. Must be >= 1\&. .br \fIoutputFeatureChannels\fP The number of feature channels in the output image/matrix\&. Must be >= 1\&. .RE .PP \fBReturns:\fP .RS 4 \fBA\fP valid \fBMPSGRUDescriptor\fP object or nil, if failure\&. .RE .PP .SH "Property Documentation" .PP .SS "\- flipOutputGates\fC [read]\fP, \fC [write]\fP, \fC [nonatomic]\fP, \fC [assign]\fP" 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\&. .SS "\- gatePnormValue\fC [read]\fP, \fC [write]\fP, \fC [nonatomic]\fP, \fC [assign]\fP" The p-norm gating norm value as specified by the GRU formulae\&. Defaults to 1\&.0f\&. .SS "\- inputGateInputWeights\fC [read]\fP, \fC [write]\fP, \fC [nonatomic]\fP, \fC [retain]\fP" 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\&. .SS "\- inputGateRecurrentWeights\fC [read]\fP, \fC [write]\fP, \fC [nonatomic]\fP, \fC [retain]\fP" Contains weights 'Uz_ij' from the GRU formula\&. If nil then assumed zero weights\&. Defaults to nil\&. .SS "\- outputGateInputGateWeights\fC [read]\fP, \fC [write]\fP, \fC [nonatomic]\fP, \fC [retain]\fP" Contains weights 'Vh_ij' - can be used to implement the 'Minimally Gated Unit'\&. If nil then assumed zero weights\&. Defaults to nil\&. .SS "\- outputGateInputWeights\fC [read]\fP, \fC [write]\fP, \fC [nonatomic]\fP, \fC [retain]\fP" 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\&. .SS "\- outputGateRecurrentWeights\fC [read]\fP, \fC [write]\fP, \fC [nonatomic]\fP, \fC [retain]\fP" Contains weights 'Uh_ij' from the GRU formula\&. If nil then assumed zero weights\&. Defaults to nil\&. .SS "\- recurrentGateInputWeights\fC [read]\fP, \fC [write]\fP, \fC [nonatomic]\fP, \fC [retain]\fP" 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\&. .SS "\- recurrentGateRecurrentWeights\fC [read]\fP, \fC [write]\fP, \fC [nonatomic]\fP, \fC [retain]\fP" Contains weights 'Ur_ij' from the GRU formula\&. If nil then assumed zero weights\&.Defaults to nil\&. .SH "Author" .PP Generated automatically by Doxygen for MetalPerformanceShaders\&.framework from the source code\&.