0
0
TensorFlowml~10 mins

Input shape specification in TensorFlow - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the input shape for a Keras model.

TensorFlow
model = tf.keras.Sequential([
    tf.keras.layers.InputLayer(input_shape=[1]),
    tf.keras.layers.Dense(10, activation='relu')
])
Drag options to blanks, or click blank then click option'
A(28, 28)
B[28, 28]
C28, 28
D28
Attempts:
3 left
💡 Hint
Common Mistakes
Using a list instead of a tuple for input_shape.
Including the batch size in the input shape.
2fill in blank
medium

Complete the code to define an input layer with a 3D input shape.

TensorFlow
inputs = tf.keras.Input(shape=[1])
Drag options to blanks, or click blank then click option'
A(64, 64)
B(64, 64, 3)
C[64, 64, 3]
D64, 64, 3
Attempts:
3 left
💡 Hint
Common Mistakes
Using a list instead of a tuple.
Omitting the color channels dimension.
3fill in blank
hard

Fix the error in the input shape specification for a grayscale image.

TensorFlow
model = tf.keras.Sequential([
    tf.keras.layers.InputLayer(input_shape=[1]),
    tf.keras.layers.Flatten(),
    tf.keras.layers.Dense(10, activation='softmax')
])
Drag options to blanks, or click blank then click option'
A(28, 28, 1)
B28, 28, 1
C[28, 28, 1]
D(28, 28)
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the channel dimension for grayscale images.
Using a list instead of a tuple.
4fill in blank
hard

Fill both blanks to create a model input layer and a dense layer with correct input shape.

TensorFlow
inputs = tf.keras.Input(shape=[1])
x = tf.keras.layers.Dense(32, activation=[2])(inputs)
Drag options to blanks, or click blank then click option'
A(100,)
B'relu'
C'sigmoid'
D(100, 1)
Attempts:
3 left
💡 Hint
Common Mistakes
Using a 2D shape for 1D input data.
Using 'sigmoid' activation in hidden layers instead of 'relu'.
5fill in blank
hard

Fill all three blanks to define a model with input shape, flatten layer, and output layer activation.

TensorFlow
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]])
Drag options to blanks, or click blank then click option'
A(28, 28)
B'softmax'
C'accuracy'
D(28, 28, 3)
Attempts:
3 left
💡 Hint
Common Mistakes
Using color image shape for grayscale input.
Using 'relu' instead of 'softmax' in output layer.
Omitting metrics or using incorrect metric names.