summaryrefslogtreecommitdiff
path: root/ml_exp/qm7db.py
diff options
context:
space:
mode:
authorDavid Luevano Alvarado <55825613+luevano@users.noreply.github.com>2020-03-07 08:47:45 -0700
committerDavid Luevano Alvarado <55825613+luevano@users.noreply.github.com>2020-03-07 08:47:45 -0700
commit00301d1a9a8a7f975b64fe4ef85458f6a40776f7 (patch)
tree1cbe7e0ae1e40f67523d2eee5cd6c1f8c26cae43 /ml_exp/qm7db.py
parent9d33a74915382159ce97e3b4142743a7e3e1c72d (diff)
Use AM again, add tf handler
Diffstat (limited to 'ml_exp/qm7db.py')
-rw-r--r--ml_exp/qm7db.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/ml_exp/qm7db.py b/ml_exp/qm7db.py
index c20df018e..d4734f4ee 100644
--- a/ml_exp/qm7db.py
+++ b/ml_exp/qm7db.py
@@ -22,7 +22,12 @@ SOFTWARE.
"""
from ml_exp.compound import Compound
import numpy as np
-import tensorflow as tf
+try:
+ import tensorflow as tf
+ TF_AV = True
+except ImportError:
+ print('Tensorflow couldn\'t be imported. Maybe it is not installed.')
+ TF_AV = False
import random
@@ -37,6 +42,10 @@ def qm7db(db_path='data',
r_seed: random seed to use for the shuffling.
use_tf: if tensorflow should be used.
"""
+ # If tf is to be used but couldn't be imported, don't try to use it.
+ if use_tf and not TF_AV:
+ use_tf = False
+
fname = f'{db_path}/hof_qm7.txt'
with open(fname, 'r') as f:
lines = f.readlines()