Understanding input_shape argument for Dense layer in Lab1

Hi,
the code for the model in Lab1 has the input_shape parameter:

model = tf.keras.Sequential([keras.layers.Dense(units=1, input_shape=[1])])

Our training data set has a batch size of 6. In the documentation, tf.keras.layers.Dense  |  TensorFlow v2.12.0 , there is no mention of this argument.

further down the documentation, Input Shape, it says: N-D tensor with shape: (batch_size, …, input_dim)

tried removing this argument from the layer, the code did not work.

Please, advise what is this arg for.

Thanks in advance!

We’re doing OOP here, so they don’t always document every attribute that is inherited from parent classes at every possible child layer. That is inherited from tf.keras.layers.Layer, so try reading the documentation for that.

1 Like

input_shape is specified for the 1st layer of a model. It refers to the shape of a single data point, excluding the batch dimension.

1 Like