Skip to content

Commit

Permalink
Merge pull request #47 from ziatdinovmax/master
Browse files Browse the repository at this point in the history
Update examples
  • Loading branch information
ziatdinovmax authored Jun 18, 2021
2 parents d2f7cf3 + dcfd171 commit 379f746
Show file tree
Hide file tree
Showing 2 changed files with 158 additions and 179 deletions.
8 changes: 6 additions & 2 deletions atomai/models/dklgp/dklgpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Created by Maxim Ziatdinov (email: maxim.ziatdinov@ai4microscopy.com)
"""

import warnings
from typing import Tuple, Type, Union

import gpytorch
Expand Down Expand Up @@ -74,8 +75,11 @@ def _compute_posterior(self, X: torch.Tensor) -> gpytorch.distributions.Multivar
"""
self.gp_model.eval()
self.likelihood.eval()
with torch.no_grad(), gpytorch.settings.use_toeplitz(False), gpytorch.settings.fast_pred_var():
posterior = self.gp_model(X.to(self.device))
wrn = gpytorch.models.exact_gp.GPInputWarning
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=wrn)
with torch.no_grad(), gpytorch.settings.use_toeplitz(False), gpytorch.settings.fast_pred_var():
posterior = self.gp_model(X.to(self.device))
return posterior

def sample_from_posterior(self, X, num_samples: int = 1000) -> np.ndarray:
Expand Down
329 changes: 152 additions & 177 deletions examples/notebooks/atomai_dkl_ferroic.ipynb

Large diffs are not rendered by default.

0 comments on commit 379f746

Please sign in to comment.