0
0
PyTorchml~10 mins

Why CNNs detect spatial patterns in PyTorch - Test Your Understanding

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

Complete the code to create a 2D convolutional layer with 3 input channels and 16 output channels.

PyTorch
conv_layer = torch.nn.Conv2d([1], 16, kernel_size=3, stride=1, padding=1)
Drag options to blanks, or click blank then click option'
A1
B16
C32
D3
Attempts:
3 left
💡 Hint
Common Mistakes
Using output channels instead of input channels
Confusing kernel size with channels
2fill in blank
medium

Complete the code to apply the convolutional layer to the input tensor.

PyTorch
output = conv_layer([1])
Drag options to blanks, or click blank then click option'
Aconv_layer
Binput_tensor
Coutput
Dtorch.nn
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the layer itself instead of the input
Passing the output variable before assignment
3fill in blank
hard

Fix the error in the code to correctly initialize the convolutional layer with a 5x5 kernel.

PyTorch
conv_layer = torch.nn.Conv2d(3, 16, kernel_size=[1], stride=1, padding=2)
Drag options to blanks, or click blank then click option'
A5
B7
C1
D3
Attempts:
3 left
💡 Hint
Common Mistakes
Using kernel size 3 instead of 5
Incorrect padding for kernel size
4fill in blank
hard

Fill both blanks to create a feature map by applying a convolution and then a ReLU activation.

PyTorch
conv_layer = torch.nn.Conv2d(3, 8, kernel_size=3, padding=1)
output = conv_layer([1])
activated_output = torch.nn.functional.[2](output)
Drag options to blanks, or click blank then click option'
Ainput_tensor
Bsigmoid
Crelu
Doutput_tensor
Attempts:
3 left
💡 Hint
Common Mistakes
Using output_tensor instead of input_tensor
Using sigmoid instead of relu
5fill in blank
hard

Fill all three blanks to create a simple CNN block: convolution, activation, and max pooling.

PyTorch
conv = torch.nn.Conv2d(1, [1], kernel_size=3, padding=1)
x = conv([2])
x = torch.nn.functional.[3](x)
x = torch.nn.functional.max_pool2d(x, 2)
Drag options to blanks, or click blank then click option'
A10
Binput_image
Crelu
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Using too many output channels
Passing wrong variable as input
Using wrong activation function