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
This commit is contained in:
Scott Zhu 2020-12-10 15:22:34 -08:00 committed by TensorFlower Gardener
parent e5ffdb506b
commit 4b7f5e46d8

View File

@ -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):