<jupyter_start><jupyter_text>Experiment 2This notebook is indented to present the second experiment. The adaptable Model is trained on the GMC and NIH balanced dataset. Load the Dataset<jupyter_code>train_loader_GMC = GMC_DataLoader(stage='train', batch_size = 5, shuffle=True, balanced = True, num_workers=0, pin_memory=True,limit=500)
train_loader_NIH= NIH_DataLoader(stage='train', batch_size = 5, shuffle=True, balanced = True, num_workers=0, pin_memory=True,limit=500)
train_loaders = [train_loader_GMC, train_loader_NIH]

val_loader_GMC = GMC_DataLoader(stage='train', batch_size = 5, shuffle=True, balanced = True, num_workers=0, pin_memory=True,limit=500)
val_loader_NIH= NIH_DataLoader(stage='train', batch_size = 5, shuffle=True, balanced = True, num_workers=0, pin_memory=True,limit=500)
val_loaders = [val_loader_GMC, val_loader_NIH]

test_loader_GMC = GMC_DataLoader(stage='test', batch_size = 5, shuffle=True, balanced = True, num_workers=0, pin_memory=True,limit=465)
test_loader_NIH= NIH_DataLoader(stage='test', batch_size = 5, shuffle=True, balanced = True, num_workers=0, pin_memory=True,limit=465)
test_loaders = [test_loader_GMC, test_loader_NIH]<jupyter_output><empty_output><jupyter_text>Initiate model<jupyter_code>super_model = SuperModel()
optimizer = optim.Adam(super_model.parameters(), lr=0.001)
criterion = torch.nn.BCELoss()<jupyter_output><empty_output><jupyter_text>Training Routine<jupyter_code>n_epochs = 20
irm = 0

train(super_model, train_loaders, val_loaders, optimizer, criterion, irm, vrex, n_epochs, device, exp2 = True)<jupyter_output><empty_output><jupyter_text>Testing Routine<jupyter_code>n_epochs = 20
irm = 0

name_model = f'{super_model.name}_irm_{irm}_ep_{n_epochs}'
test(super_model, test_loader_NIH, name_model, device, exp2 = True)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11411245865490628, 'fraction_numerical': 0.023704520396912898, 'mean_word_length': 10.273291925465838, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '475603', 'license': 'MIT', 'n_tokens_mistral': 706, 'n_tokens_neox': 660, 'n_words': 121, 'path': 'notebooks/experiment2.ipynb', 'repo_name': 'riccardocadei/pneumoniadiagnosis', 'size': '1814'}