|
a |
|
b/tensorflow/README.md |
|
|
1 |
TensorFlow implementation of ecg classification. |
|
|
2 |
|
|
|
3 |
# Prepare data |
|
|
4 |
To prepare the dataset *create_traindataset_mitdb.py* extract the beats from all patients, compute the RR interval information and set their corresponding label from the annotation files. |
|
|
5 |
|
|
|
6 |
# Models |
|
|
7 |
|
|
|
8 |
## DNN classifier |
|
|
9 |
In *dnn_mitdb.py* a DNN default classifier from tensorflow is used |
|
|
10 |
|
|
|
11 |
```python |
|
|
12 |
mitdb_classifier = tf.contrib.learn.DNNClassifier(feature_columns=feature_columns, |
|
|
13 |
hidden_units=[10, 20, 10], |
|
|
14 |
n_classes=5) |
|
|
15 |
``` |
|
|
16 |
|
|
|
17 |
## My own model classifier |
|
|
18 |
Due to the imbalanced data (common in that problem) between N class and anomalies class (SVEB, VEB, F). In *my_dnn_mitdb.py* a classifier that adjust the weight for loss computation during training step is defined. |
|
|
19 |
|
|
|
20 |
```python |
|
|
21 |
def my_model_fn(features, targets, mode, params): |
|
|
22 |
... |
|
|
23 |
loss = tf.losses.softmax_cross_entropy(targets_onehot, output_layer, weights=weights_tf) |
|
|
24 |
... |
|
|
25 |
|
|
|
26 |
my_nn = tf.contrib.learn.Estimator(model_fn=my_model_fn, params=model_params) |
|
|
27 |
``` |
|
|
28 |
|
|
|
29 |
# Requirements |
|
|
30 |
|
|
|
31 |
[Installation guide](installation_guide.md) |
|
|
32 |
|
|
|
33 |
Tensorflow |
|
|
34 |
|
|
|
35 |
python-matplotlib |
|
|
36 |
|
|
|
37 |
pywavelets |