<jupyter_start><jupyter_text>Train TextCNNStefan/<NAME>Since Wed. Mar. 16th. 2022 Setup Ipython<jupyter_code>%load_ext autoreload
%autoreload 2<jupyter_output><empty_output><jupyter_text>Colab<jupyter_code>import os
import sys


is_on_colab = 'google.colab' in sys.modules

if is_on_colab:
    from google.colab import drive
    drive.mount('/content/drive')

    ! pip3 install sty icecream
    ! pip3 install wfdb
    ! pip3 install pytorch-lightning transformers datasets
    ! pip3 install vit-pytorch

    path = os.path.join('drive', 'My Drive', 'Research', 'ECG Classification', 'ECG-Representation-Learning')
    sys.path.append(path)
    ! ls "{path}"

    import time, os
    os.environ['TZ'] = 'US/Eastern'
    time.tzset()


import torch
if torch.cuda.is_available():
    ! nvidia-smi


from icecream import ic

from ecg_transformer.util import *
ic(PATH_BASE, DIR_PROJ, PKG_NM)<jupyter_output>ic| PATH_BASE: '/Users/stefanh/Documents/UMich/Research/ECG Classification'
    DIR_PROJ: 'ECG-Representation-Learning'
    PKG_NM: 'ecg_transformer'<jupyter_text>code<jupyter_code>from pytorch_lightning.utilities.seed import seed_everything
from icecream import ic

from ecg_transformer.models.train import get_all_setup

seed_everything(config('random-seed'))<jupyter_output>Global seed set to 77<jupyter_text>Prep<jupyter_code># model_size = 'debug'
model_size = 'base'
# model_size = 'tiny'
t = 'original'

# n_sample = 4
# n_sample = 512
n_sample = None

with_pl = False

train_args = dict(
    num_train_epoch=32,
    train_batch_size=256,
    # train_batch_size=32,
    eval_batch_size=256*2,
    warmup_ratio=0.1,
    n_sample=n_sample,
    augment_timeout=True,
    patience=16,
    precision=16,
    log_per_epoch=True,
    # log_to_console=False
    save_while_training=True,
    save_every_n_epoch=8,
    save_top_k=4,
    tqdm=True
)
model, trainer = get_all_setup(model_size=model_size, train_args=train_args, ptbxl_type=t, with_pl=with_pl)<jupyter_output>[38;2;0;186;142m2022-04-19 02:10:34[38;2;97;175;239m| [39m[49m[22m[23m[24m[25m[27m[28m[29m[38;2;198;120;221m[Get PTB-XL splits][38;2;97;175;239m::[38;2;198;120;221mget_ptbxl_splits[38;2;97;175;239m::[38;2;198;120;221mptb_dataset.py[38;2;97;175;239m:[38;2;198;120;221m107[38;2;97;175;239m, [39m[49m[22m[23m[24m[25m[27m[28m[29mINFO[39m[49m[22m[23m[24m[25m[27m[28m[29m[38;2;97;175;239m - [39m[49m[22m[23m[24m[25m[27m[28m[29mGetting PTB-XL splits with n=[34m21837[39m[49m[0m... [39m[49m[22m[23m[24m[25m[27m[28m[29m
[38;2;0;186;142m2022-04-19 02:10:34[38;2;97;175;239m| [39m[49m[22m[23m[24m[25m[27m[28m[29m[38;2;198;120;221m[Get PTB-XL splits][38;2;97;175;239m::[38;2;198;120;221mget_ptbxl_splits[38;2;97;175;239m::[38;2;198;120;221mptb_dataset.py[38;2;97;175;239m:[38;2;198;120;221m116[38;2;97;175;239m, [39m[49m[22m[23m[24m[25m[27m[28m[29mINFO[39m[49m[22m[23m[24m[25m[27m[28m[29m[38;2;97;175;239m - [39m[...]<jupyter_text>Train<jupyter_code>trainer.train()<jupyter_output><empty_output><jupyter_text>Evaluate<jupyter_code># TODO
os.listdir(trainer.output_dir)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17710309930423782, 'fraction_numerical': 0.15053763440860216, 'mean_word_length': 7.389920424403183, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, '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': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '22508', 'license': 'MIT', 'n_tokens_mistral': 1796, 'n_tokens_neox': 1407, 'n_words': 153, 'path': 'notebook/train/baseline_vit.ipynb', 'repo_name': 'StefanHeng/ECG-Representation-Learning', 'size': '3167'}