Adding a new convolutional layer
Your project lead provided you with a new CNN model. Let's take a look at the model's architecture and append a new convolutional layer to it.
The model is available as CNNModel. The packages torch and torch.nn as nn have been imported.
Bu egzersiz
Deep Learning for Images with PyTorch
kursunun bir parçasıdırEgzersiz talimatları
- Instantiate a model from the
CNNModelclass and access the convolutional layers. - Create a new convolutional layer with
in_channelsequal to existing layer'sout_channels,out_channelsset to 32, andstrideandpaddingboth set to 1, and akernel_sizeof 3; assign it toconv2. - Append the new layer to the model, calling it
"conv2".
Uygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
# Create a model
model = ____
print("Original model: ", model)
# Create a new convolutional layer
conv2 = ____
# Append the new layer to the model
model.____(____)
print("Extended model: ", model)