(self, inputs, mask=None, training=None, initial_state=None)
| 310 | reset_after and ops.executing_eagerly_outside_functions()) |
| 311 | |
| 312 | def call(self, inputs, mask=None, training=None, initial_state=None): |
| 313 | # GRU does not support constants. Ignore it during process. |
| 314 | inputs, initial_state, _ = self._process_inputs(inputs, initial_state, None) |
| 315 | |
| 316 | if isinstance(mask, list): |
| 317 | mask = mask[0] |
| 318 | |
| 319 | input_shape = K.int_shape(inputs) |
| 320 | timesteps = input_shape[0] if self.time_major else input_shape[1] |
| 321 | |
| 322 | if not self.could_use_cudnn: |
| 323 | kwargs = {'training': training} |
| 324 | self.cell.reset_dropout_mask() |
| 325 | self.cell.reset_recurrent_dropout_mask() |
| 326 | |
| 327 | def step(cell_inputs, cell_states): |
| 328 | return self.cell.call(cell_inputs, cell_states, **kwargs) |
| 329 | |
| 330 | last_output, outputs, states = K.rnn( |
| 331 | step, |
| 332 | inputs, |
| 333 | initial_state, |
| 334 | constants=None, |
| 335 | go_backwards=self.go_backwards, |
| 336 | mask=mask, |
| 337 | unroll=self.unroll, |
| 338 | input_length=timesteps, |
| 339 | time_major=self.time_major, |
| 340 | zero_output_for_mask=self.zero_output_for_mask) |
| 341 | # This is a dummy tensor for testing purpose. |
| 342 | runtime = _runtime(_RUNTIME_UNKNOWN) |
| 343 | else: |
| 344 | last_output, outputs, runtime, states = self._defun_gru_call( |
| 345 | inputs, initial_state, training, mask) |
| 346 | |
| 347 | if self.stateful: |
| 348 | updates = [state_ops.assign(self.states[0], states[0])] |
| 349 | self.add_update(updates) |
| 350 | |
| 351 | if self.return_sequences: |
| 352 | output = outputs |
| 353 | else: |
| 354 | output = last_output |
| 355 | |
| 356 | if self.return_state: |
| 357 | return [output] + list(states) |
| 358 | elif self._return_runtime: |
| 359 | return output, runtime |
| 360 | else: |
| 361 | return output |
| 362 | |
| 363 | def _defun_gru_call(self, inputs, initial_state, training, mask): |
| 364 | # Use the new defun approach for backend implementation swap. |
no test coverage detected