Where does a TensorFlow model instance get `input` property from?

Viewed 157

I am not talking about how to pass an input to a model.

If you make a model, e.g. from the docs:

model = tf.keras.models.Sequential([
  tf.keras.layers.Flatten(input_shape=(28, 28)),
  tf.keras.layers.Dense(128, activation='relu'),
  tf.keras.layers.Dropout(0.2),
  tf.keras.layers.Dense(10, activation='softmax')
])

model actually has a few properties (or attributes) which are not listed in the documentation... These include input, inputs, name, and much more. I've listed them with dir(), but surely its documented somewhere.

I would like to know what exactly these are. It really seems like a silly question. Maybe there is a different document I cannot find?

1 Answers

The class tf.keras.Model inherits from tf.keras.layers.Layer, which inherits from tf.Module. The model instance will have attributes from those classes as well.

  • inputs comes from tf.keras.Model. You pass inputs= when you create a model.
  • input comes from tf.keras.layers.Layer
  • name is defined in both tf.keras.layers.Layer and tf.Module
Related