summaryrefslogtreecommitdiff
path: root/ml_exp/kernels.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/kernels.py
parent9d33a74915382159ce97e3b4142743a7e3e1c72d (diff)
Use AM again, add tf handler
Diffstat (limited to 'ml_exp/kernels.py')
-rw-r--r--ml_exp/kernels.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/ml_exp/kernels.py b/ml_exp/kernels.py
index c203af30e..abc71f7af 100644
--- a/ml_exp/kernels.py
+++ b/ml_exp/kernels.py
@@ -22,7 +22,12 @@ SOFTWARE.
"""
# import math
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
def gaussian_kernel(X1,
@@ -36,6 +41,10 @@ def gaussian_kernel(X1,
sigma: kernel width.
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
+
X1_size = X1.shape[0]
X2_size = X2.shape[0]
i_sigma = -0.5 / (sigma*sigma)