

Public Member Functions | |
| __init__ (self, int num_classes, int input_channels=3, float dropout_rate=0.3) | |
| forward (self, x) | |
Public Attributes | |
| conv1 | |
| bn1 | |
| conv2 | |
| bn2 | |
| conv3 | |
| bn3 | |
| pool | |
| fc1 | |
| fc_bn | |
| fc2 | |
| dropout | |
Protected Attributes | |
| _to_linear | |
A simple CNN model for image classification with regularization to prevent overfitting.
| cnn.CNNModel.__init__ | ( | self, | |
| int | num_classes, | ||
| int | input_channels = 3, |
||
| float | dropout_rate = 0.3 |
||
| ) |
Initialize the CNN model.
Args:
num_classes: Number of classes to classify
input_channels: Number of input channels (1 for grayscale, 3 for RGB)
dropout_rate: Dropout rate for regularization
| cnn.CNNModel.forward | ( | self, | |
| x | |||
| ) |
Forward pass through the network.
Args:
x: Input tensor of shape [batch_size, channels, height, width]
Returns:
Output tensor of shape [batch_size, num_classes]
|
protected |
| cnn.CNNModel.bn1 |
| cnn.CNNModel.bn2 |
| cnn.CNNModel.bn3 |
| cnn.CNNModel.conv1 |
| cnn.CNNModel.conv2 |
| cnn.CNNModel.conv3 |
| cnn.CNNModel.dropout |
| cnn.CNNModel.fc1 |
| cnn.CNNModel.fc2 |
| cnn.CNNModel.fc_bn |
| cnn.CNNModel.pool |