Challenge - 5 Problems
Sentiment Analysis Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateOutput of model prediction on sample input
Given the following TensorFlow model for sentiment analysis, what is the output shape of the prediction for a batch of 3 samples?
TensorFlow
import tensorflow as tf model = tf.keras.Sequential([ tf.keras.layers.Embedding(input_dim=10000, output_dim=16, input_length=100), tf.keras.layers.GlobalAveragePooling1D(), tf.keras.layers.Dense(16, activation='relu'), tf.keras.layers.Dense(1, activation='sigmoid') ]) sample_input = tf.constant([[1]*100, [2]*100, [3]*100]) prediction = model(sample_input) output_shape = prediction.shape
Attempts:
2 left
💡 Hint
The model outputs one value per input sample indicating sentiment probability.
✗ Incorrect
The model processes a batch of 3 samples, each producing a single sigmoid output, so the output shape is (3, 1).
❓ Model Choice
intermediateBest model layer for capturing word order in sentiment analysis
Which layer is best suited to capture the order of words in a sentence for sentiment analysis?
Attempts:
2 left
💡 Hint
Consider which layer can remember sequences over time.
✗ Incorrect
LSTM layers are designed to capture sequential dependencies and word order, which is important for sentiment analysis.
❓ Hyperparameter
advancedChoosing the right batch size for training sentiment analysis model
You are training a sentiment analysis model on a dataset of 10,000 samples. Which batch size is likely to provide a good balance between training speed and model convergence?
Attempts:
2 left
💡 Hint
Very small batch sizes slow training; very large batch sizes may harm convergence.
✗ Incorrect
A batch size of 16 is small enough to provide frequent updates and large enough for efficient computation.
❓ Metrics
advancedInterpreting accuracy and loss during sentiment analysis training
During training a binary sentiment analysis model, you observe that the training loss decreases steadily but the validation accuracy remains around 50%. What does this indicate?
Attempts:
2 left
💡 Hint
Consider what it means when training improves but validation does not.
✗ Incorrect
Decreasing training loss with poor validation accuracy suggests overfitting: the model memorizes training data but fails to generalize.
🔧 Debug
expertIdentifying cause of NaN loss during sentiment analysis training
You train a sentiment analysis model and suddenly the loss becomes NaN after a few epochs. Which of the following is the most likely cause?
Attempts:
2 left
💡 Hint
NaN loss often happens when updates are too large and cause numerical instability.
✗ Incorrect
A very high learning rate can cause weights to update too aggressively, leading to NaN loss values.
