<jupyter_start><jupyter_text>DL<jupyter_code>x_train, y_train, x_test, y_test = process_dfs(df_train, df_test)
x_train.shape, x_test.shape
tr_ds, val_ds = to_TDS(x_train, y_train), to_TDS(x_test, y_test)
db = create_databunch(tr_ds, val_ds, 32)<jupyter_output><empty_output><jupyter_text>Testing dims at input/output<jupyter_code>for tx, ty in db.train_dl:
    print(tx.shape, ty.shape)<jupyter_output>torch.Size([30, 1, 570]) torch.Size([30])<jupyter_text>Res2Net<jupyter_code>model = Res2Net(Res2Block, [2, 2, 2, 2], c_in=1, num_classes=num_classes, scale=4).cuda(); model
model = create_inception(1, num_classes).cuda()
model_params(model)
def get_layer_name(layer)->str:
    return str(layer.__class__).split(".")[-1].split("'")[0]

def layers_info(m, **kwargs):
    func = lambda m:list(map(get_layer_name, flatten_model(m)))
    layers_names = func(m)
    layers_sizes, layers_params, layers_trainable = params_size(m, **kwargs)
    layer_info = namedtuple('Layer_Information', ['Layer', 'OutputSize', 'Params', 'Trainable'])
    return list(map(layer_info, layers_names, layers_sizes, layers_params, layers_trainable))

def model_params(model):
    'Get model params'
    info = layers_info(model, size=(1, 100));
    total_params = 0
    total_trainable_params = 0
    for layer, size, params, trainable in info:
        if size is None: continue
        total_params += int(params)
        total_trainable_params += int(params) * trainable
    return total_params, total_trainable_params
model(tx).shape
learn_res = fastai.basic_train.Learner(db, 
                                       model, 
                                       loss_func=CrossEntropyFlat(), 
                                       metrics=[accuracy],
                                       wd=1e-2).mixup()
from utils import model_params
learn_res.lr_find(); learn_res.recorder.plot(suggestion=True)
learn_res.fit_one_cycle(100, 1e-3)
fig = learn_res.recorder.plot_losses(return_fig=True)
learn_res.recorder.plot_metrics()
fig.savefig('Olive.png')
learn_res.fit_one_cycle(100, 1e-3)
fig = learn_res.recorder.plot_losses(return_fig=True)
fig.savefig('Train_Val.png')
p, t = learn_res.get_preds()
accuracy(p,t)
def get_cm(p, t): return confusion_matrix(t, p.softmax(dim=1).argmax(1))<jupyter_output><empty_output><jupyter_text>Confusion Matrix<jupyter_code>sns.heatmap(get_cm(p,t), cmap='inferno')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1312837557125052, 'fraction_numerical': 0.017449106771915246, 'mean_word_length': 4.472727272727273, 'pattern_counts': {'":': 0, '<': 16, '<?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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '650082', 'license': 'Apache-2.0', 'n_tokens_mistral': 914, 'n_tokens_neox': 876, 'n_words': 142, 'path': 'v1/04_res2net.ipynb', 'repo_name': 'williamsdoug/timeseries_fastai', 'size': '2407'}