MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / build

Method build

tensorflow/python/ops/rnn_cell_impl.py:550–577  ·  view source on GitHub ↗
(self, inputs_shape)

Source from the content-addressed store, hash-verified

548
549 @tf_utils.shape_type_conversion
550 def build(self, inputs_shape):
551 if inputs_shape[-1] is None:
552 raise ValueError("Expected inputs.shape[-1] to be known, saw shape: %s" %
553 str(inputs_shape))
554 _check_supported_dtypes(self.dtype)
555 input_depth = inputs_shape[-1]
556 self._gate_kernel = self.add_variable(
557 "gates/%s" % _WEIGHTS_VARIABLE_NAME,
558 shape=[input_depth + self._num_units, 2 * self._num_units],
559 initializer=self._kernel_initializer)
560 self._gate_bias = self.add_variable(
561 "gates/%s" % _BIAS_VARIABLE_NAME,
562 shape=[2 * self._num_units],
563 initializer=(self._bias_initializer
564 if self._bias_initializer is not None else
565 init_ops.constant_initializer(1.0, dtype=self.dtype)))
566 self._candidate_kernel = self.add_variable(
567 "candidate/%s" % _WEIGHTS_VARIABLE_NAME,
568 shape=[input_depth + self._num_units, self._num_units],
569 initializer=self._kernel_initializer)
570 self._candidate_bias = self.add_variable(
571 "candidate/%s" % _BIAS_VARIABLE_NAME,
572 shape=[self._num_units],
573 initializer=(self._bias_initializer
574 if self._bias_initializer is not None else
575 init_ops.zeros_initializer(dtype=self.dtype)))
576
577 self.built = True
578
579 def call(self, inputs, state):
580 """Gated recurrent unit (GRU) with nunits cells."""

Callers

nothing calls this directly

Calls 2

_check_supported_dtypesFunction · 0.85
add_variableMethod · 0.45

Tested by

no test coverage detected