Update the docstring for Bidirectional wrapper wrt to the layer used.

For any custom layer to work with Bidirectional wrapper, the layer need to support "go_backwards" as its init parameter and property.

PiperOrigin-RevId: 293904336
Change-Id: Id65eff898e3acc6d33897f4671c042167f178958
This commit is contained in:
Scott Zhu 2020-02-07 15:10:23 -08:00 committed by TensorFlower Gardener
parent bb27042bae
commit 8ff354d254

View File

@ -353,21 +353,30 @@ class Bidirectional(Wrapper):
"""Bidirectional wrapper for RNNs. """Bidirectional wrapper for RNNs.
Arguments: Arguments:
layer: `Recurrent` instance. layer: `keras.layers.RNN` instance, such as `keras.layers.LSTM` or
merge_mode: Mode by which outputs of the `keras.layers.GRU`. It could also be a `keras.layers.Layer` instance
forward and backward RNNs will be combined. that meets the following criteria:
One of {'sum', 'mul', 'concat', 'ave', None}. 1. Be a sequence-processing layer (accepts 3D+ inputs).
If None, the outputs will not be combined, 2. Have a `go_backwards`, `return_sequences` and `return_state`
they will be returned as a list. attribute (with the same semantics as for the `RNN` class).
backward_layer: Optional `Recurrent` instance to be used to handle 3. Have an `input_spec` attribute.
backwards input processing. If `backward_layer` is not provided, 4. Implement serialization via `get_config()` and `from_config()`.
the layer instance passed as the `layer` argument will be used to Note that the recommended way to create new RNN layers is to write a
generate the backward layer automatically. custom RNN cell and use it with `keras.layers.RNN`, instead of
subclassing `keras.layers.Layer` directly.
merge_mode: Mode by which outputs of the forward and backward RNNs will be
combined. One of {'sum', 'mul', 'concat', 'ave', None}. If None, the
outputs will not be combined, they will be returned as a list. Default
value is 'concat'.
backward_layer: Optional `keras.layers.RNN`, or keras.layers.Layer` instance
to be used to handle backwards input processing. If `backward_layer` is
not provided, the layer instance passed as the `layer` argument will be
used to generate the backward layer automatically.
Note that the provided `backward_layer` layer should have properties Note that the provided `backward_layer` layer should have properties
matching those of the `layer` argument, in particular it should have the matching those of the `layer` argument, in particular it should have the
same values for `stateful`, `return_states`, `return_sequence`, etc. same values for `stateful`, `return_states`, `return_sequence`, etc.
In addition, `backward_layer` and `layer` should have In addition, `backward_layer` and `layer` should have different
different `go_backwards` argument values. `go_backwards` argument values.
A `ValueError` will be raised if these requirements are not met. A `ValueError` will be raised if these requirements are not met.
Call arguments: Call arguments: