0
0
TensorFlowml~10 mins

Time series with RNN 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 a simple RNN layer for time series data.

TensorFlow
model = tf.keras.Sequential([
    tf.keras.layers.SimpleRNN([1], input_shape=(10, 1))
])
Drag options to blanks, or click blank then click option'
A32
B0.1
Crelu
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Using an activation function or dropout rate instead of units.
Setting input_shape as the number of units.
2fill in blank
medium

Complete the code to compile the RNN model with mean squared error loss.

TensorFlow
model.compile(optimizer='adam', loss=[1], metrics=['mae'])
Drag options to blanks, or click blank then click option'
A'accuracy'
B'binary_crossentropy'
C'categorical_crossentropy'
D'mse'
Attempts:
3 left
💡 Hint
Common Mistakes
Using classification loss functions like 'accuracy' or 'categorical_crossentropy'.
3fill in blank
hard

Fix the error in the code to correctly reshape the input data for the RNN.

TensorFlow
X_train = X_train.reshape((X_train.shape[0], [1], 1))
Drag options to blanks, or click blank then click option'
AX_train.shape[1]
BX_train.shape[0]
C1
DX_train.shape[2]
Attempts:
3 left
💡 Hint
Common Mistakes
Using the batch size or feature dimension incorrectly.
Setting time steps to 1 which loses sequence information.
4fill in blank
hard

Fill both blanks to add a Dense output layer for univariate time series regression.

TensorFlow
tf.keras.layers.Dense([1], activation=[2])
Drag options to blanks, or click blank then click option'
A1
B'linear'
C32
D'relu'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'relu' activation which clips negative values.
Setting units to hidden size like 32 instead of output size.
5fill in blank
hard

Fill all three blanks to train the RNN model with standard hyperparameters.

TensorFlow
history = model.fit(X_train, y_train, epochs=[1], batch_size=[2], validation_split=[3])
Drag options to blanks, or click blank then click option'
A50
B32
C0.2
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Using too few epochs like 10.
Omitting validation_split or using invalid values.