22.02.2024 Views

Daniel Voigt Godoy - Deep Learning with PyTorch Step-by-Step A Beginner’s Guide-leanpub

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

The next part of our model, the classifier part, uses these features to feed what

would be a simple neural network with a single hidden layer if considered on its

own:

Model Configuration - Classifier

1 # Classification

2 # Hidden Layer

3 model_cnn1.add_module('fc1',

4 nn.Linear(in_features=n_channels*4*4, out_features=10)

5 )

6 model_cnn1.add_module('relu2', nn.ReLU())

7 # Output Layer

8 model.add_module('fc2', nn.Linear(in_features=10, out_features=3))

See? There is a hidden layer that takes the 16 features as inputs and maps them

into a ten-dimensional space that is going to be "activated" by the ReLU.

Then, the output layer produces three distinct linear combinations of the ten

activation values, each combination corresponding to a different class. The figure

below, depicting the second half of the model, should make it more clear.

Figure 5.17 - Classifier with softmax output

386 | Chapter 5: Convolutions

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!