Embedding expects 2D input: (batch_size, sequence_length), but input_data is 1D.
Step 2: Confirm other parameters
output_dim can be smaller than input_dim; input can be integer indices; activation not required.
Final Answer:
input_data should be 2D, not 1D -> Option A
Quick Check:
Embedding input must be 2D tensor [OK]
Hint: Embedding input must be 2D (batch, sequence) [OK]
Common Mistakes:
Using 1D input instead of 2D
Thinking output_dim must exceed input_dim
Adding activation to Embedding unnecessarily
5. You want to build a chatbot using TensorFlow that understands word meaning and context. Which approach best helps TensorFlow handle text effectively?
hard
A. Convert text to uppercase and feed directly to a Conv2D layer
B. Use only a Dense layer on raw text input
C. Use Dropout layers only to prevent overfitting
D. Use an Embedding layer followed by an LSTM layer to capture word vectors and sequence context
Solution
Step 1: Understand text representation needs
Embedding layers convert words to vectors capturing meaning; LSTM layers capture sequence context.
Step 2: Evaluate other options
Dense layers alone can't handle sequences; Conv2D is for images; Dropout only prevents overfitting, not understanding.
Final Answer:
Use an Embedding layer followed by an LSTM layer to capture word vectors and sequence context -> Option D
Quick Check:
Embedding + LSTM = best for text understanding [OK]
Hint: Combine Embedding and LSTM for smart text apps [OK]
Common Mistakes:
Using Dense layers on raw text
Applying Conv2D to text data
Relying only on Dropout layers
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.