IniziaInizia gratis

Classifier block

Your next task is to create a classifier block that will replace the original VGG16 classifier. You decide to use a block with two fully connected layers with a ReLU activation in between.

The vgg_model and input_dim you defined in the last exercise are available in your workspace, and torch and torchvision.models have been imported.

Questo esercizio fa parte del corso

Deep Learning for Images with PyTorch

Visualizza il corso

Istruzioni dell'esercizio

  • Create a variable num_classes with the number of classes assuming you're dealing with detecting cats and dogs only.
  • Create a sequential block using nn.Sequential.
  • Create a linear layer with in_features set to input_dim.
  • Add the output features to the classifier's last layer.

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

# Create a variable with the number of classes
____
    
# Create a sequential block
classifier = ____(
	# Create a linear layer with input features
	____(____, 512),
	nn.ReLU(),
	# Add the output dimension to the classifier
	nn.Linear(512, ____),
)
Modifica ed esegui il codice