Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create an embedding layer with input dimension 1000 and output dimension 64.
TensorFlow
embedding_layer = tf.keras.layers.Embedding(input_dim=1000, output_dim=[1])
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing input_dim and output_dim values.
Using output_dim larger than necessary.
✗ Incorrect
The output_dim parameter defines the size of the embedding vectors. Here, 64 is the correct size.
2fill in blank
mediumComplete the code to define an embedding layer that accepts input sequences of length 10.
TensorFlow
embedding_layer = tf.keras.layers.Embedding(input_dim=5000, output_dim=50, input_length=[1])
Attempts:
3 left
💡 Hint
Common Mistakes
Setting input_length to output_dim by mistake.
Using input_length larger than actual sequence length.
✗ Incorrect
The input_length parameter specifies the length of input sequences. Here, it is 10.
3fill in blank
hardFix the error in the embedding layer creation by filling the correct input_dim.
TensorFlow
embedding_layer = tf.keras.layers.Embedding(input_dim=[1], output_dim=100)
Attempts:
3 left
💡 Hint
Common Mistakes
Using zero or negative numbers for input_dim.
Confusing input_dim with output_dim.
✗ Incorrect
input_dim must be a positive integer representing vocabulary size. 10000 is a valid size; 0 or negative values cause errors.
4fill in blank
hardFill both blanks to create an embedding layer and get the output shape after passing input of length 7.
TensorFlow
embedding_layer = tf.keras.layers.Embedding(input_dim=[1], output_dim=[2], input_length=7) output_shape = embedding_layer.compute_output_shape((None, 7))
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up input_dim and output_dim values.
Using input_length as a blank instead of fixed 7.
✗ Incorrect
input_dim is 5000 for vocabulary size, output_dim is 64 for embedding size. The output shape will be (None, 7, 64).
5fill in blank
hardFill all three blanks to create an embedding layer, pass input data, and get the shape of the output tensor.
TensorFlow
embedding_layer = tf.keras.layers.Embedding(input_dim=[1], output_dim=[2], input_length=5) input_data = tf.constant([[1, 2, 3, 4, 5]]) output = embedding_layer([3]) output_shape = output.shape
Attempts:
3 left
💡 Hint
Common Mistakes
Passing wrong tensor to embedding layer.
Confusing input_dim and output_dim values.
✗ Incorrect
input_dim is 1000, output_dim is 32, and the input tensor is input_data. The output shape will be (1, 5, 32).
