AlexNet
- class cv.backbones.AlexNet.model.AlexNet(num_classes, in_channels=3)[source]
Bases:
ModuleAlexNet model for image classification based on the paper.
This class defines the AlexNet architecture, which consists of convolutional layers for feature extraction and fully connected layers for classification.
- Parameters:
num_classes (int) – The number of output classes for classification.
in_channels (int, optional) – The number of input channels for the images, typically 3 for RGB (default: 3).
Example
>>> model = AlexNet(num_classes=1000, in_channels=3)
- forward(x)[source]
Defines the forward pass of the AlexNet model.
The input tensor passes through the feature extractor (convolutional layers), then is flattened and passed through the classifier (fully connected layers).
- Parameters:
x (torch.Tensor) – Input tensor of shape (batch_size, in_channels, height, width).
- Returns:
Output tensor after passing through the model, with shape (batch_size, num_classes).
- Return type:
torch.Tensor
Example
>>> output = model(torch.randn(1, 3, 224, 224)) # Example input tensor of shape (batch_size, channels, height, width)