Repository: keras-team/autokeras

Issue:
"numpy.linalg.linalg.LinAlgError: N-th leading minor of the array is not positive definite" exception while training ImageClassifier
<!---
**If you are reporting a bug:**
*  Verify that your issue is not being currently addressed by other issues or pull requests.
*  Please note that Auto-Keras is only compatible with **Python 3.6**.
*  Tag the issue with the `bug report` tag.
-->

### Bug Description

When training ImageClassifier on float inputs of shape 80x92x24 on a binary classification task, this exception is thrown when AutoKeras lists all created models until this point and their respected losses and metrics. Here is a more complete log + stack trace:  http://termbin.com/gb3n

### Reproducing Steps

* Create a dataset of noise shaped 80x92x24 with ~360 or so samples
*  Respective binary labels.

In my case, some values of the dataset are quite large (they vary between 0 and 1_000_000, but I'm not sure that this is related since AutoKeras performs normalization).

* Have it train on a GTX 1070Ti or equivalent in terms of vram for about an hour (can't confirm that it's GPU-related either).
* Wait for the exception


### Expected Behavior

It should work.

### Setup Details
 - OS type and version: Ubuntu 18.04
 - Python: 3.6
 - autokeras: 0.2.14 (installed manually from git)
- all dependencies are installed as stated in requirements.txt for this release, unless for:
- tensorflow 1.10, compiled locally. 



Discussion:
@Zvezdin Thank you for the report.
I think this has been fixed in the develop branch.
Will be released soon.

Resolving patch:
diff --git a/autokeras/bayesian.py b/autokeras/bayesian.py
--- a/autokeras/bayesian.py
+++ b/autokeras/bayesian.py
@@ -92,7 +92,7 @@ def incremental_fit(self, train_x, train_y):
         down_k = np.concatenate((down_left_k, down_right_k), axis=1)
         self._distance_matrix = np.concatenate((up_k, down_k), axis=0)
         distort_matrix = bourgain_embedding_matrix(self._distance_matrix)
-        k_matrix = 1.0 / np.exp(distort_matrix)
+        k_matrix = 1.0 / np.exp(np.power(distort_matrix, 2))
         diagonal = np.diag_indices_from(k_matrix)
         diagonal = (diagonal[0][-len(train_x):], diagonal[1][-len(train_x):])
         k_matrix[diagonal] += self.alpha
@@ -118,7 +118,7 @@ def first_fit(self, train_x, train_y):
 
         self._distance_matrix = self.edit_distance_matrix(self.kernel_lambda, self._x)
         distort_matrix = bourgain_embedding_matrix(self._distance_matrix)
-        k_matrix = 1.0 / np.exp(distort_matrix)
+        k_matrix = 1.0 / np.exp(np.power(distort_matrix, 2))
         k_matrix[np.diag_indices_from(k_matrix)] += self.alpha
 
         self._l_matrix = cholesky(k_matrix, lower=True)  # Line 2
@@ -129,7 +129,7 @@ def first_fit(self, train_x, train_y):
         return self
 
     def predict(self, train_x):
-        k_trans = 1.0 / np.exp(self.edit_distance_matrix(self.kernel_lambda, train_x, self._x))
+        k_trans = 1.0 / np.exp(np.power(self.edit_distance_matrix(self.kernel_lambda, train_x, self._x), 2))
         y_mean = k_trans.dot(self._alpha_vector)  # Line 4 (y_mean = f_star)
 
         # compute inverse K_inv of K based on its Cholesky


Test patch: