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

Method call

tensorflow/contrib/rnn/python/ops/rnn_cell.py:2643–2735  ·  view source on GitHub ↗

Run one step of LSTM. Args: inputs: input Tensor, 2D, batch x num_units. state: this must be a tuple of state Tensors, both `2-D`, with column sizes `c_state` and `m_state`. Returns: A tuple containing: - A `2-D, [batch x output_dim]`, Tensor represe

(self, inputs, state)

Source from the content-addressed store, hash-verified

2641 return res
2642
2643 def call(self, inputs, state):
2644 """Run one step of LSTM.
2645
2646 Args:
2647 inputs: input Tensor, 2D, batch x num_units.
2648 state: this must be a tuple of state Tensors,
2649 both `2-D`, with column sizes `c_state` and
2650 `m_state`.
2651
2652 Returns:
2653 A tuple containing:
2654
2655 - A `2-D, [batch x output_dim]`, Tensor representing the output of the
2656 LSTM after reading `inputs` when previous state was `state`.
2657 Here output_dim is:
2658 num_proj if num_proj was set,
2659 num_units otherwise.
2660 - Tensor(s) representing the new state of LSTM after reading `inputs` when
2661 the previous state was `state`. Same type and shape(s) as `state`.
2662
2663 Raises:
2664 ValueError: If input size cannot be inferred from inputs via
2665 static shape inference.
2666 """
2667 sigmoid = math_ops.sigmoid
2668
2669 (c_prev, m_prev) = state
2670
2671 dtype = inputs.dtype
2672 input_size = inputs.get_shape().with_rank(2).dims[1]
2673 if input_size.value is None:
2674 raise ValueError("Could not infer input size from inputs.get_shape()[-1]")
2675 scope = vs.get_variable_scope()
2676 with vs.variable_scope(scope, initializer=self._initializer) as unit_scope:
2677
2678 # i = input_gate, j = new_input, f = forget_gate, o = output_gate
2679 lstm_matrix = self._linear(
2680 [inputs, m_prev],
2681 4 * self._num_units,
2682 bias=True,
2683 bias_initializer=None,
2684 layer_norm=self._layer_norm)
2685 i, j, f, o = array_ops.split(
2686 value=lstm_matrix, num_or_size_splits=4, axis=1)
2687
2688 if self._layer_norm:
2689 i = _norm(self._norm_gain, self._norm_shift, i, "input")
2690 j = _norm(self._norm_gain, self._norm_shift, j, "transform")
2691 f = _norm(self._norm_gain, self._norm_shift, f, "forget")
2692 o = _norm(self._norm_gain, self._norm_shift, o, "output")
2693
2694 # Diagonal connections
2695 if self._use_peepholes:
2696 with vs.variable_scope(unit_scope):
2697 w_f_diag = vs.get_variable(
2698 "w_f_diag", shape=[self._num_units], dtype=dtype)
2699 w_i_diag = vs.get_variable(
2700 "w_i_diag", shape=[self._num_units], dtype=dtype)

Callers

nothing calls this directly

Calls 8

_linearMethod · 0.95
_normFunction · 0.85
with_rankMethod · 0.80
variable_scopeMethod · 0.80
sigmoidClass · 0.50
get_shapeMethod · 0.45
splitMethod · 0.45
get_variableMethod · 0.45

Tested by

no test coverage detected