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

Function assert_like_rnncell

tensorflow/python/ops/rnn_cell_impl.py:71–102  ·  view source on GitHub ↗

Raises a TypeError if cell is not like an RNNCell. NOTE: Do not rely on the error message (in particular in tests) which can be subject to change to increase readability. Use ASSERT_LIKE_RNNCELL_ERROR_REGEXP. Args: cell_name: A string to give a meaningful error referencing to the name

(cell_name, cell)

Source from the content-addressed store, hash-verified

69
70
71def assert_like_rnncell(cell_name, cell):
72 """Raises a TypeError if cell is not like an RNNCell.
73
74 NOTE: Do not rely on the error message (in particular in tests) which can be
75 subject to change to increase readability. Use
76 ASSERT_LIKE_RNNCELL_ERROR_REGEXP.
77
78 Args:
79 cell_name: A string to give a meaningful error referencing to the name of
80 the functionargument.
81 cell: The object which should behave like an RNNCell.
82
83 Raises:
84 TypeError: A human-friendly exception.
85 """
86 conditions = [
87 _hasattr(cell, "output_size"),
88 _hasattr(cell, "state_size"),
89 _hasattr(cell, "get_initial_state") or _hasattr(cell, "zero_state"),
90 callable(cell),
91 ]
92 errors = [
93 "'output_size' property is missing", "'state_size' property is missing",
94 "either 'zero_state' or 'get_initial_state' method is required",
95 "is not callable"
96 ]
97
98 if not all(conditions):
99
100 errors = [error for error, cond in zip(errors, conditions) if not cond]
101 raise TypeError("The argument {!r} ({}) is not an RNNCell: {}.".format(
102 cell_name, cell, ", ".join(errors)))
103
104
105def _concat(prefix, suffix, static=False):

Callers 2

__init__Method · 0.85
from_configMethod · 0.85

Calls 4

_hasattrFunction · 0.85
allFunction · 0.85
formatMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected