Skip to content

Commit 2a5ec79

Browse files
Soontoshuser17359
andcommitted
Updated text_callable section of README for cross-version compatability (issue #83)
Co-authored-by: Santosh Patapati <sapatapatiwork@gmail.com> Co-authored-by: Ryszard Błażej <blazejryszard@gmail.com>
1 parent 2b12f8e commit 2a5ec79

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,17 @@ def text_callable(layer_index, layer):
145145
above = bool(layer_index%2)
146146

147147
# Get the output shape of the layer
148-
output_shape = [x for x in list(layer.output_shape) if x is not None]
148+
if hasattr(layer, 'output_shape'):
149+
# ───────────────────────────────
150+
# Legacy Keras (standalone 2.x) or TF-Keras <2.11
151+
# ───────────────────────────────
152+
# this will work so long as `layer.output_shape` exists
153+
output_shape = [x for x in list(layer.output.shape) if x is not None]
154+
else:
155+
# ───────────────────────────────
156+
# Modern TF-Keras (>= 2.11) – attribute removed
157+
# ───────────────────────────────
158+
output_shape = layer.output.shape.as_list()
149159

150160
# If the output shape is a list of tuples, we only take the first one
151161
if isinstance(output_shape[0], tuple):

0 commit comments

Comments
 (0)