0
0
TensorFlowml~10 mins

Multi-input and multi-output models 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 define two input layers for a multi-input model.

TensorFlow
input1 = tf.keras.Input(shape=[1])
input2 = tf.keras.Input(shape=(10,))
Drag options to blanks, or click blank then click option'
ANone
B32
C[32]
D(32,)
Attempts:
3 left
💡 Hint
Common Mistakes
Using an integer instead of a tuple for input shape.
Using a list instead of a tuple for input shape.
2fill in blank
medium

Complete the code to concatenate two input tensors in the model.

TensorFlow
concat = tf.keras.layers.Concatenate()([input1, [1]])
Drag options to blanks, or click blank then click option'
Ainput2
Binput3
Cinputs
Dinput_2
Attempts:
3 left
💡 Hint
Common Mistakes
Using an undefined variable name.
Using a string instead of a tensor variable.
3fill in blank
hard

Fix the error in the model output definition by selecting the correct output layer.

TensorFlow
output1 = tf.keras.layers.Dense(1, activation='sigmoid')([1])
output2 = tf.keras.layers.Dense(10, activation='softmax')(dense2)
Drag options to blanks, or click blank then click option'
Ainput2
Binput1
Cconcat
Ddense1
Attempts:
3 left
💡 Hint
Common Mistakes
Passing input layers directly to output layers.
Passing unrelated layer outputs.
4fill in blank
hard

Fill both blanks to compile the multi-output model with appropriate loss functions and metrics.

TensorFlow
model.compile(optimizer='adam', loss=[1], metrics=[2])
Drag options to blanks, or click blank then click option'
A{'output1': 'binary_crossentropy', 'output2': 'categorical_crossentropy'}
B['mse', 'mae']
C{'output1': ['accuracy'], 'output2': ['accuracy']}
D['accuracy', 'accuracy']
Attempts:
3 left
💡 Hint
Common Mistakes
Using lists instead of dictionaries for losses and metrics.
Not matching output names in loss and metrics.
5fill in blank
hard

Fill all three blanks to create a multi-input, multi-output model with correct inputs, outputs, and model definition.

TensorFlow
input_a = tf.keras.Input(shape=[1])
input_b = tf.keras.Input(shape=[2])
model = tf.keras.Model(inputs=[input_a, input_b], outputs=[3])
Drag options to blanks, or click blank then click option'
A(64,)
B(10,)
C[output1, output2]
D(32,)
Attempts:
3 left
💡 Hint
Common Mistakes
Using integers instead of tuples for input shapes.
Passing outputs as a tuple instead of a list.