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

Function bidirectional_dynamic_rnn

tensorflow/python/ops/rnn.py:364–514  ·  view source on GitHub ↗

Creates a dynamic version of bidirectional recurrent neural network. Takes input and builds independent forward and backward RNNs. The input_size of forward and backward cell must match. The initial state for both directions is zero by default (but can be set optionally) and no intermediate s

(cell_fw,
                              cell_bw,
                              inputs,
                              sequence_length=None,
                              initial_state_fw=None,
                              initial_state_bw=None,
                              dtype=None,
                              parallel_iterations=None,
                              swap_memory=False,
                              time_major=False,
                              scope=None)

Source from the content-addressed store, hash-verified

362 "this API")
363@tf_export(v1=["nn.bidirectional_dynamic_rnn"])
364def bidirectional_dynamic_rnn(cell_fw,
365 cell_bw,
366 inputs,
367 sequence_length=None,
368 initial_state_fw=None,
369 initial_state_bw=None,
370 dtype=None,
371 parallel_iterations=None,
372 swap_memory=False,
373 time_major=False,
374 scope=None):
375 """Creates a dynamic version of bidirectional recurrent neural network.
376
377 Takes input and builds independent forward and backward RNNs. The input_size
378 of forward and backward cell must match. The initial state for both directions
379 is zero by default (but can be set optionally) and no intermediate states are
380 ever returned -- the network is fully unrolled for the given (passed in)
381 length(s) of the sequence(s) or completely unrolled if length(s) is not
382 given.
383
384 Args:
385 cell_fw: An instance of RNNCell, to be used for forward direction.
386 cell_bw: An instance of RNNCell, to be used for backward direction.
387 inputs: The RNN inputs.
388 If time_major == False (default), this must be a tensor of shape:
389 `[batch_size, max_time, ...]`, or a nested tuple of such elements.
390 If time_major == True, this must be a tensor of shape: `[max_time,
391 batch_size, ...]`, or a nested tuple of such elements.
392 sequence_length: (optional) An int32/int64 vector, size `[batch_size]`,
393 containing the actual lengths for each of the sequences in the batch. If
394 not provided, all batch entries are assumed to be full sequences; and time
395 reversal is applied from time `0` to `max_time` for each sequence.
396 initial_state_fw: (optional) An initial state for the forward RNN. This must
397 be a tensor of appropriate type and shape `[batch_size,
398 cell_fw.state_size]`. If `cell_fw.state_size` is a tuple, this should be a
399 tuple of tensors having shapes `[batch_size, s] for s in
400 cell_fw.state_size`.
401 initial_state_bw: (optional) Same as for `initial_state_fw`, but using the
402 corresponding properties of `cell_bw`.
403 dtype: (optional) The data type for the initial states and expected output.
404 Required if initial_states are not provided or RNN states have a
405 heterogeneous dtype.
406 parallel_iterations: (Default: 32). The number of iterations to run in
407 parallel. Those operations which do not have any temporal dependency and
408 can be run in parallel, will be. This parameter trades off time for
409 space. Values >> 1 use more memory but take less time, while smaller
410 values use less memory but computations take longer.
411 swap_memory: Transparently swap the tensors produced in forward inference
412 but needed for back prop from GPU to CPU. This allows training RNNs which
413 would typically not fit on a single GPU, with very minimal (or no)
414 performance penalty.
415 time_major: The shape format of the `inputs` and `outputs` Tensors. If true,
416 these `Tensors` must be shaped `[max_time, batch_size, depth]`. If false,
417 these `Tensors` must be shaped `[batch_size, max_time, depth]`. Using
418 `time_major = True` is a bit more efficient because it avoids transposes
419 at the beginning and end of the RNN calculation. However, most TensorFlow
420 data is batch-major, so by default this function accepts input and emits
421 output in batch-major form.

Callers

nothing calls this directly

Calls 3

variable_scopeMethod · 0.80
dynamic_rnnFunction · 0.70
_reverseFunction · 0.70

Tested by

no test coverage detected