Skip to content

Commit

Permalink
python2 port
Browse files Browse the repository at this point in the history
  • Loading branch information
rajpurkar committed Jan 18, 2017
1 parent 2124359 commit 3416508
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 5 deletions.
13 changes: 11 additions & 2 deletions ecg/analyze-keras.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division
from __future__ import absolute_import
from builtins import zip
from builtins import open
from builtins import str
from future import standard_library
standard_library.install_aliases()
import argparse
import csv
import json
import os
from tabulate import tabulate
from io import StringIO
from io import BytesIO


def get_params_table(path, max_models=5):
Expand All @@ -13,7 +22,7 @@ def process_params(parameters):
del parameters["FOLDER_TO_SAVE"]
return parameters

output = StringIO()
output = BytesIO()
first = True
visited_dirs = {}
for loss, _, dirpath in get_best_models(path):
Expand Down
9 changes: 8 additions & 1 deletion ecg/data/irhythm/extract_data.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
from __future__ import print_function
from __future__ import division

from __future__ import unicode_literals
from __future__ import absolute_import

from builtins import zip
from builtins import int
from builtins import range
from future import standard_library
standard_library.install_aliases()
import collections
import json
import numpy as np
Expand Down
9 changes: 9 additions & 0 deletions ecg/eval-keras.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division
from __future__ import absolute_import
from builtins import range
from builtins import open
from builtins import str
from future import standard_library
standard_library.install_aliases()
import argparse
import numpy as np
from sklearn.metrics import classification_report, confusion_matrix
Expand Down
9 changes: 9 additions & 0 deletions ecg/loader.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import absolute_import
from builtins import dict
from builtins import zip
from builtins import range
from future import standard_library
standard_library.install_aliases()
import argparse
import collections
import numpy as np
Expand Down
8 changes: 8 additions & 0 deletions ecg/predict-keras.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division
from __future__ import absolute_import
from builtins import open
from builtins import str
from future import standard_library
standard_library.install_aliases()
import argparse
import numpy as np
from keras.models import load_model
Expand Down
12 changes: 11 additions & 1 deletion ecg/train-keras.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division
from __future__ import absolute_import
from builtins import open
from builtins import int
from builtins import str
from future import standard_library
standard_library.install_aliases()

import argparse
import numpy as np
import json
Expand Down Expand Up @@ -36,7 +46,7 @@ def plot_model(model, start_time, net_type):
def save_params(params, start_time, net_type):
saving_filename = get_folder_name(start_time, net_type) + "/params.json"
with open(saving_filename, 'w') as outfile:
json.dump(params, outfile)
outfile.write(unicode(json.dumps(params, ensure_ascii=False)))


if __name__ == '__main__':
Expand Down
6 changes: 5 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
cycler==0.10.0
docopt==0.6.2
funcsigs==1.0.2
future==0.16.0
h5py==2.6.0
joblib==0.10.3
Keras==1.2.0
mock==2.0.0
numpy==1.11.3
pandas==0.19.2
pbr==1.10.0
pprint==0.1
protobuf==3.1.0.post1
pydot-ng==1.0.0
Expand All @@ -17,6 +21,6 @@ scipy==0.18.1
six==1.10.0
sklearn==0.0
tabulate==0.7.7
tensorflow==0.12.1
tensorflow-gpu==0.12.1
Theano==0.8.2
tqdm==4.11.0

0 comments on commit 3416508

Please sign in to comment.