Complete the code to import the TensorFlow library.
import [1] as tf
TensorFlow is imported as tf to use its functions for building models.
Complete the code to create a Sequential model for sentiment analysis.
model = tf.keras.models.Sequential([tf.keras.layers.Embedding(input_dim=10000, output_dim=16), tf.keras.layers.GlobalAveragePooling1D(), tf.keras.layers.Dense([1], activation='relu'), tf.keras.layers.Dense(1, activation='sigmoid')])
The Dense layer uses 32 units to learn features before the output layer.
Fix the error in the code to compile the model with the correct loss function for binary sentiment classification.
model.compile(optimizer='adam', loss='[1]', metrics=['accuracy'])
Binary crossentropy is the correct loss for binary classification tasks like sentiment analysis.
Fill both blanks to prepare the training data and labels for the model.
train_data = [1] train_labels = [2]
Reviews are the input texts and labels are the sentiment targets for training.
Fill all three blanks to train the model with training data, labels, and set epochs.
history = model.fit([1], [2], epochs=[3], validation_split=0.2)
Model is trained on train_data and train_labels for 10 epochs with 20% validation split.
