DAPPER (Document Analysis, Processing, and Pattern Extraction Repository)
Statistical Learning Final Project for Document Classification
 
Loading...
Searching...
No Matches
hybrid.ResNetHybridModel Class Reference

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

Inheritance diagram for hybrid.ResNetHybridModel:
Inheritance graph
Collaboration diagram for hybrid.ResNetHybridModel:
Collaboration graph

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.
 

Public Attributes

 num_classes
 
 resnet
 
 image_feature_dim
 
 embedding
 
 embedding_dropout
 
 word_gru
 
 word_gru_dropout
 
 word_attention
 
 sent_gru
 
 sent_gru_dropout
 
 sent_attention
 
 text_feature_dim
 
 fusion_layer
 
 classifier
 

Protected Member Functions

 _create_resnet_model (self, trained_model_name, pretrained)
 Create and configure the ResNet model.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ __init__()

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.

Parameters
num_classesNumber of document classes
vocab_sizeSize of the vocabulary for text embedding
embedding_dimDimension of the word embeddings
word_hidden_dimDimension of the word-level GRU hidden state
sent_hidden_dimDimension of the sentence-level GRU hidden state
trained_model_nameName of the ResNet model to use (e.g., "resnet18", "resnet50")
pretrainedWhether to use pre-trained weights
dropoutDropout rate for regularization

Member Function Documentation

◆ _create_resnet_model()

hybrid.ResNetHybridModel._create_resnet_model (   self,
  trained_model_name,
  pretrained 
)
protected

Create and configure the ResNet model.

Parameters
trained_model_nameName of the ResNet model to use
pretrainedWhether to use pre-trained weights
Returns
Configured ResNet model
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

◆ forward()

hybrid.ResNetHybridModel.forward (   self,
  images,
  docs 
)

Forward pass through the hybrid model.

Parameters
imagesInput images tensor of shape (batch_size, channels, height, width)
docsInput text tensor of shape (batch_size, num_sentences, max_sent_length)
Returns
Output tensor of shape (batch_size, num_classes)

Member Data Documentation

◆ classifier

hybrid.ResNetHybridModel.classifier

◆ embedding

hybrid.ResNetHybridModel.embedding

◆ embedding_dropout

hybrid.ResNetHybridModel.embedding_dropout

◆ fusion_layer

hybrid.ResNetHybridModel.fusion_layer

◆ image_feature_dim

hybrid.ResNetHybridModel.image_feature_dim

◆ num_classes

hybrid.ResNetHybridModel.num_classes

◆ resnet

hybrid.ResNetHybridModel.resnet

◆ sent_attention

hybrid.ResNetHybridModel.sent_attention

◆ sent_gru

hybrid.ResNetHybridModel.sent_gru

◆ sent_gru_dropout

hybrid.ResNetHybridModel.sent_gru_dropout

◆ text_feature_dim

hybrid.ResNetHybridModel.text_feature_dim

◆ word_attention

hybrid.ResNetHybridModel.word_attention

◆ word_gru

hybrid.ResNetHybridModel.word_gru

◆ word_gru_dropout

hybrid.ResNetHybridModel.word_gru_dropout

The documentation for this class was generated from the following file: