Skip to content

Commit ed6d542

Browse files
Skip None when inference shape when layer has None Input.
PiperOrigin-RevId: 820426089
1 parent 0dec184 commit ed6d542

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tf_keras/engine/base_layer_v1.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2186,8 +2186,10 @@ def _maybe_build(self, inputs):
21862186
else:
21872187
self._set_dtype_policy(policy.Policy(dtype))
21882188
input_shapes = None
2189-
if all(hasattr(x, "shape") for x in input_list):
2190-
input_shapes = tf.nest.map_structure(lambda x: x.shape, inputs)
2189+
if any(hasattr(x, "shape") for x in input_list):
2190+
input_shapes = tf.nest.map_structure(
2191+
lambda x: x.shape if hasattr(x, 'shape') else None, inputs
2192+
)
21912193
# Only call `build` if the user has manually overridden the build
21922194
# method.
21932195
if not hasattr(self.build, "_is_default"):

0 commit comments

Comments
 (0)