Hybrid model combining ResNet for image processing and EAML for text processing. More...


Public Member Functions | |
| __init__ (self, int num_classes, int vocab_size, int embedding_dim=100, int word_hidden_dim=50, int sent_hidden_dim=50, str trained_model_name="resnet50", bool pretrained=True, float dropout=0.5) | |
| Constructor for ResNetHybridModel. | |
| forward (self, images, docs) | |
| Forward pass through the hybrid model. | |
Protected Member Functions | |
| _create_resnet_model (self, trained_model_name, pretrained) | |
| Create and configure the ResNet model. | |
Hybrid model combining ResNet for image processing and EAML for text processing.
This class implements a hybrid architecture that combines the strengths of ResNet for image understanding and EAML for OCR text processing. It uses ResNet as the image encoder and EAML's text processing branch.
Hybrid model that combines ResNet for image processing and EAML for text processing. This model leverages the strengths of both architectures to create a powerful document classifier that uses both image and OCR text modalities.
| hybrid.ResNetHybridModel.__init__ | ( | self, | |
| int | num_classes, | ||
| int | vocab_size, | ||
| int | embedding_dim = 100, |
||
| int | word_hidden_dim = 50, |
||
| int | sent_hidden_dim = 50, |
||
| str | trained_model_name = "resnet50", |
||
| bool | pretrained = True, |
||
| float | dropout = 0.5 |
||
| ) |
Constructor for ResNetHybridModel.
| num_classes | Number of document classes |
| vocab_size | Size of the vocabulary for text embedding |
| embedding_dim | Dimension of the word embeddings |
| word_hidden_dim | Dimension of the word-level GRU hidden state |
| sent_hidden_dim | Dimension of the sentence-level GRU hidden state |
| trained_model_name | Name of the ResNet model to use (e.g., "resnet18", "resnet50") |
| pretrained | Whether to use pre-trained weights |
| dropout | Dropout rate for regularization |
|
protected |
Create and configure the ResNet model.
| trained_model_name | Name of the ResNet model to use |
| pretrained | Whether to use pre-trained weights |
Create and configure the ResNet model.
Args:
trained_model_name: Name of the ResNet model to use
pretrained: Whether to use pre-trained weights
Returns:
Configured ResNet model
| hybrid.ResNetHybridModel.forward | ( | self, | |
| images, | |||
| docs | |||
| ) |
Forward pass through the hybrid model.
| images | Input images tensor of shape (batch_size, channels, height, width) |
| docs | Input text tensor of shape (batch_size, num_sentences, max_sent_length) |
| hybrid.ResNetHybridModel.classifier |
| hybrid.ResNetHybridModel.embedding |
| hybrid.ResNetHybridModel.embedding_dropout |
| hybrid.ResNetHybridModel.fusion_layer |
| hybrid.ResNetHybridModel.image_feature_dim |
| hybrid.ResNetHybridModel.num_classes |
| hybrid.ResNetHybridModel.resnet |
| hybrid.ResNetHybridModel.sent_attention |
| hybrid.ResNetHybridModel.sent_gru |
| hybrid.ResNetHybridModel.sent_gru_dropout |
| hybrid.ResNetHybridModel.text_feature_dim |
| hybrid.ResNetHybridModel.word_attention |
| hybrid.ResNetHybridModel.word_gru |
| hybrid.ResNetHybridModel.word_gru_dropout |