<jupyter_start><jupyter_text>Config<jupyter_code>config = read_config("Fork")
config.debug = True
config.gpu = [1]
config.train_folds = [0]
config = update_config(config)
train, test = dataset.read_data(config)
display(train.shape, test.shape)
display(train.head())
display(test.head())<jupyter_output><empty_output><jupyter_text>adding features<jupyter_code>train = FE.add_features_choice(train, config)
test = FE.add_features_choice(test, config)
feature_cols = [col for col in train.columns if col not in ["id", "breath_id", "fold", "pressure"]]
print(feature_cols)
display(train.head()), display(test.head())
model = models.get_model(len(feature_cols),config)
for n,p in model.named_parameters():
    print(n)<jupyter_output>lstms.0.weight_ih_l0
lstms.0.weight_hh_l0
lstms.0.bias_ih_l0
lstms.0.bias_hh_l0
lstms.0.weight_ih_l0_reverse
lstms.0.weight_hh_l0_reverse
lstms.0.bias_ih_l0_reverse
lstms.0.bias_hh_l0_reverse
lstms.1.weight_ih_l0
lstms.1.weight_hh_l0
lstms.1.bias_ih_l0
lstms.1.bias_hh_l0
lstms.1.weight_ih_l0_reverse
lstms.1.weight_hh_l0_reverse
lstms.1.bias_ih_l0_reverse
lstms.1.bias_hh_l0_reverse
lstms.2.weight_ih_l0
lstms.2.weight_hh_l0
lstms.2.bias_ih_l0
lstms.2.bias_hh_l0
lstms.2.weight_ih_l0_reverse
lstms.2.weight_hh_l0_reverse
lstms.2.bias_ih_l0_reverse
lstms.2.bias_hh_l0_reverse
lstms.3.weight_ih_l0
lstms.3.weight_hh_l0
lstms.3.bias_ih_l0
lstms.3.bias_hh_l0
lstms.3.weight_ih_l0_reverse
lstms.3.weight_hh_l0_reverse
lstms.3.bias_ih_l0_reverse
lstms.3.bias_hh_l0_reverse
fc1.weight
fc1.bias
fc2.weight
fc2.bias<jupyter_text>Learning Rate Finder<jupyter_code>if config.use_lr_finder:
    # data
    rs = RobustScaler(quantile_range=(config.low_q, config.high_q), unit_variance=config.unit_var)
    X_train = rs.fit_transform(train[feature_cols])
    X_train = X_train.reshape(-1, 80, len(feature_cols))
    y_train = train['pressure'].values.reshape(-1, 80)
    w_train = (1 - train['u_out']).values.reshape(-1, 80)
    train_dt = dataset.LR_VPP(X_train, y_train, w_train)
    train_loader = DataLoader(train_dt,
                              batch_size=config.batch_size,
                              shuffle=True,
                              num_workers=config.num_workers, pin_memory=True, drop_last=False)
if config.use_lr_finder:
    # model
    model = models.Model(len(feature_cols),config)
    model.to(config.device)
    if len(config.gpu) > 1:
        model = DataParallel(model)
    optimizer = AdamW(model.parameters(), lr=1e-6, eps=1e-08, weight_decay=config.weight_decay, amsgrad=False)
    criterion = loss.cal_mae_loss
if config.use_lr_finder:
    lr_finder = lrfinder.LRFinder(model, optimizer, criterion, config.device)
    lrs, losses = lr_finder.range_test(train_loader, end_lr=10, num_iter=100, smooth_f=0.05, diverge_th=5)    
    lrfinder.plot_lr_finder(lrs, losses)
if config.use_lr_finder:
    del model, optimizer, criterion, train_dt, train_loader, lr_finder
    gc.collect()
    torch.cuda.empty_cache()<jupyter_output><empty_output><jupyter_text>Training<jupyter_code>train_helper.training_loop(train.copy(), config)
gc.collect()
torch.cuda.empty_cache()<jupyter_output><empty_output><jupyter_text>Inference<jupyter_code>test_avg = infer_helper.get_test_avg(train.query("fold==0").copy(), config)
test_avg
train.query("fold==0")['pressure']
test_avg["pressure"].hist(bins=100)
plt.show()
train["pressure"].hist(bins=100)
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12317144528964306, 'fraction_numerical': 0.03013458162668227, 'mean_word_length': 5.600386100386101, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 21, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '428999', 'license': 'Apache-2.0', 'n_tokens_mistral': 1413, 'n_tokens_neox': 1378, 'n_words': 171, 'path': 'notebook/Model.ipynb', 'repo_name': 'VincentWang25/GBVPP', 'size': '3418'}