Created
October 23, 2020 15:38
-
-
Save codeKgu/8e5f6ac317b4b455fc11590fd6e271e2 to your computer and use it in GitHub Desktop.
Tutorial for multimodal_transformers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from multimodal_transformers.model import AutoModelWithTabular, TabularConfig | |
from transformers import AutoConfig | |
num_labels = len(np.unique(torch_dataset, labels)) | |
config = AutoConfig.from_pretrained('bert-base-uncased') | |
tabular_config = TabularConfig( | |
num_labels=num_labels, | |
cat_feat_dim=torch_dataset.cat_feats.shape[1], | |
numerical_feat_dim=torch_dataset.numerical_feats.shape[1], | |
combine_feat_method='weighted_feature_sum_on_transformer_cat_and_numerical_feats', | |
) | |
config.tabular_config = tabular_config | |
model = AutoModelWithTabular.from_pretrained('bert-base-uncased', config=config) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment