Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to define a simple convolutional layer in a neural network.
Computer Vision
conv_layer = Conv2D(filters=32, kernel_size=3, activation=[1])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'softmax' in a convolutional layer activation instead of ReLU.
Forgetting to add an activation function.
✗ Incorrect
The ReLU activation function is commonly used in convolutional layers to introduce non-linearity and help the model learn complex patterns.
2fill in blank
mediumComplete the code to add a pooling layer after a convolutional layer.
Computer Vision
pool_layer = MaxPooling2D(pool_size=[1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a pool size of (1, 1) which does not reduce dimensions.
Choosing too large pool sizes that overly reduce feature maps.
✗ Incorrect
A pool size of (2, 2) is commonly used to reduce the spatial dimensions by half, helping to reduce computation and control overfitting.
3fill in blank
hardFix the error in the code to correctly compile a model with categorical crossentropy loss.
Computer Vision
model.compile(optimizer='adam', loss=[1], metrics=['accuracy'])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'binary_crossentropy' for multi-class problems.
Using regression loss functions like 'mean_squared_error' incorrectly.
✗ Incorrect
For multi-class classification problems, 'categorical_crossentropy' is the correct loss function to use.
4fill in blank
hardFill both blanks to create a dictionary comprehension that maps layer names to their output shapes if the output has more than 2 dimensions.
Computer Vision
layer_shapes = {layer.name: layer.output_shape for layer in model.layers if [1] > [2] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Comparing layer.name to a number.
Using layer.output_shape directly in comparison without len().
✗ Incorrect
We use len(layer.output_shape) to get the number of dimensions and filter layers with output shapes having more than 2 dimensions.
5fill in blank
hardFill all three blanks to create a dictionary comprehension that maps layer names to the number of parameters if the layer has more than 1000 parameters.
Computer Vision
param_counts = {layer.[1]: layer.[2] for layer in model.layers if layer.[3] > 1000} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using layer.output_shape instead of count_params().
Not calling count_params() as a method.
✗ Incorrect
We access layer.name for the key, use layer.count_params() to get the number of parameters for the value and filter layers with more than 1000 parameters.