parameters: (self, layer)
return_statement: return tf_wts if not is_bidi else tf_wts * 2
docstring: Shapes of Cudnn canonical weight tensors for given layer.
docstring_summary: Shapes of Cudnn canonical weight tensors for given layer.
docstring_tokens: Shapes of Cudnn canonical weight tensors for given layer .
function: def _canonical_weight_shape(self, layer):
      """Shapes of Cudnn canonical weight tensors for given layer."""
      if layer < 0 or layer >= self._num_layers:
        raise ValueError("\'layer\' is not valid, got %s, expecting [%d, %d]" %
                         (layer, 0, self._num_layers - 1))
      if not self._input_size:
        raise RuntimeError(
            "%s._canonical_weight_shape invoked before input shape is known" %
            type(self).__name__)
  
      input_size = self._input_size
      num_units = self._num_units
      num_gates = self._num_params_per_layer // 2
      is_bidi = self._direction == CUDNN_RNN_BIDIRECTION
  
      if layer == 0:
        wts_applied_on_inputs = [(num_units, input_size)] * num_gates
      else:
        if is_bidi:
          wts_applied_on_inputs = [(num_units, 2 * num_units)] * num_gates
        else:
          wts_applied_on_inputs = [(num_units, num_units)] * num_gates
      wts_applied_on_hidden_states = [(num_units, num_units)] * num_gates
      tf_wts = wts_applied_on_inputs + wts_applied_on_hidden_states
      return tf_wts if not is_bidi else tf_wts * 2
function_tokens: def _canonical_weight_shape ( self , layer ) : if layer < 0 or layer >= self . _num_layers : raise ValueError ( "\'layer\' is not valid, got %s, expecting [%d, %d]" % ( layer , 0 , self . _num_layers - 1 ) ) if not self . _input_size : raise RuntimeError ( "%s._canonical_weight_shape invoked before input shape is known" % type ( self ) . __name__ ) input_size = self . _input_size num_units = self . _num_units num_gates = self . _num_params_per_layer // 2 is_bidi = self . _direction == CUDNN_RNN_BIDIRECTION if layer == 0 : wts_applied_on_inputs = [ ( num_units , input_size ) ] * num_gates else : if is_bidi : wts_applied_on_inputs = [ ( num_units , 2 * num_units ) ] * num_gates else : wts_applied_on_inputs = [ ( num_units , num_units ) ] * num_gates wts_applied_on_hidden_states = [ ( num_units , num_units ) ] * num_gates tf_wts = wts_applied_on_inputs + wts_applied_on_hidden_states return tf_wts if not is_bidi else tf_wts * 2