Complete the code to specify the input shape for a Keras model.
model = tf.keras.Sequential([
tf.keras.layers.InputLayer(input_shape=[1]),
tf.keras.layers.Dense(10, activation='relu')
])The input_shape argument expects a tuple specifying the shape of each input sample, excluding the batch size. So (28, 28) is correct.
Complete the code to define an input layer with a 3D input shape.
inputs = tf.keras.Input(shape=[1])The input shape for a color image with height and width 64 pixels and 3 color channels is (64, 64, 3). It must be a tuple.
Fix the error in the input shape specification for a grayscale image.
model = tf.keras.Sequential([
tf.keras.layers.InputLayer(input_shape=[1]),
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(10, activation='softmax')
])For grayscale images, the input shape should include the single channel dimension as (28, 28, 1). It must be a tuple.
Fill both blanks to create a model input layer and a dense layer with correct input shape.
inputs = tf.keras.Input(shape=[1]) x = tf.keras.layers.Dense(32, activation=[2])(inputs)
The input shape for a 1D vector of length 100 is (100,). The dense layer activation is commonly set to 'relu' for hidden layers.
Fill all three blanks to define a model with input shape, flatten layer, and output layer activation.
model = tf.keras.Sequential([
tf.keras.layers.InputLayer(input_shape=[1]),
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(10, activation=[2])
])
model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=[[3]])The input shape for grayscale images is (28, 28). The output layer uses 'softmax' activation for multi-class classification. The metric 'accuracy' measures how often predictions are correct.