Get startedGet started for free

Box regressor block

Your final task is to create a regressor block to predict bounding box coordinates. You decide to have a block with 2 fully connected layers with a ReLU activation in between, similar to the classifier you defined earlier.

Your vgg_model and input_dim are still available and torch and torchvision.models have been imported.

This exercise is part of the course

Deep Learning for Images with PyTorch

View Course

Exercise instructions

  • Create a variable num_coordinates with the number of boundary box coordinates to predict.
  • Define the appropriate input dimension for the first linear layer and set the output dimension to 32.
  • Define the appropriate output dimension in the regressor's last layer.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Define the number of coordinates
____

bb = nn.Sequential(  
	# Add input and output dimensions
	nn.Linear(____, ____),
	nn.ReLU(),
	# Add the output for the last regression layer
	nn.Linear(32, ____),
)
Edit and Run Code