0
0
TensorFlowml~10 mins

Sequence-to-sequence basics in TensorFlow - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create an embedding layer for the encoder input.

TensorFlow
encoder_embedding = tf.keras.layers.Embedding(input_dim=10000, output_dim=[1])(encoder_inputs)
Drag options to blanks, or click blank then click option'
A128
B64
C256
D512
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing too small or too large embedding size without reason.
2fill in blank
medium

Complete the code to define the encoder LSTM layer with 256 units.

TensorFlow
encoder_lstm = tf.keras.layers.LSTM([1], return_state=True)
Drag options to blanks, or click blank then click option'
A64
B256
C512
D128
Attempts:
3 left
💡 Hint
Common Mistakes
Using a number too small to capture sequence complexity.
3fill in blank
hard

Fix the error in the decoder LSTM call to use the encoder states as initial state.

TensorFlow
decoder_outputs, _, _ = decoder_lstm(decoder_embedding, initial_state=[1])
Drag options to blanks, or click blank then click option'
Aencoder_states
Bdecoder_states
Cencoder_outputs
Ddecoder_embedding
Attempts:
3 left
💡 Hint
Common Mistakes
Passing encoder_outputs instead of encoder_states.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps words to their lengths only if length is greater than 3.

TensorFlow
word_lengths = {word: [1] for word in words if [2]
Drag options to blanks, or click blank then click option'
Alen(word)
Blen(word) > 3
Cword.startswith('a')
Dword.isalpha()
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong condition or value in comprehension.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps uppercase words to their lengths if length is less than 5.

TensorFlow
result = [1]: [2] for word in words if [3]
Drag options to blanks, or click blank then click option'
Aword.upper()
Blen(word)
Clen(word) < 5
Dword.lower()
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up keys and values or wrong condition.