Now that we understand the basic premise behind CNN layers, it's time to take an in-depth look at how they work. Open up code example, which can be found in the Chapter_7_DQN_CNN.py file, and follow these steps:
- At this point, the only code we need to focus on is for a new class called CnnDQN, as shown here:
class CnnDQN(nn.Module): def __init__(self, input_shape, num_actions): super(CnnDQN, self).__init__() self.input_shape = input_shape self.num_actions = num_actions self.features = nn.Sequential( nn.Conv2d(input_shape[0], 32, kernel_size=8, stride=4), nn.ReLU(), nn.Conv2d(32, 64, kernel_size=4, stride=2), nn.ReLU(), nn.Conv2d(64, 64, kernel_size=3, stride=1), nn.ReLU()) self.fc = nn.Sequential( nn.Linear(self.feature_size(), ...