Skip to content

Commit ff5d98b

Browse files
committed
Adds test to avoid regression for issue tensorflow#5548.
1 parent 0456403 commit ff5d98b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tensorboard/plugins/graph/keras_util_test.py

+14
Original file line numberDiff line numberDiff line change
@@ -1043,6 +1043,20 @@ def test_keras_model_to_graph_def_functional_multiple_inbound_nodes_from_same_no
10431043

10441044
self.assertGraphDefToModel(expected_proto, model)
10451045

1046+
def test__keras_model_to_graph_def__does_not_crash_with_mixed_precision_dtype_policy(
1047+
self,
1048+
):
1049+
# See https://keras.io/api/mixed_precision/ for more info.
1050+
# Test to avoid regression on issue #5548
1051+
first_layer = tf.keras.layers.Dense(
1052+
1, input_shape=(1,), dtype="mixed_float16"
1053+
)
1054+
model = tf.keras.Sequential([first_layer])
1055+
1056+
model_config = json.loads(model.to_json())
1057+
# This line should not raise errors:
1058+
keras_util.keras_model_to_graph_def(model_config)
1059+
10461060

10471061
class _DoublingLayer(tf.keras.layers.Layer):
10481062
def call(self, inputs):

0 commit comments

Comments
 (0)