<jupyter_start><jupyter_text>PhysioNet/Computing in Cardiology Challenge 2020 Classification of 12-lead ECGs 3. Train Model  Setup Noteboook<jupyter_code># 3rd party libraries
import os
import sys
import numpy as np
import tensorflow as tf

# Local Libraries
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(os.getcwd()))))))
from kardioml.models.deepecg.utils.devices.device_check import print_device_counts
from kardioml.models.deepecg.train.train import train
from kardioml.models.deepecg.model.model import Model
from kardioml import DATA_PATH, OUTPUT_PATH, LABELS_COUNT, NUM_LEADS

# Configure Notebook
import warnings
warnings.filterwarnings('ignore')
%matplotlib inline
%load_ext autoreload
%autoreload 2<jupyter_output>C:\Users\sebig\Anaconda3\envs\physionet-challenge-2020\lib\site-packages\tensorflow\python\framework\dtypes.py:526: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint8 = np.dtype([("qint8", np.int8, 1)])
C:\Users\sebig\Anaconda3\envs\physionet-challenge-2020\lib\site-packages\tensorflow\python\framework\dtypes.py:527: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint8 = np.dtype([("quint8", np.uint8, 1)])
C:\Users\sebig\Anaconda3\envs\physionet-challenge-2020\lib\site-packages\tensorflow\python\framework\dtypes.py:528: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint16 = np.dtype([("qint16", np.int16, 1)])
C:\Users\sebig\A[...]<jupyter_text>1. Initialize Model<jupyter_code># Print devices
print_device_counts()

# Set save path for graphs, summaries, and checkpoints
os.makedirs(OUTPUT_PATH, exist_ok=True)

# Set sample length (seconds)
duration = 60

# Set model name
model_name = '17'

# Maximum number of checkpoints to keep
max_to_keep = 1

# Set randome states
seed = 0                  

# Set sample frequency
fs = 350

# Set data path
lookup_path = os.path.join(DATA_PATH, 'training', 'deepecg', 'single_split', str(fs))

# Get training dataset dimensions
length, channels = (int(duration * fs), NUM_LEADS+1)          

# Number of classes
classes = LABELS_COUNT

# Choose network
network_name = 'DeepECGV1'

# Set hyper-parameter
hyper_params = {'num_res_layers': 8, 'drop_rate': 0.3, 'kernel_size': 3, 
                'conv_filts': 64, 'res_filts': 64, 'skip_filts': 64, 
                'dilation': True, 'fs': fs}

# Set network inputs
network_parameters = {'length': length, 'channels': channels, 'classes': classes, 'seed': seed,
                      'hyper_params': hyper_params}

# Create model
model = Model(model_name=model_name, 
              network_name=network_name, 
              network_parameters=network_parameters, 
              save_path=OUTPUT_PATH,
              lookup_path=lookup_path,
              max_to_keep=max_to_keep)<jupyter_output>Workstation has 1 CPUs.
Workstation has 2 GPUs.
input | shape = (?, 21000, 13)
stem_layer_1 | shape = (?, 10500, 32)
stem_layer_2 | shape = (?, 5250, 64)
res_layer_1_skip | shape = (?, 5250, 64)
res_layer_2_skip | shape = (?, 5250, 64)
res_layer_3_skip | shape = (?, 5250, 64)
res_layer_4_skip | shape = (?, 5250, 64)
res_layer_5_skip | shape = (?, 5250, 64)
res_layer_6_skip | shape = (?, 5250, 64)
res_layer_7_skip | shape = (?, 5250, 64)
res_layer_8_skip | shape = (?, 5250, 64)
output_skip_addition | shape = (?, 5250, 64)
output_conv1 | shape = (?, 5250, 128)
output_conv2 | shape = (?, 5250, 256)
gap | shape = (?, 256)
logits | shape = (?, 27)
input | shape = (?, 21000, 13)
stem_layer_1 | shape = (?, 10500, 32)
stem_layer_2 | shape = (?, 5250, 64)
res_layer_1_skip | shape = (?, 5250, 64)
res_layer_2_skip | shape = (?, 5250, 64)
res_layer_3_skip | shape = (?, 5250, 64)
res_layer_4_skip | shape = (?, 5250, 64)
res_layer_5_skip | shape = (?, 5250, 64)
res_layer_6_skip | shape = (?, 5250, 6[...]<jupyter_text>4. Train Model<jupyter_code># Set hyper-parameters
epochs = 100
batch_size = 16
learning_rate_start = 0.001            

# Train model
train(model=model, epochs=epochs, batch_size=batch_size)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13122999542752628, 'fraction_numerical': 0.060128029263831734, 'mean_word_length': 4.441542288557214, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '61482', 'license': 'BSD-2-Clause', 'n_tokens_mistral': 1792, 'n_tokens_neox': 1563, 'n_words': 392, 'path': 'kardioml/models/deepecg/notebooks/3_train_model_test.ipynb', 'repo_name': 'Seb-Good/physionet-challenge-2020', 'size': '4374'}