Run one step of LSTM. Args: inputs: input Tensor, 2D, [batch, feature_size]. state: Tensor or tuple of Tensors, 2D, [batch, state_size], depends on the flag self._state_is_tuple. Returns: A tuple containing: - A 2D, [batch, output_dim], Tensor representing t
(self, inputs, state)
| 621 | return self._state_tuple_type |
| 622 | |
| 623 | def call(self, inputs, state): |
| 624 | """Run one step of LSTM. |
| 625 | |
| 626 | Args: |
| 627 | inputs: input Tensor, 2D, [batch, feature_size]. |
| 628 | state: Tensor or tuple of Tensors, 2D, [batch, state_size], depends on the |
| 629 | flag self._state_is_tuple. |
| 630 | |
| 631 | Returns: |
| 632 | A tuple containing: |
| 633 | - A 2D, [batch, output_dim], Tensor representing the output of the LSTM |
| 634 | after reading "inputs" when previous state was "state". |
| 635 | Here output_dim is num_units. |
| 636 | - A 2D, [batch, state_size], Tensor representing the new state of LSTM |
| 637 | after reading "inputs" when previous state was "state". |
| 638 | Raises: |
| 639 | ValueError: if an input_size was specified and the provided inputs have |
| 640 | a different dimension. |
| 641 | """ |
| 642 | batch_size = tensor_shape.dimension_value( |
| 643 | inputs.shape[0]) or array_ops.shape(inputs)[0] |
| 644 | freq_inputs = self._make_tf_features(inputs) |
| 645 | m_out_lst = [] |
| 646 | state_out_lst = [] |
| 647 | for block in range(len(freq_inputs)): |
| 648 | m_out_lst_current, state_out_lst_current = self._compute( |
| 649 | freq_inputs[block], |
| 650 | block, |
| 651 | state, |
| 652 | batch_size, |
| 653 | state_is_tuple=self._state_is_tuple) |
| 654 | m_out_lst.extend(m_out_lst_current) |
| 655 | state_out_lst.extend(state_out_lst_current) |
| 656 | if self._state_is_tuple: |
| 657 | state_out = self._state_tuple_type(*state_out_lst) |
| 658 | else: |
| 659 | state_out = array_ops.concat(state_out_lst, 1) |
| 660 | m_out = array_ops.concat(m_out_lst, 1) |
| 661 | return m_out, state_out |
| 662 | |
| 663 | def _compute(self, |
| 664 | freq_inputs, |