(self, inputs, mask=None, training=None, initial_state=None)
| 902 | ops.executing_eagerly_outside_functions()) |
| 903 | |
| 904 | def call(self, inputs, mask=None, training=None, initial_state=None): |
| 905 | # LSTM does not support constants. Ignore it during process. |
| 906 | inputs, initial_state, _ = self._process_inputs(inputs, initial_state, None) |
| 907 | |
| 908 | if isinstance(mask, list): |
| 909 | mask = mask[0] |
| 910 | |
| 911 | input_shape = K.int_shape(inputs) |
| 912 | timesteps = input_shape[0] if self.time_major else input_shape[1] |
| 913 | |
| 914 | if not self.could_use_cudnn: |
| 915 | # Fall back to use the normal LSTM. |
| 916 | kwargs = {'training': training} |
| 917 | self.cell.reset_dropout_mask() |
| 918 | self.cell.reset_recurrent_dropout_mask() |
| 919 | |
| 920 | def step(inputs, states): |
| 921 | return self.cell.call(inputs, states, **kwargs) |
| 922 | |
| 923 | last_output, outputs, states = K.rnn( |
| 924 | step, |
| 925 | inputs, |
| 926 | initial_state, |
| 927 | constants=None, |
| 928 | go_backwards=self.go_backwards, |
| 929 | mask=mask, |
| 930 | unroll=self.unroll, |
| 931 | input_length=timesteps, |
| 932 | time_major=self.time_major, |
| 933 | zero_output_for_mask=self.zero_output_for_mask) |
| 934 | runtime = _runtime(_RUNTIME_UNKNOWN) |
| 935 | else: |
| 936 | # Use the new defun approach for backend implementation swap. |
| 937 | # Note that different implementations need to have same function |
| 938 | # signature, eg, the tensor parameters need to have same shape and dtypes. |
| 939 | # Since the CuDNN has an extra set of bias, those bias will be passed to |
| 940 | # both normal and CuDNN implementations. |
| 941 | self.reset_dropout_mask() |
| 942 | dropout_mask = self.get_dropout_mask_for_cell(inputs, training, count=4) |
| 943 | if dropout_mask is not None: |
| 944 | inputs = inputs * dropout_mask[0] |
| 945 | cudnn_lstm_kwargs = { |
| 946 | 'inputs': inputs, |
| 947 | 'init_h': initial_state[0], |
| 948 | 'init_c': initial_state[1], |
| 949 | 'kernel': self.cell.kernel, |
| 950 | 'recurrent_kernel': self.cell.recurrent_kernel, |
| 951 | 'bias': self.cell.bias, |
| 952 | 'mask': mask, |
| 953 | 'time_major': self.time_major, |
| 954 | 'go_backwards': self.go_backwards |
| 955 | } |
| 956 | normal_lstm_kwargs = cudnn_lstm_kwargs.copy() |
| 957 | normal_lstm_kwargs.update({ |
| 958 | 'activation': self.activation, |
| 959 | 'recurrent_activation': self.recurrent_activation |
| 960 | }) |
| 961 |
nothing calls this directly
no test coverage detected