<jupyter_start><jupyter_text>Calling the class for the varying hyperparamters<jupyter_code># HYPERPARAMETERS TO BE TUNED
N_HIDDEN = 128
BATCH_SIZE = 64
LEARNING_RATE = 0.005
DIMINISH_FACTOR = 0.400

# MAIN MODEL
Model = E2E_PextE(embedding_dim, embedding_dim_pos, max_sen_len, max_doc_len, \
keep_prob1, keep_prob2, keep_prob3, N_HIDDEN, n_class)
Model.to(device)
print(Model)
x = torch.rand([BATCH_SIZE, max_doc_len, max_sen_len, embedding_dim]).to(device)
distance = torch.rand([BATCH_SIZE, max_doc_len * max_doc_len, embedding_dim_pos]).to(device)
pred_pos, pred_cause, pred_pair = Model(x, distance)
print("Random i/o shapes x: {}, distance: {}, y_pos: {}, y_cause: {}, y_pair: {}".format(
    x.shape, distance.shape, pred_pos.shape, pred_cause.shape, pred_pair.shape))
pos_cause_criterion = ce_loss_aux(); pair_criterion = ce_loss_pair(DIMINISH_FACTOR)
optimizer = optim.Adam(Model.parameters(), lr=LEARNING_RATE, weight_decay=l2_reg)
train_and_eval(Model, pos_cause_criterion, pair_criterion, optimizer, N_HIDDEN, BATCH_SIZE, LEARNING_RATE, DIMINISH_FACTOR)

# HYPERPARAMETERS TO BE TUNED
N_HIDDEN = 128
BATCH_SIZE = 64
LEARNING_RATE = 0.005
DIMINISH_FACTOR = 0.200

# MAIN MODEL
Model = E2E_PextE(embedding_dim, embedding_dim_pos, max_sen_len, max_doc_len, \
keep_prob1, keep_prob2, keep_prob3, N_HIDDEN, n_class)
Model.to(device)
print(Model)
x = torch.rand([BATCH_SIZE, max_doc_len, max_sen_len, embedding_dim]).to(device)
distance = torch.rand([BATCH_SIZE, max_doc_len * max_doc_len, embedding_dim_pos]).to(device)
pred_pos, pred_cause, pred_pair = Model(x, distance)
print("Random i/o shapes x: {}, distance: {}, y_pos: {}, y_cause: {}, y_pair: {}".format(
    x.shape, distance.shape, pred_pos.shape, pred_cause.shape, pred_pair.shape))
pos_cause_criterion = ce_loss_aux(); pair_criterion = ce_loss_pair(DIMINISH_FACTOR)
optimizer = optim.Adam(Model.parameters(), lr=LEARNING_RATE, weight_decay=l2_reg)
train_and_eval(Model, pos_cause_criterion, pair_criterion, optimizer, N_HIDDEN, BATCH_SIZE, LEARNING_RATE, DIMINISH_FACTOR)

# HYPERPARAMETERS TO BE TUNED
N_HIDDEN = 128
BATCH_SIZE = 64
LEARNING_RATE = 0.001
DIMINISH_FACTOR = 0.400

# MAIN MODEL
Model = E2E_PextE(embedding_dim, embedding_dim_pos, max_sen_len, max_doc_len, \
keep_prob1, keep_prob2, keep_prob3, N_HIDDEN, n_class)
Model.to(device)
print(Model)
x = torch.rand([BATCH_SIZE, max_doc_len, max_sen_len, embedding_dim]).to(device)
distance = torch.rand([BATCH_SIZE, max_doc_len * max_doc_len, embedding_dim_pos]).to(device)
pred_pos, pred_cause, pred_pair = Model(x, distance)
print("Random i/o shapes x: {}, distance: {}, y_pos: {}, y_cause: {}, y_pair: {}".format(
    x.shape, distance.shape, pred_pos.shape, pred_cause.shape, pred_pair.shape))
pos_cause_criterion = ce_loss_aux(); pair_criterion = ce_loss_pair(DIMINISH_FACTOR)
optimizer = optim.Adam(Model.parameters(), lr=LEARNING_RATE, weight_decay=l2_reg)
train_and_eval(Model, pos_cause_criterion, pair_criterion, optimizer, N_HIDDEN, BATCH_SIZE, LEARNING_RATE, DIMINISH_FACTOR)

# HYPERPARAMETERS TO BE TUNED
N_HIDDEN = 128
BATCH_SIZE = 64
LEARNING_RATE = 0.001
DIMINISH_FACTOR = 0.200

# MAIN MODEL
Model = E2E_PextE(embedding_dim, embedding_dim_pos, max_sen_len, max_doc_len, \
keep_prob1, keep_prob2, keep_prob3, N_HIDDEN, n_class)
Model.to(device)
print(Model)
x = torch.rand([BATCH_SIZE, max_doc_len, max_sen_len, embedding_dim]).to(device)
distance = torch.rand([BATCH_SIZE, max_doc_len * max_doc_len, embedding_dim_pos]).to(device)
pred_pos, pred_cause, pred_pair = Model(x, distance)
print("Random i/o shapes x: {}, distance: {}, y_pos: {}, y_cause: {}, y_pair: {}".format(
    x.shape, distance.shape, pred_pos.shape, pred_cause.shape, pred_pair.shape))
pos_cause_criterion = ce_loss_aux(); pair_criterion = ce_loss_pair(DIMINISH_FACTOR)
optimizer = optim.Adam(Model.parameters(), lr=LEARNING_RATE, weight_decay=l2_reg)
train_and_eval(Model, pos_cause_criterion, pair_criterion, optimizer, N_HIDDEN, BATCH_SIZE, LEARNING_RATE, DIMINISH_FACTOR)

# HYPERPARAMETERS TO BE TUNED
N_HIDDEN = 128
BATCH_SIZE = 128
LEARNING_RATE = 0.005
DIMINISH_FACTOR = 0.400

# MAIN MODEL
Model = E2E_PextE(embedding_dim, embedding_dim_pos, max_sen_len, max_doc_len, \
keep_prob1, keep_prob2, keep_prob3, N_HIDDEN, n_class)
Model.to(device)
print(Model)
x = torch.rand([BATCH_SIZE, max_doc_len, max_sen_len, embedding_dim]).to(device)
distance = torch.rand([BATCH_SIZE, max_doc_len * max_doc_len, embedding_dim_pos]).to(device)
pred_pos, pred_cause, pred_pair = Model(x, distance)
print("Random i/o shapes x: {}, distance: {}, y_pos: {}, y_cause: {}, y_pair: {}".format(
    x.shape, distance.shape, pred_pos.shape, pred_cause.shape, pred_pair.shape))
pos_cause_criterion = ce_loss_aux(); pair_criterion = ce_loss_pair(DIMINISH_FACTOR)
optimizer = optim.Adam(Model.parameters(), lr=LEARNING_RATE, weight_decay=l2_reg)
train_and_eval(Model, pos_cause_criterion, pair_criterion, optimizer, N_HIDDEN, BATCH_SIZE, LEARNING_RATE, DIMINISH_FACTOR)

# HYPERPARAMETERS TO BE TUNED
N_HIDDEN = 128
BATCH_SIZE = 128
LEARNING_RATE = 0.005
DIMINISH_FACTOR = 0.200

# MAIN MODEL
Model = E2E_PextE(embedding_dim, embedding_dim_pos, max_sen_len, max_doc_len, \
keep_prob1, keep_prob2, keep_prob3, N_HIDDEN, n_class)
Model.to(device)
print(Model)
x = torch.rand([BATCH_SIZE, max_doc_len, max_sen_len, embedding_dim]).to(device)
distance = torch.rand([BATCH_SIZE, max_doc_len * max_doc_len, embedding_dim_pos]).to(device)
pred_pos, pred_cause, pred_pair = Model(x, distance)
print("Random i/o shapes x: {}, distance: {}, y_pos: {}, y_cause: {}, y_pair: {}".format(
    x.shape, distance.shape, pred_pos.shape, pred_cause.shape, pred_pair.shape))
pos_cause_criterion = ce_loss_aux(); pair_criterion = ce_loss_pair(DIMINISH_FACTOR)
optimizer = optim.Adam(Model.parameters(), lr=LEARNING_RATE, weight_decay=l2_reg)
train_and_eval(Model, pos_cause_criterion, pair_criterion, optimizer, N_HIDDEN, BATCH_SIZE, LEARNING_RATE, DIMINISH_FACTOR)

# HYPERPARAMETERS TO BE TUNED
N_HIDDEN = 128
BATCH_SIZE = 128
LEARNING_RATE = 0.001
DIMINISH_FACTOR = 0.400

# MAIN MODEL
Model = E2E_PextE(embedding_dim, embedding_dim_pos, max_sen_len, max_doc_len, \
keep_prob1, keep_prob2, keep_prob3, N_HIDDEN, n_class)
Model.to(device)
print(Model)
x = torch.rand([BATCH_SIZE, max_doc_len, max_sen_len, embedding_dim]).to(device)
distance = torch.rand([BATCH_SIZE, max_doc_len * max_doc_len, embedding_dim_pos]).to(device)
pred_pos, pred_cause, pred_pair = Model(x, distance)
print("Random i/o shapes x: {}, distance: {}, y_pos: {}, y_cause: {}, y_pair: {}".format(
    x.shape, distance.shape, pred_pos.shape, pred_cause.shape, pred_pair.shape))
pos_cause_criterion = ce_loss_aux(); pair_criterion = ce_loss_pair(DIMINISH_FACTOR)
optimizer = optim.Adam(Model.parameters(), lr=LEARNING_RATE, weight_decay=l2_reg)
train_and_eval(Model, pos_cause_criterion, pair_criterion, optimizer, N_HIDDEN, BATCH_SIZE, LEARNING_RATE, DIMINISH_FACTOR)

# HYPERPARAMETERS TO BE TUNED
N_HIDDEN = 128
BATCH_SIZE = 128
LEARNING_RATE = 0.001
DIMINISH_FACTOR = 0.200

# MAIN MODEL
Model = E2E_PextE(embedding_dim, embedding_dim_pos, max_sen_len, max_doc_len, \
keep_prob1, keep_prob2, keep_prob3, N_HIDDEN, n_class)
Model.to(device)
print(Model)
x = torch.rand([BATCH_SIZE, max_doc_len, max_sen_len, embedding_dim]).to(device)
distance = torch.rand([BATCH_SIZE, max_doc_len * max_doc_len, embedding_dim_pos]).to(device)
pred_pos, pred_cause, pred_pair = Model(x, distance)
print("Random i/o shapes x: {}, distance: {}, y_pos: {}, y_cause: {}, y_pair: {}".format(
    x.shape, distance.shape, pred_pos.shape, pred_cause.shape, pred_pair.shape))
pos_cause_criterion = ce_loss_aux(); pair_criterion = ce_loss_pair(DIMINISH_FACTOR)
optimizer = optim.Adam(Model.parameters(), lr=LEARNING_RATE, weight_decay=l2_reg)
train_and_eval(Model, pos_cause_criterion, pair_criterion, optimizer, N_HIDDEN, BATCH_SIZE, LEARNING_RATE, DIMINISH_FACTOR)

# HYPERPARAMETERS TO BE TUNED
N_HIDDEN = 256
BATCH_SIZE = 64
LEARNING_RATE = 0.005
DIMINISH_FACTOR = 0.400

# MAIN MODEL
Model = E2E_PextE(embedding_dim, embedding_dim_pos, max_sen_len, max_doc_len, \
keep_prob1, keep_prob2, keep_prob3, N_HIDDEN, n_class)
Model.to(device)
print(Model)
x = torch.rand([BATCH_SIZE, max_doc_len, max_sen_len, embedding_dim]).to(device)
distance = torch.rand([BATCH_SIZE, max_doc_len * max_doc_len, embedding_dim_pos]).to(device)
pred_pos, pred_cause, pred_pair = Model(x, distance)
print("Random i/o shapes x: {}, distance: {}, y_pos: {}, y_cause: {}, y_pair: {}".format(
    x.shape, distance.shape, pred_pos.shape, pred_cause.shape, pred_pair.shape))
pos_cause_criterion = ce_loss_aux(); pair_criterion = ce_loss_pair(DIMINISH_FACTOR)
optimizer = optim.Adam(Model.parameters(), lr=LEARNING_RATE, weight_decay=l2_reg)
train_and_eval(Model, pos_cause_criterion, pair_criterion, optimizer, N_HIDDEN, BATCH_SIZE, LEARNING_RATE, DIMINISH_FACTOR)

# HYPERPARAMETERS TO BE TUNED
N_HIDDEN = 256
BATCH_SIZE = 64
LEARNING_RATE = 0.005
DIMINISH_FACTOR = 0.200

# MAIN MODEL
Model = E2E_PextE(embedding_dim, embedding_dim_pos, max_sen_len, max_doc_len, \
keep_prob1, keep_prob2, keep_prob3, N_HIDDEN, n_class)
Model.to(device)
print(Model)
x = torch.rand([BATCH_SIZE, max_doc_len, max_sen_len, embedding_dim]).to(device)
distance = torch.rand([BATCH_SIZE, max_doc_len * max_doc_len, embedding_dim_pos]).to(device)
pred_pos, pred_cause, pred_pair = Model(x, distance)
print("Random i/o shapes x: {}, distance: {}, y_pos: {}, y_cause: {}, y_pair: {}".format(
    x.shape, distance.shape, pred_pos.shape, pred_cause.shape, pred_pair.shape))
pos_cause_criterion = ce_loss_aux(); pair_criterion = ce_loss_pair(DIMINISH_FACTOR)
optimizer = optim.Adam(Model.parameters(), lr=LEARNING_RATE, weight_decay=l2_reg)
train_and_eval(Model, pos_cause_criterion, pair_criterion, optimizer, N_HIDDEN, BATCH_SIZE, LEARNING_RATE, DIMINISH_FACTOR)

# HYPERPARAMETERS TO BE TUNED
N_HIDDEN = 256
BATCH_SIZE = 64
LEARNING_RATE = 0.001
DIMINISH_FACTOR = 0.400

# MAIN MODEL
Model = E2E_PextE(embedding_dim, embedding_dim_pos, max_sen_len, max_doc_len, \
keep_prob1, keep_prob2, keep_prob3, N_HIDDEN, n_class)
Model.to(device)
print(Model)
x = torch.rand([BATCH_SIZE, max_doc_len, max_sen_len, embedding_dim]).to(device)
distance = torch.rand([BATCH_SIZE, max_doc_len * max_doc_len, embedding_dim_pos]).to(device)
pred_pos, pred_cause, pred_pair = Model(x, distance)
print("Random i/o shapes x: {}, distance: {}, y_pos: {}, y_cause: {}, y_pair: {}".format(
    x.shape, distance.shape, pred_pos.shape, pred_cause.shape, pred_pair.shape))
pos_cause_criterion = ce_loss_aux(); pair_criterion = ce_loss_pair(DIMINISH_FACTOR)
optimizer = optim.Adam(Model.parameters(), lr=LEARNING_RATE, weight_decay=l2_reg)
train_and_eval(Model, pos_cause_criterion, pair_criterion, optimizer, N_HIDDEN, BATCH_SIZE, LEARNING_RATE, DIMINISH_FACTOR)

# HYPERPARAMETERS TO BE TUNED
N_HIDDEN = 256
BATCH_SIZE = 64
LEARNING_RATE = 0.001
DIMINISH_FACTOR = 0.200

# MAIN MODEL
Model = E2E_PextE(embedding_dim, embedding_dim_pos, max_sen_len, max_doc_len, \
keep_prob1, keep_prob2, keep_prob3, N_HIDDEN, n_class)
Model.to(device)
print(Model)
x = torch.rand([BATCH_SIZE, max_doc_len, max_sen_len, embedding_dim]).to(device)
distance = torch.rand([BATCH_SIZE, max_doc_len * max_doc_len, embedding_dim_pos]).to(device)
pred_pos, pred_cause, pred_pair = Model(x, distance)
print("Random i/o shapes x: {}, distance: {}, y_pos: {}, y_cause: {}, y_pair: {}".format(
    x.shape, distance.shape, pred_pos.shape, pred_cause.shape, pred_pair.shape))
pos_cause_criterion = ce_loss_aux(); pair_criterion = ce_loss_pair(DIMINISH_FACTOR)
optimizer = optim.Adam(Model.parameters(), lr=LEARNING_RATE, weight_decay=l2_reg)
train_and_eval(Model, pos_cause_criterion, pair_criterion, optimizer, N_HIDDEN, BATCH_SIZE, LEARNING_RATE, DIMINISH_FACTOR)

# HYPERPARAMETERS TO BE TUNED
N_HIDDEN = 256
BATCH_SIZE = 128
LEARNING_RATE = 0.005
DIMINISH_FACTOR = 0.400

# MAIN MODEL
Model = E2E_PextE(embedding_dim, embedding_dim_pos, max_sen_len, max_doc_len, \
keep_prob1, keep_prob2, keep_prob3, N_HIDDEN, n_class)
Model.to(device)
print(Model)
x = torch.rand([BATCH_SIZE, max_doc_len, max_sen_len, embedding_dim]).to(device)
distance = torch.rand([BATCH_SIZE, max_doc_len * max_doc_len, embedding_dim_pos]).to(device)
pred_pos, pred_cause, pred_pair = Model(x, distance)
print("Random i/o shapes x: {}, distance: {}, y_pos: {}, y_cause: {}, y_pair: {}".format(
    x.shape, distance.shape, pred_pos.shape, pred_cause.shape, pred_pair.shape))
pos_cause_criterion = ce_loss_aux(); pair_criterion = ce_loss_pair(DIMINISH_FACTOR)
optimizer = optim.Adam(Model.parameters(), lr=LEARNING_RATE, weight_decay=l2_reg)
train_and_eval(Model, pos_cause_criterion, pair_criterion, optimizer, N_HIDDEN, BATCH_SIZE, LEARNING_RATE, DIMINISH_FACTOR)

# HYPERPARAMETERS TO BE TUNED
N_HIDDEN = 256
BATCH_SIZE = 128
LEARNING_RATE = 0.005
DIMINISH_FACTOR = 0.200

# MAIN MODEL
Model = E2E_PextE(embedding_dim, embedding_dim_pos, max_sen_len, max_doc_len, \
keep_prob1, keep_prob2, keep_prob3, N_HIDDEN, n_class)
Model.to(device)
print(Model)
x = torch.rand([BATCH_SIZE, max_doc_len, max_sen_len, embedding_dim]).to(device)
distance = torch.rand([BATCH_SIZE, max_doc_len * max_doc_len, embedding_dim_pos]).to(device)
pred_pos, pred_cause, pred_pair = Model(x, distance)
print("Random i/o shapes x: {}, distance: {}, y_pos: {}, y_cause: {}, y_pair: {}".format(
    x.shape, distance.shape, pred_pos.shape, pred_cause.shape, pred_pair.shape))
pos_cause_criterion = ce_loss_aux(); pair_criterion = ce_loss_pair(DIMINISH_FACTOR)
optimizer = optim.Adam(Model.parameters(), lr=LEARNING_RATE, weight_decay=l2_reg)
train_and_eval(Model, pos_cause_criterion, pair_criterion, optimizer, N_HIDDEN, BATCH_SIZE, LEARNING_RATE, DIMINISH_FACTOR)

# HYPERPARAMETERS TO BE TUNED
N_HIDDEN = 256
BATCH_SIZE = 128
LEARNING_RATE = 0.001
DIMINISH_FACTOR = 0.400

# MAIN MODEL
Model = E2E_PextE(embedding_dim, embedding_dim_pos, max_sen_len, max_doc_len, \
keep_prob1, keep_prob2, keep_prob3, N_HIDDEN, n_class)
Model.to(device)
print(Model)
x = torch.rand([BATCH_SIZE, max_doc_len, max_sen_len, embedding_dim]).to(device)
distance = torch.rand([BATCH_SIZE, max_doc_len * max_doc_len, embedding_dim_pos]).to(device)
pred_pos, pred_cause, pred_pair = Model(x, distance)
print("Random i/o shapes x: {}, distance: {}, y_pos: {}, y_cause: {}, y_pair: {}".format(
    x.shape, distance.shape, pred_pos.shape, pred_cause.shape, pred_pair.shape))
pos_cause_criterion = ce_loss_aux(); pair_criterion = ce_loss_pair(DIMINISH_FACTOR)
optimizer = optim.Adam(Model.parameters(), lr=LEARNING_RATE, weight_decay=l2_reg)
train_and_eval(Model, pos_cause_criterion, pair_criterion, optimizer, N_HIDDEN, BATCH_SIZE, LEARNING_RATE, DIMINISH_FACTOR)

# HYPERPARAMETERS TO BE TUNED
N_HIDDEN = 256
BATCH_SIZE = 128
LEARNING_RATE = 0.001
DIMINISH_FACTOR = 0.200

# MAIN MODEL
Model = E2E_PextE(embedding_dim, embedding_dim_pos, max_sen_len, max_doc_len, \
keep_prob1, keep_prob2, keep_prob3, N_HIDDEN, n_class)
Model.to(device)
print(Model)
x = torch.rand([BATCH_SIZE, max_doc_len, max_sen_len, embedding_dim]).to(device)
distance = torch.rand([BATCH_SIZE, max_doc_len * max_doc_len, embedding_dim_pos]).to(device)
pred_pos, pred_cause, pred_pair = Model(x, distance)
print("Random i/o shapes x: {}, distance: {}, y_pos: {}, y_cause: {}, y_pair: {}".format(
    x.shape, distance.shape, pred_pos.shape, pred_cause.shape, pred_pair.shape))
pos_cause_criterion = ce_loss_aux(); pair_criterion = ce_loss_pair(DIMINISH_FACTOR)
optimizer = optim.Adam(Model.parameters(), lr=LEARNING_RATE, weight_decay=l2_reg)
train_and_eval(Model, pos_cause_criterion, pair_criterion, optimizer, N_HIDDEN, BATCH_SIZE, LEARNING_RATE, DIMINISH_FACTOR)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12068417371399504, 'fraction_numerical': 0.018821135626629362, 'mean_word_length': 7.675124103695532, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '43621', 'license': 'MIT', 'n_tokens_mistral': 6564, 'n_tokens_neox': 6250, 'n_words': 1143, 'path': 'Task_4_Emotion_Cause_Pair_Extraction/[20210927] ecpe-long-data-summarized-PextE.ipynb', 'repo_name': 'nicholasneo78/fyp-ai-for-healthcare', 'size': '15727'}