Your first neural network
It's time for you to implement a small neural network containing two linear layers in sequence.
This exercise is part of the course
Introduction to Deep Learning with PyTorch
Exercise instructions
- Add a container for stacking layers in sequence.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
import torch
import torch.nn as nn
input_tensor = torch.Tensor([[2, 3, 6, 7, 9, 3, 2, 1]])
# Create a container for stacking linear layers
model = nn.____(nn.Linear(8, 4),
nn.Linear(4, 1)
)
output = model(input_tensor)
print(output)