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

Method _compute

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

Run the actual computation of one step LSTM. Args: freq_inputs: list of Tensors, 2D, [batch, feature_size]. block: int, current frequency block index to process. state: Tensor or tuple of Tensors, 2D, [batch, state_size], it depends on the flag state_is_tuple. ba

(self,
               freq_inputs,
               block,
               state,
               batch_size,
               state_prefix="state",
               state_is_tuple=True)

Source from the content-addressed store, hash-verified

661 return m_out, state_out
662
663 def _compute(self,
664 freq_inputs,
665 block,
666 state,
667 batch_size,
668 state_prefix="state",
669 state_is_tuple=True):
670 """Run the actual computation of one step LSTM.
671
672 Args:
673 freq_inputs: list of Tensors, 2D, [batch, feature_size].
674 block: int, current frequency block index to process.
675 state: Tensor or tuple of Tensors, 2D, [batch, state_size], it depends on
676 the flag state_is_tuple.
677 batch_size: int32, batch size.
678 state_prefix: (optional) string, name prefix for states, defaults to
679 "state".
680 state_is_tuple: boolean, indicates whether the state is a tuple or Tensor.
681
682 Returns:
683 A tuple, containing:
684 - A list of [batch, output_dim] Tensors, representing the output of the
685 LSTM given the inputs and state.
686 - A list of [batch, state_size] Tensors, representing the LSTM state
687 values given the inputs and previous state.
688 """
689 sigmoid = math_ops.sigmoid
690 tanh = math_ops.tanh
691 num_gates = 3 if self._couple_input_forget_gates else 4
692 dtype = freq_inputs[0].dtype
693 actual_input_size = freq_inputs[0].get_shape().as_list()[1]
694
695 concat_w_f = _get_concat_variable(
696 "W_f_%d" % block,
697 [actual_input_size + 2 * self._num_units, num_gates * self._num_units],
698 dtype, self._num_unit_shards)
699 b_f = vs.get_variable(
700 "B_f_%d" % block,
701 shape=[num_gates * self._num_units],
702 initializer=init_ops.zeros_initializer(),
703 dtype=dtype)
704 if not self._share_time_frequency_weights:
705 concat_w_t = _get_concat_variable("W_t_%d" % block, [
706 actual_input_size + 2 * self._num_units, num_gates * self._num_units
707 ], dtype, self._num_unit_shards)
708 b_t = vs.get_variable(
709 "B_t_%d" % block,
710 shape=[num_gates * self._num_units],
711 initializer=init_ops.zeros_initializer(),
712 dtype=dtype)
713
714 if self._use_peepholes:
715 # Diagonal connections
716 if not self._couple_input_forget_gates:
717 w_f_diag_freqf = vs.get_variable(
718 "W_F_diag_freqf_%d" % block, shape=[self._num_units], dtype=dtype)
719 w_f_diag_freqt = vs.get_variable(
720 "W_F_diag_freqt_%d" % block, shape=[self._num_units], dtype=dtype)

Callers 2

callMethod · 0.95
callMethod · 0.45

Calls 12

_get_concat_variableFunction · 0.85
sliceMethod · 0.80
rangeFunction · 0.50
sigmoidClass · 0.50
tanhClass · 0.50
as_listMethod · 0.45
get_shapeMethod · 0.45
get_variableMethod · 0.45
concatMethod · 0.45
matmulMethod · 0.45
splitMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected