From 4b7f5e46d83ec260706a30d37f591911c13c4f65 Mon Sep 17 00:00:00 2001 From: Scott Zhu Date: Thu, 10 Dec 2020 15:22:34 -0800 Subject: [PATCH] Add a warning message for usage of feeding keras.Input() to sequential model. The keras.Input() is designed for functional model, and might cause some use confusion when calling model.summary() or plot the model. See https://github.com/tensorflow/tensorflow/issues/45437 for more information. PiperOrigin-RevId: 346877064 Change-Id: I20264fc966e9651c24a7a99b65173ad7e814fc1e --- tensorflow/python/keras/engine/sequential.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tensorflow/python/keras/engine/sequential.py b/tensorflow/python/keras/engine/sequential.py index eff921ee3c1..474dce8307b 100644 --- a/tensorflow/python/keras/engine/sequential.py +++ b/tensorflow/python/keras/engine/sequential.py @@ -178,6 +178,10 @@ class Sequential(functional.Functional): origin_layer = layer._keras_history[0] if isinstance(origin_layer, input_layer.InputLayer): layer = origin_layer + logging.warning( + 'Please add `keras.layers.InputLayer` instead of `keras.Input` to ' + 'Sequential model. `keras.Input` is intended to be used by ' + 'Functional model.') if isinstance(layer, module.Module): if not isinstance(layer, base_layer.Layer):