Enhanced Multi-Level Attention Network for document classification. More...


Public Member Functions | |
| __init__ (self, vocab_size, embedding_dim, word_hidden_dim, sent_hidden_dim, image_channels, image_feature_dim, num_classes, dropout=0.5, use_ocr_text=False) | |
| Constructor for EAML class. | |
| forward (self, docs, images) | |
| Forward pass through the EAML network. | |
Public Attributes | |
| embedding_dim | |
| word_hidden_dim | |
| sent_hidden_dim | |
| image_feature_dim | |
| use_ocr_text | |
| embedding | |
| word_gru | |
| word_attention | |
| sent_gru | |
| sent_attention | |
| image_encoder | |
| fc | |
| dropout | |
Enhanced Multi-Level Attention Network for document classification.
This class implements a multimodal document classifier that combines text and image features using attention mechanisms at multiple levels.
Enhanced Multi-Level Attention Network (EAML) for Document Classification with Text and Image modalities. Assumes text input is preprocessed into sentences and words, and embedded. Assumes image input is preprocessed to a fixed size.
| eaml.EAML.__init__ | ( | self, | |
| vocab_size, | |||
| embedding_dim, | |||
| word_hidden_dim, | |||
| sent_hidden_dim, | |||
| image_channels, | |||
| image_feature_dim, | |||
| num_classes, | |||
dropout = 0.5, |
|||
use_ocr_text = False |
|||
| ) |
Constructor for EAML class.
| 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 |
| image_channels | Number of input image channels |
| image_feature_dim | Dimension of the image feature vector |
| num_classes | Number of document classes |
| dropout | Dropout rate for regularization |
| use_ocr_text | Whether to use OCR text from the dataset |
| eaml.EAML.forward | ( | self, | |
| docs, | |||
| images | |||
| ) |
Forward pass through the EAML network.
| docs | Input tensor of shape (batch_size, num_sentences, max_sent_length) |
| images | Input tensor of shape (batch_size, channels, height, width) |
| eaml.EAML.dropout |
| eaml.EAML.embedding |
| eaml.EAML.embedding_dim |
| eaml.EAML.fc |
| eaml.EAML.image_encoder |
| eaml.EAML.image_feature_dim |
| eaml.EAML.sent_attention |
| eaml.EAML.sent_gru |
| eaml.EAML.sent_hidden_dim |
| eaml.EAML.use_ocr_text |
| eaml.EAML.word_attention |
| eaml.EAML.word_gru |
| eaml.EAML.word_hidden_dim |