LSNet model for document classification. More...


Public Member Functions | |
| __init__ (self, num_classes=16, model_size='s', dropout_rate=0.5) | |
| Constructor for LSNet model. | |
| forward (self, x) | |
| Forward pass through the LSNet model. | |
Public Attributes | |
| channels | |
| num_blocks | |
| conv1 | |
| maxpool | |
| layer1 | |
| layer2 | |
| layer3 | |
| layer4 | |
| avgpool | |
| dropout | |
| fc | |
Protected Member Functions | |
| _initialize_weights (self) | |
| Initialize weights for the model. | |
| _make_layer (self, in_channels, out_channels, num_blocks, stride=1) | |
| Create a layer of LS Blocks. | |
LSNet model for document classification.
This model implements the LSNet architecture for document classification, using LS Convolution and LS Blocks to achieve efficient and effective feature extraction and classification.
LSNet model as described in the paper. This model uses LS Convolution and LS Blocks to achieve efficient and effective feature extraction and classification.
| lsnet.LSNet.__init__ | ( | self, | |
num_classes = 16, |
|||
model_size = 's', |
|||
dropout_rate = 0.5 |
|||
| ) |
Constructor for LSNet model.
| num_classes | Number of classes to classify |
| model_size | Size of the model ('t' for tiny, 's' for small, 'b' for base) |
| dropout_rate | Dropout probability |
Initialize the LSNet model.
Args:
num_classes: Number of classes to classify (default: 1000 for ImageNet)
model_size: Size of the model ('t' for tiny, 's' for small, 'b' for base)
dropout_rate: Dropout probability (default: 0.5)
|
protected |
Initialize weights for the model.
|
protected |
Create a layer of LS Blocks.
| in_channels | Number of input channels |
| out_channels | Number of output channels |
| num_blocks | Number of LS Blocks in the layer |
| stride | Stride of the first LS Block |
Create a layer of LS Blocks.
Args:
in_channels: Number of input channels
out_channels: Number of output channels
num_blocks: Number of LS Blocks in the layer
stride: Stride of the first LS Block (default: 1)
Returns:
Sequential module containing LS Blocks
| lsnet.LSNet.forward | ( | self, | |
| x | |||
| ) |
Forward pass through the LSNet model.
| x | Input tensor of shape [batch_size, 3, height, width] |
Forward pass through the LSNet model.
Args:
x: Input tensor of shape [batch_size, 3, height, width]
Returns:
Output tensor of shape [batch_size, num_classes]
| lsnet.LSNet.avgpool |
| lsnet.LSNet.channels |
| lsnet.LSNet.conv1 |
| lsnet.LSNet.dropout |
| lsnet.LSNet.fc |
| lsnet.LSNet.layer1 |
| lsnet.LSNet.layer2 |
| lsnet.LSNet.layer3 |
| lsnet.LSNet.layer4 |
| lsnet.LSNet.maxpool |
| lsnet.LSNet.num_blocks |