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

Function _is_keras_rnn_cell

tensorflow/python/ops/rnn.py:145–165  ·  view source on GitHub ↗

Check whether the cell is a Keras RNN cell. The Keras RNN cell accept the state as a list even the state is a single tensor, whereas the TF RNN cell does not wrap single state tensor in list. This behavior difference should be unified in future version. Args: rnn_cell: An RNN cell inst

(rnn_cell)

Source from the content-addressed store, hash-verified

143
144
145def _is_keras_rnn_cell(rnn_cell):
146 """Check whether the cell is a Keras RNN cell.
147
148 The Keras RNN cell accept the state as a list even the state is a single
149 tensor, whereas the TF RNN cell does not wrap single state tensor in list.
150 This behavior difference should be unified in future version.
151
152 Args:
153 rnn_cell: An RNN cell instance that either follow the Keras interface or TF
154 RNN interface.
155
156 Returns:
157 Boolean, whether the cell is an Keras RNN cell.
158 """
159 # Cell type check is not strict enough since there are cells created by other
160 # library like Deepmind that didn't inherit tf.nn.rnn_cell.RNNCell.
161 # Keras cells never had zero_state method, which was from the original
162 # interface from TF RNN cell.
163 return (not isinstance(rnn_cell, rnn_cell_impl.RNNCell) and
164 isinstance(rnn_cell, base_layer.Layer) and
165 getattr(rnn_cell, "zero_state", None) is None)
166
167
168# pylint: disable=unused-argument

Callers 2

_time_stepFunction · 0.85
static_rnnFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected