Complete the code to import TensorFlow correctly.
import [1] as tf
TensorFlow is imported using the name 'tensorflow'. This is the standard import for using TensorFlow in Python.
Complete the code to create a simple sequential model in TensorFlow.
model = tf.keras.models.Sequential([tf.keras.layers.Dense([1], activation='relu')])
The Dense layer requires the number of units as an integer. Here, 10 units are specified.
Fix the error in compiling the model by filling the correct optimizer name.
model.compile(optimizer='[1]', loss='sparse_categorical_crossentropy', metrics=['accuracy'])
The optimizer name should be a valid TensorFlow optimizer string like 'adam'.
Fill both blanks to train the model with data and epochs.
history = model.fit([1], [2], epochs=5)
The fit method requires training data inputs and labels, which are x_train and y_train respectively.
Fill all three blanks to evaluate the model and print accuracy.
loss, [1] = model.evaluate([2], [3]) print(f'Accuracy: {accuracy:.2f}')
The evaluate method returns loss and accuracy. The inputs are x_test and y_test. We assign accuracy to the second variable and print it.