def _create_gate_variables(self, input_shape, dtype):
    """Initialize the variables used for the gates."""
    if len(input_shape) != 2:
      raise ValueError(
          "Rank of shape must be {} not: {}".format(2, len(input_shape)))

    equiv_input_size = self._hidden_state_size + input_shape.dims[1].value
    initializer = basic.create_linear_initializer(equiv_input_size)

    self._w_xh = tf.get_variable(
        self.W_GATES,
        shape=[equiv_input_size, 4 * self._hidden_size],
        dtype=dtype,
        initializer=self._initializers.get(self.W_GATES, initializer),
        partitioner=self._partitioners.get(self.W_GATES),
        regularizer=self._regularizers.get(self.W_GATES))
    self._b = tf.get_variable(
        self.B_GATES,
        shape=[4 * self._hidden_size],
        dtype=dtype,
        initializer=self._initializers.get(self.B_GATES, initializer),
        partitioner=self._partitioners.get(self.B_GATES),
        regularizer=self._regularizers.get(self.B_GATES))
    if self._use_projection:
      w_h_initializer = basic.create_linear_initializer(self._hidden_size)
      self._w_h_projection = tf.get_variable(
          self.W_H_PROJECTION,
          shape=[self._hidden_size, self._hidden_state_size],
          dtype=dtype,
          initializer=self._initializers.get(self.W_H_PROJECTION,
                                             w_h_initializer),
          partitioner=self._partitioners.get(self.W_H_PROJECTION),
          regularizer=self._regularizers.get(self.W_H_PROJECTION))
def _create_gate_variables ( self , input_shape , dtype ) : if len ( input_shape ) != 2 : raise ValueError ( "Rank of shape must be {} not: {}" . format ( 2 , len ( input_shape ) ) ) equiv_input_size = self . _hidden_state_size + input_shape . dims [ 1 ] . value initializer = basic . create_linear_initializer ( equiv_input_size ) self . _w_xh = tf . get_variable ( self . W_GATES , shape = [ equiv_input_size , 4 * self . _hidden_size ] , dtype = dtype , initializer = self . _initializers . get ( self . W_GATES , initializer ) , partitioner = self . _partitioners . get ( self . W_GATES ) , regularizer = self . _regularizers . get ( self . W_GATES ) ) self . _b = tf . get_variable ( self . B_GATES , shape = [ 4 * self . _hidden_size ] , dtype = dtype , initializer = self . _initializers . get ( self . B_GATES , initializer ) , partitioner = self . _partitioners . get ( self . B_GATES ) , regularizer = self . _regularizers . get ( self . B_GATES ) ) if self . _use_projection : w_h_initializer = basic . create_linear_initializer ( self . _hidden_size ) self . _w_h_projection = tf . get_variable ( self . W_H_PROJECTION , shape = [ self . _hidden_size , self . _hidden_state_size ] , dtype = dtype , initializer = self . _initializers . get ( self . W_H_PROJECTION , w_h_initializer ) , partitioner = self . _partitioners . get ( self . W_H_PROJECTION ) , regularizer = self . _regularizers . get ( self . W_H_PROJECTION ) )
Initialize the variables used for the gates.