0

I have a simple neural network of 2 layers, recognizing 10 classes:

self.layer1 = nn.Sequential(
    nn.Conv2d(1, 32, kernel_size=5, stride=1, padding=2),
    nn.ReLU(),
    nn.MaxPool2d(kernel_size=2, stride=2))
self.fc1 = nn.Linear(14 * 14 * 32, 10)

How can a classification be made using the convolutional layer in this case?

Hey
  • 1
  • 2

1 Answers1

1

You need Dense() layers after convolution / pooling layers. Conv and max-pool are meant to process pixel data in a format that can be later received from dense layers. It's the Dense() output layer that, using a softmax activation, can technically perform the classification (by returning a one-hot encoded vector).

Leevo
  • 6,225
  • 3
  • 16
  • 52
  • But Dense and Linear are one and the same. I want to know if there is a way to classify an object other than using a fully connected layer? – Hey Jul 16 '19 at 12:57
  • Dense layers are not necessarily "linear", that depends on your choice of activation functions. However, I don't think it's possible to classify observations without Dense layers. – Leevo Jul 16 '19 at 13:00
  • See "fully convolutional network" – Ben Reiniger Dec 13 '19 at 22:31