Two-output model architecture
In this exercise, you will construct a multi-output neural network architecture capable of predicting the character and the alphabet.
Recall the general structure: in the .__init__() method, you define layers to be used in the forward pass later. In the forward() method, you will first pass the input image through a couple of layers to obtain its embedding, which in turn is fed into two separate classifier layers, one for each output.
torch.nn is already imported under its usual alias, so let's build a model!
Latihan ini adalah bagian dari kursus
Intermediate Deep Learning with PyTorch
Latihan interaktif praktis
Cobalah latihan ini dengan menyelesaikan kode contoh berikut.
class Net(nn.Module):
def __init__(self):
super().__init__()
self.image_layer = nn.Sequential(
nn.Conv2d(1, 16, kernel_size=3, padding=1),
nn.MaxPool2d(kernel_size=2),
nn.ELU(),
nn.Flatten(),
nn.Linear(16*32*32, 128)
)
# Define the two classifier layers
____ = ____
____ = ____