analysiscenter / cardio

CardIO is a library for data science research of heart signals
https://analysiscenter.github.io/cardio/
Apache License 2.0
248 stars 78 forks source link

HMM Jupyter notebook gives batchflow import errors #40

Closed sitadrost closed 1 year ago

sitadrost commented 4 years ago

Dear developers,

Thanks a lot for sharing your code on GitHub! I installed CardIO as a Git project repository (following your instructions, so including --recursive), on my Ubuntu Linux machine with Python 3.7 and Miniconda.

When trying to work through the HMM Jupyter notebook, I'm getting a lot of errors following the cardio import commands. The first one is AttributeError: module 'cardio.batchflow' has no attribute 'Batch' (not sure whether the others will be resolved once this one is, so I won't list these for now).

Am I doing something wrong? Would it be better to install CardIO through pip3?

Thanks in advance for your help! Best wishes, Sita

EDIT: In the meantime I tried installing through pip3, but that gives a lot of errors. I'm copying the last error below, if you need the other errors as well, please let me know.

ERROR: Command errored out with exit status 1: /home/sita/miniconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-4be4jd4c/scikit-learn/setup.py'"'"'; __file__='"'"'/tmp/pip-install-4be4jd4c/scikit-learn/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-47pzagft/install-record.txt --single-version-externally-managed --compile --install-headers /home/sita/miniconda3/include/python3.7m/scikit-learn Check the logs for full command output.

sitadrost commented 4 years ago

Great, I think I solved the batchflow errors now! I installed batchflow separately, and now the cardio imports work alright too (using my Git clone). Unfortunately I'm running into another error (after also installing tensorflow): AttributeError: module 'tensorflow' has no attribute 'layers' (due to this import: from cardio.models.hmm import HMModel, prepare_hmm_input). Any ideas?

Many thanks! Sita

EDIT: Ugh... it looks like I should downgrade my tensorflow version to v1 (see this StackOverflow post) I'll let you know whether that works!

EDIT 2: Nope, sorry... The oldest version of tensorflow that I could find so far is 1.14.0, and this gives the same AttributeError

EDIT 3: OK, I give up... I tried some of the fixes suggested on the TensorFlow website: the tf.comp module, and using keras.layers instead of layers, but neither of these worked. I hope you can suggest a fix!

sitadrost commented 4 years ago

Which tensorflow version are you using yourself? And which Python version? Also, are you using Keras as a separate package, or as a part of Tensorflow?

sitadrost commented 4 years ago

Coooool, I think I've got it working now! I installed Tensorflow 1.14.0 and Keras, and the code from the HMM Jupyter notebook is running now. Fingers crossed! Please let me know if there are other packages that I should install to be able to use CardIO.

sitadrost commented 4 years ago

Ah no!! After running for a while, the command ppl_train = (dtst >> ppl_train_template).run() is giving an error:

Traceback (most recent call last):

  File "<ipython-input-16-593748cd05e5>", line 1, in <module>
    ppl_train = (dtst >> ppl_train_template).run()

  File "/home/sita/Documents/Python/cardio/cardio/batchflow/batchflow/pipeline.py", line 1282, in run
    for _ in self.gen_batch(*args, **kwargs):

  File "/home/sita/Documents/Python/cardio/cardio/batchflow/batchflow/pipeline.py", line 1214, in _gen_batch
    batch_res = self.execute_for(batch)

  File "/home/sita/Documents/Python/cardio/cardio/batchflow/batchflow/pipeline.py", line 609, in execute_for
    batch_res = self._exec_all_actions(batch)

  File "/home/sita/Documents/Python/cardio/cardio/batchflow/batchflow/pipeline.py", line 576, in _exec_all_actions
    _action_args = _action['args']

KeyError: 'args'

Does this look familiar to you?