Building a deeper neural network
So far, our neural network architecture only has one hidden layer. In this section, we will contrast the performance of models where there are two hidden layers and no hidden layer (with no hidden layer being a logistic regression).
A model with two layers within a network can be built as follows (note that we have kept the number of units in the second hidden layer set to 1,000). The modified get_model
function (from the code in the Batch size of 32 section), where there are two hidden layers, is as follows:
The full code can be found in the Impact_of_building_a_deeper_neural_network.ipynb
file located in the Chapter03
folder on GitHub at https://bit.ly/mcvp-2e. For the sake of brevity, we will not detail every step from the Batch size of 32 section. Please refer to the notebooks on GitHub while executing the code.
def get_model():
model = nn.Sequential(
nn.Linear(28 * 28, 1000),
nn.ReLU...