class_docstr: lasagne.layers.recurrent.GRULayer(incoming, num_units,
  resetgate=lasagne.layers.Gate(W_cell=None),
  updategate=lasagne.layers.Gate(W_cell=None),
  hidden_update=lasagne.layers.Gate(
  W_cell=None, lasagne.nonlinearities.tanh),
  hid_init=lasagne.init.Constant(0.), backwards=False, learn_init=False,
  gradient_steps=-1, grad_clipping=0, unroll_scan=False,
  precompute_input=True, mask_input=None, only_return_final=False, **kwargs)
  
  Gated Recurrent Unit (GRU) Layer
  
  Implements the recurrent step proposed in [1]_, which computes the output
  by
  
  .. math ::
      r_t &= \sigma_r(x_t W_{xr} + h_{t - 1} W_{hr} + b_r)\\
      u_t &= \sigma_u(x_t W_{xu} + h_{t - 1} W_{hu} + b_u)\\
      c_t &= \sigma_c(x_t W_{xc} + r_t \odot (h_{t - 1} W_{hc}) + b_c)\\
      h_t &= (1 - u_t) \odot h_{t - 1} + u_t \odot c_t
  
  Parameters
  ----------
  incoming : a :class:`lasagne.layers.Layer` instance or a tuple
      The layer feeding into this layer, or the expected input shape.
  num_units : int
      Number of hidden units in the layer.
  resetgate : Gate
      Parameters for the reset gate (:math:`r_t`): :math:`W_{xr}`,
      :math:`W_{hr}`, :math:`b_r`, and :math:`\sigma_r`.
  updategate : Gate
      Parameters for the update gate (:math:`u_t`): :math:`W_{xu}`,
      :math:`W_{hu}`, :math:`b_u`, and :math:`\sigma_u`.
  hidden_update : Gate
      Parameters for the hidden update (:math:`c_t`): :math:`W_{xc}`,
      :math:`W_{hc}`, :math:`b_c`, and :math:`\sigma_c`.
  hid_init : callable, np.ndarray, theano.shared or :class:`Layer`
      Initializer for initial hidden state (:math:`h_0`).
  backwards : bool
      If True, process the sequence backwards and then reverse the
      output again such that the output from the layer is always
      from :math:`x_1` to :math:`x_n`.
  learn_init : bool
      If True, initial hidden values are learned.
  gradient_steps : int
      Number of timesteps to include in the backpropagated gradient.
      If -1, backpropagate through the entire sequence.
  grad_clipping : float
      If nonzero, the gradient messages are clipped to the given value during
      the backward pass.  See [1]_ (p. 6) for further explanation.
  unroll_scan : bool
      If True the recursion is unrolled instead of using scan. For some
      graphs this gives a significant speed up but it might also consume
      more memory. When `unroll_scan` is True, backpropagation always
      includes the full sequence, so `gradient_steps` must be set to -1 and
      the input sequence length must be known at compile time (i.e., cannot
      be given as None).
  precompute_input : bool
      If True, precompute input_to_hid before iterating through
      the sequence. This can result in a speedup at the expense of
      an increase in memory usage.
  mask_input : :class:`lasagne.layers.Layer`
      Layer which allows for a sequence mask to be input, for when sequences
      are of variable length.  Default `None`, which means no mask will be
      supplied (i.e. all sequences are of the same length).
  only_return_final : bool
      If True, only return the final sequential output (e.g. for tasks where
      a single target value for the entire sequence is desired).  In this
      case, Theano makes an optimization which saves memory.
  
  References
  ----------
  .. [1] Cho, Kyunghyun, et al: On the properties of neural
     machine translation: Encoder-decoder approaches.
     arXiv preprint arXiv:1409.1259 (2014).
  .. [2] Chung, Junyoung, et al.: Empirical Evaluation of Gated
     Recurrent Neural Networks on Sequence Modeling.
     arXiv preprint arXiv:1412.3555 (2014).
  .. [3] Graves, Alex: "Generating sequences with recurrent neural networks."
         arXiv preprint arXiv:1308.0850 (2013).
  
  Notes
  -----
  An alternate update for the candidate hidden state is proposed in [2]_:
  
  .. math::
      c_t &= \sigma_c(x_t W_{ic} + (r_t \odot h_{t - 1})W_{hc} + b_c)\\
  
  We use the formulation from [1]_ because it allows us to do all matrix
  operations in a single dot product.
code: def __init__(
      self,
      incoming,
      num_units,
      resetgate=Gate(W_cell=None),
      updategate=Gate(W_cell=None),
      hidden_update=Gate(W_cell=None, nonlinearity=nonlinearities.tanh),
      hid_init=init.Constant(0.0),
      backwards=False,
      learn_init=False,
      gradient_steps=-1,
      grad_clipping=0,
      unroll_scan=False,
      precompute_input=True,
      mask_input=None,
      only_return_final=False,
      **kwargs,
  ):
      # This layer inherits from a MergeLayer, because it can have three
      # inputs - the layer input, the mask and the initial hidden state.  We
      # will just provide the layer input as incomings, unless a mask input
      # or initial hidden state was provided.
      incomings = [incoming]
      self.mask_incoming_index = -1
      self.hid_init_incoming_index = -1
      if mask_input is not None:
          incomings.append(mask_input)
          self.mask_incoming_index = len(incomings) - 1
      if isinstance(hid_init, Layer):
          incomings.append(hid_init)
          self.hid_init_incoming_index = len(incomings) - 1
  
      # Initialize parent layer
      super(GRULayer, self).__init__(incomings, **kwargs)
  
      self.learn_init = learn_init
      self.num_units = num_units
      self.grad_clipping = grad_clipping
      self.backwards = backwards
      self.gradient_steps = gradient_steps
      self.unroll_scan = unroll_scan
      self.precompute_input = precompute_input
      self.only_return_final = only_return_final
  
      if unroll_scan and gradient_steps != -1:
          raise ValueError(
              "Gradient steps must be -1 when unroll_scan is true."
          )
  
      # Retrieve the dimensionality of the incoming layer
      input_shape = self.input_shapes[0]
  
      if unroll_scan and input_shape[1] is None:
          raise ValueError(
              "Input sequence length cannot be specified as "
              "None when unroll_scan is True"
          )
  
      # Input dimensionality is the output dimensionality of the input layer
      num_inputs = np.prod(input_shape[2:])
  
      def add_gate_params(gate, gate_name):
          """Convenience function for adding layer parameters from a Gate
          instance."""
          return (
              self.add_param(
                  gate.W_in,
                  (num_inputs, num_units),
                  name="W_in_to_{}".format(gate_name),
              ),
              self.add_param(
                  gate.W_hid,
                  (num_units, num_units),
                  name="W_hid_to_{}".format(gate_name),
              ),
              self.add_param(
                  gate.b,
                  (num_units,),
                  name="b_{}".format(gate_name),
                  regularizable=False,
              ),
              gate.nonlinearity,
          )
  
      # Add in all parameters from gates
      (
          self.W_in_to_updategate,
          self.W_hid_to_updategate,
          self.b_updategate,
          self.nonlinearity_updategate,
      ) = add_gate_params(updategate, "updategate")
      (
          self.W_in_to_resetgate,
          self.W_hid_to_resetgate,
          self.b_resetgate,
          self.nonlinearity_resetgate,
      ) = add_gate_params(resetgate, "resetgate")
  
      (
          self.W_in_to_hidden_update,
          self.W_hid_to_hidden_update,
          self.b_hidden_update,
          self.nonlinearity_hid,
      ) = add_gate_params(hidden_update, "hidden_update")
  
      # Initialize hidden state
      if isinstance(hid_init, Layer):
          self.hid_init = hid_init
      else:
          self.hid_init = self.add_param(
              hid_init,
              (1, self.num_units),
              name="hid_init",
              trainable=learn_init,
              regularizable=False,
          )
  
imports: import numpy
  import theano
  import theano.tensor
  from ..None import nonlinearities
  from ..None import init
  from ..utils import unroll_scan
  from .base import MergeLayer, Layer
  from .input import InputLayer
  from .dense import DenseLayer
  from .None import helper
label_desc: Use image node_id 1 to create a new GRULayer object from inherited base classes: MergeLayer with example: obj = GRULayer(incoming, num_units, resetgate, updategate, hidden_update, hid_init, backwards, learn_init, gradient_steps, grad_clipping, unroll_scan, precompute_input, mask_input, only_return_final)