diff --git a/Makefile b/Makefile index 888932a..0193253 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ build: install: build python -m pip install -e . -build-docs: +docs: rm -rf docs mkdir -p docs custom_css=' + @@ -27,7 +27,7 @@

Module mogptk.data

Expand source code -Browse git +Browse git
import re
 import copy
@@ -1477,7 +1477,7 @@ 

Examples

Expand source code -Browse git +Browse git
def LoadFunction(f, start, end, n, var=0.0, name="", random=False):
     """
@@ -1622,7 +1622,7 @@ 

Examples

Expand source code -Browse git +Browse git
def LoadSplitData(x_train, x_test, y_train, y_test, name=""):
     """
@@ -1713,7 +1713,7 @@ 

Examples

Expand source code -Browse git +Browse git
class Data:
     def __init__(self, X, Y, Y_err=None, name=None, x_labels=None, y_label=None):
@@ -2820,7 +2820,7 @@ 

Examples

Expand source code -Browse git +Browse git
def aggregate(self, duration, f=np.mean, f_err=None):
     """
@@ -2876,7 +2876,7 @@ 

Examples

Expand source code -Browse git +Browse git
def copy(self):
     """
@@ -2913,7 +2913,7 @@ 

Examples

Expand source code -Browse git +Browse git
def filter(self, start, end, dim=None):
     """
@@ -2975,7 +2975,7 @@ 

Examples

Expand source code -Browse git +Browse git
def get_bnse_estimation(self, Q=1, n=1000, iters=200):
     """
@@ -3047,7 +3047,7 @@ 

Examples

Expand source code -Browse git +Browse git
def get_data(self, transformed=False):
     """
@@ -3085,7 +3085,7 @@ 

Examples

Expand source code -Browse git +Browse git
def get_input_dims(self):
     """
@@ -3128,7 +3128,7 @@ 

Examples

Expand source code -Browse git +Browse git
def get_ls_estimation(self, Q=1, n=10000):
     """
@@ -3186,7 +3186,7 @@ 

Examples

Expand source code -Browse git +Browse git
def get_name(self):
     """
@@ -3218,7 +3218,7 @@ 

Examples

Expand source code -Browse git +Browse git
def get_nyquist_estimation(self):
     """
@@ -3259,7 +3259,7 @@ 

Examples

Expand source code -Browse git +Browse git
def get_prediction_data(self):
     """
@@ -3309,7 +3309,7 @@ 

Examples

Expand source code -Browse git +Browse git
def get_sm_estimation(self, Q=1, method='LS', optimizer='Adam', iters=200, params={}):
     """
@@ -3368,7 +3368,7 @@ 

Examples

Expand source code -Browse git +Browse git
def get_test_data(self, transformed=False):
     """
@@ -3418,7 +3418,7 @@ 

Examples

Expand source code -Browse git +Browse git
def get_train_data(self, transformed=False):
     """
@@ -3454,7 +3454,7 @@ 

Examples

Expand source code -Browse git +Browse git
def has_test_data(self):
     """
@@ -3498,7 +3498,7 @@ 

Examples

Expand source code -Browse git +Browse git
def plot(self, pred=None, title=None, ax=None, legend=True, errorbars=True, transformed=False):
     """
@@ -3629,7 +3629,7 @@ 

Examples

Expand source code -Browse git +Browse git
def plot_spectrum(self, title=None, method='ls', ax=None, per=None, maxfreq=None, log=False, transformed=True, n=10000):
     """
@@ -3741,7 +3741,7 @@ 

Args

Expand source code -Browse git +Browse git
def remove_indices(self, indices):
     """
@@ -3779,7 +3779,7 @@ 

Examples

Expand source code -Browse git +Browse git
def remove_random_ranges(self, n, duration, dim=0):
     """
@@ -3833,7 +3833,7 @@ 

Examples

Expand source code -Browse git +Browse git
def remove_randomly(self, n=None, pct=None):
     """
@@ -3884,7 +3884,7 @@ 

Examples

Expand source code -Browse git +Browse git
def remove_range(self, start=None, end=None, dim=None):
     """
@@ -3939,7 +3939,7 @@ 

Args

Expand source code -Browse git +Browse git
def remove_relative_range(self, start=0.0, end=1.0, dim=None):
     """
@@ -3969,7 +3969,7 @@ 

Args

Expand source code -Browse git +Browse git
def reset(self):
     """
@@ -3994,7 +3994,7 @@ 

Examples

Expand source code -Browse git +Browse git
def set_function(self, f):
     """
@@ -4028,7 +4028,7 @@ 

Examples

Expand source code -Browse git +Browse git
def set_labels(self, x_labels, y_label):
     """
@@ -4070,7 +4070,7 @@ 

Examples

Expand source code -Browse git +Browse git
def set_name(self, name):
     """
@@ -4101,7 +4101,7 @@ 

Examples

Expand source code -Browse git +Browse git
def set_prediction_data(self, X):
     """
@@ -4146,7 +4146,7 @@ 

Examples

Expand source code -Browse git +Browse git
def set_prediction_range(self, start=None, end=None, n=None, step=None):
     """
@@ -4225,7 +4225,7 @@ 

Examples

Expand source code -Browse git +Browse git
def transform(self, transformer):
     """
diff --git a/docs/dataset.html b/docs/dataset.html
index d797adc..dded303 100644
--- a/docs/dataset.html
+++ b/docs/dataset.html
@@ -9,7 +9,7 @@
 
 
 
-
+
 
 
 
@@ -27,7 +27,7 @@ 

Module mogptk.dataset

Expand source code -Browse git +Browse git
import copy
 
@@ -792,7 +792,7 @@ 

Examples

Expand source code -Browse git +Browse git
def LoadCSV(filename, x_col=0, y_col=1, y_err_col=None, name=None, **kwargs):
     """
@@ -848,7 +848,7 @@ 

Examples

Expand source code -Browse git +Browse git
def LoadDataFrame(df, x_col=0, y_col=1, y_err_col=None, name=None):
     """
@@ -990,7 +990,7 @@ 

Examples

Expand source code -Browse git +Browse git
class DataSet:
     """
@@ -1608,7 +1608,7 @@ 

Examples

Expand source code -Browse git +Browse git
def aggregate(self, duration, f=np.mean):
     """
@@ -1645,7 +1645,7 @@ 

Examples

Expand source code -Browse git +Browse git
def append(self, arg):
     """
@@ -1687,7 +1687,7 @@ 

Examples

Expand source code -Browse git +Browse git
def copy(self):
     """
@@ -1724,7 +1724,7 @@ 

Examples

Expand source code -Browse git +Browse git
def filter(self, start, end, dim=None):
     """
@@ -1765,7 +1765,7 @@ 

Examples

Expand source code -Browse git +Browse git
def get(self, index):
     """
@@ -1819,7 +1819,7 @@ 

Examples

Expand source code -Browse git +Browse git
def get_bnse_estimation(self, Q=1, n=1000, iters=200):
     """
@@ -1869,7 +1869,7 @@ 

Examples

Expand source code -Browse git +Browse git
def get_data(self, transformed=False):
     """
@@ -1909,7 +1909,7 @@ 

Examples

Expand source code -Browse git +Browse git
def get_index(self, index):
     """
@@ -1951,7 +1951,7 @@ 

Examples

Expand source code -Browse git +Browse git
def get_input_dims(self):
     """
@@ -1994,7 +1994,7 @@ 

Examples

Expand source code -Browse git +Browse git
def get_ls_estimation(self, Q=1, n=10000):
     """
@@ -2040,7 +2040,7 @@ 

Examples

Expand source code -Browse git +Browse git
def get_names(self):
     """
@@ -2072,7 +2072,7 @@ 

Examples

Expand source code -Browse git +Browse git
def get_nyquist_estimation(self):
     """
@@ -2104,7 +2104,7 @@ 

Examples

Expand source code -Browse git +Browse git
def get_output_dims(self):
     """
@@ -2136,7 +2136,7 @@ 

Examples

Expand source code -Browse git +Browse git
def get_prediction_data(self):
     """
@@ -2187,7 +2187,7 @@ 

Examples

Expand source code -Browse git +Browse git
def get_sm_estimation(self, Q=1, method='BNSE', optimizer='Adam', iters=200, params={}):
     """
@@ -2239,7 +2239,7 @@ 

Examples

Expand source code -Browse git +Browse git
def get_test_data(self, transformed=False):
     """
@@ -2278,7 +2278,7 @@ 

Examples

Expand source code -Browse git +Browse git
def get_train_data(self, transformed=False):
     """
@@ -2314,7 +2314,7 @@ 

Examples

Expand source code -Browse git +Browse git
def has_test_data(self):
     """
@@ -2361,7 +2361,7 @@ 

Examples

Expand source code -Browse git +Browse git
def plot(self, pred=None, title=None, figsize=None, legend=True, transformed=False):
     """
@@ -2443,7 +2443,7 @@ 

Examples

Expand source code -Browse git +Browse git
def plot_spectrum(self, title=None, method='ls', per=None, maxfreq=None, figsize=None, log=False, transformed=True, n=1001):
     """
@@ -2502,7 +2502,7 @@ 

Examples

Expand source code -Browse git +Browse git
def set_prediction_data(self, X):
     """
@@ -2552,7 +2552,7 @@ 

Examples

Expand source code -Browse git +Browse git
def set_prediction_range(self, start, end, n=None, step=None):
     """
@@ -2616,7 +2616,7 @@ 

Examples

Expand source code -Browse git +Browse git
def transform(self, transformer):
     """
diff --git a/docs/exact_mosm.png b/docs/exact_mosm.png
new file mode 100644
index 0000000..4a695d9
Binary files /dev/null and b/docs/exact_mosm.png differ
diff --git a/docs/examples.html b/docs/examples.html
index 54c273d..4dcc7ec 100644
--- a/docs/examples.html
+++ b/docs/examples.html
@@ -9,7 +9,7 @@
 
 
 
-
+
 
 
 
@@ -47,6 +47,7 @@ 

Index

  • Unstable training: NaNs and Infs
  • +
  • Scalability
    • diff --git a/docs/gpr/config.html b/docs/gpr/config.html index aaaad35..65dd979 100644 --- a/docs/gpr/config.html +++ b/docs/gpr/config.html @@ -9,7 +9,7 @@ - + @@ -27,7 +27,7 @@

      Module mogptk.gpr.config

      Expand source code -Browse git +Browse git
      import torch
       
      @@ -119,7 +119,7 @@ 

      Functions

      Expand source code -Browse git +Browse git
      def print_gpu_information():
           """
      @@ -145,7 +145,7 @@ 

      Functions

      Expand source code -Browse git +Browse git
      def set_positive_minimum(val):
           """
      @@ -162,7 +162,7 @@ 

      Functions

      Expand source code -Browse git +Browse git
      def use_cpu(n=None):
           """
      @@ -182,7 +182,7 @@ 

      Functions

      Expand source code -Browse git +Browse git
      def use_double_precision():
           """
      @@ -199,7 +199,7 @@ 

      Functions

      Expand source code -Browse git +Browse git
      def use_gpu(n=None):
           """
      @@ -223,7 +223,7 @@ 

      Functions

      Expand source code -Browse git +Browse git
      def use_half_precision():
           """
      @@ -242,7 +242,7 @@ 

      Functions

      Expand source code -Browse git +Browse git
      def use_single_precision():
           """
      @@ -264,7 +264,7 @@ 

      Classes

      Expand source code -Browse git +Browse git
      class Config:
           dtype = torch.float32
      diff --git a/docs/gpr/index.html b/docs/gpr/index.html
      index 6711d16..ad6dc3f 100644
      --- a/docs/gpr/index.html
      +++ b/docs/gpr/index.html
      @@ -9,7 +9,7 @@
       
       
       
      -
      +
       
       
       
      @@ -27,7 +27,7 @@ 

      Module mogptk.gpr

      Expand source code -Browse git +Browse git
      from .config import *
       from .plot import plot_gram
      diff --git a/docs/gpr/kernel.html b/docs/gpr/kernel.html
      index ed148c2..38e82ab 100644
      --- a/docs/gpr/kernel.html
      +++ b/docs/gpr/kernel.html
      @@ -9,7 +9,7 @@
       
       
       
      -
      +
       
       
       
      @@ -27,7 +27,7 @@ 

      Module mogptk.gpr.kernel

      Expand source code -Browse git +Browse git
      import torch
       import copy
      @@ -456,7 +456,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      class AddKernel(Kernels):
           """
      @@ -514,7 +514,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      class AutomaticRelevanceDeterminationKernel(MulKernel):
           """
      @@ -569,7 +569,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      class Kernel:
           """
      @@ -794,7 +794,7 @@ 

      Static methods

      Expand source code -Browse git +Browse git
      @staticmethod
       def average(X1, X2=None):
      @@ -812,7 +812,7 @@ 

      Static methods

      Expand source code -Browse git +Browse git
      @staticmethod
       def distance(X1, X2=None):
      @@ -830,7 +830,7 @@ 

      Static methods

      Expand source code -Browse git +Browse git
      @staticmethod
       def squared_distance(X1, X2=None):
      @@ -850,7 +850,7 @@ 

      Instance variables

      Expand source code -Browse git +Browse git
      @property
       def active_dims(self):
      @@ -880,7 +880,7 @@ 

      Returns

      Expand source code -Browse git +Browse git
      def K(self, X1, X2=None):
           """
      @@ -915,7 +915,7 @@ 

      Returns

      Expand source code -Browse git +Browse git
      def K_diag(self, X1):
           """
      @@ -944,7 +944,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      def copy_parameters(self, other):
           """
      @@ -965,7 +965,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      def iterkernels(self):
           """
      @@ -992,7 +992,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      class Kernels(Kernel):
           """
      @@ -1069,7 +1069,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      class MixtureKernel(AddKernel):
           """
      @@ -1120,7 +1120,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      class MulKernel(Kernels):
           """
      @@ -1181,7 +1181,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      class MultiOutputKernel(Kernel):
           """
      @@ -1322,7 +1322,7 @@ 

      Returns

      Expand source code -Browse git +Browse git
      def Ksub(self, i, j, X1, X2=None):
           """
      @@ -1356,7 +1356,7 @@ 

      Returns

      Expand source code -Browse git +Browse git
      def Ksub_diag(self, i, X1):
           """
      diff --git a/docs/gpr/likelihood.html b/docs/gpr/likelihood.html
      index d6b9e40..a206d09 100644
      --- a/docs/gpr/likelihood.html
      +++ b/docs/gpr/likelihood.html
      @@ -9,7 +9,7 @@
       
       
       
      -
      +
       
       
       
      @@ -27,7 +27,7 @@ 

      Module mogptk.gpr.likelihood

      Expand source code -Browse git +Browse git
      import torch
       import numpy as np
      @@ -821,7 +821,7 @@ 

      Functions

      Expand source code -Browse git +Browse git
      def exp(x):
           """
      @@ -841,7 +841,7 @@ 

      Functions

      Expand source code -Browse git +Browse git
      def identity(x):
           """
      @@ -861,7 +861,7 @@ 

      Functions

      Expand source code -Browse git +Browse git
      def inv_probit(x):
           """
      @@ -882,7 +882,7 @@ 

      Functions

      Expand source code -Browse git +Browse git
      def logistic(x):
           """
      @@ -902,7 +902,7 @@ 

      Functions

      Expand source code -Browse git +Browse git
      def square(x):
           """
      @@ -938,7 +938,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      class BernoulliLikelihood(Likelihood):
           """
      @@ -1028,7 +1028,7 @@ 

      Attributes

      Expand source code -Browse git +Browse git
      class BetaLikelihood(Likelihood):
           """
      @@ -1114,7 +1114,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      class ChiSquaredLikelihood(Likelihood):
           """
      @@ -1185,7 +1185,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      class ExponentialLikelihood(Likelihood):
           """
      @@ -1269,7 +1269,7 @@ 

      Attributes

      Expand source code -Browse git +Browse git
      class GammaLikelihood(Likelihood):
           """
      @@ -1343,7 +1343,7 @@ 

      Inherited members

      Expand source code -Browse git +Browse git
      class GaussHermiteQuadrature:
           def __init__(self, deg=20, t_scale=None, w_scale=None):
      @@ -1385,7 +1385,7 @@ 

      Attributes

      Expand source code -Browse git +Browse git
      class GaussianLikelihood(Likelihood):
           """
      @@ -1475,7 +1475,7 @@ 

      Attributes

      Expand source code -Browse git +Browse git
      class LaplaceLikelihood(Likelihood):
           """
      @@ -1544,7 +1544,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      class Likelihood:
           """
      @@ -1679,7 +1679,7 @@ 

      Methods

      Expand source code -Browse git +Browse git
      def log_prob(self, y, f, X=None):
           """
      @@ -1714,7 +1714,7 @@ 

      Returns

      Expand source code -Browse git +Browse git
      def mean(self, f, X=None):
           """
      @@ -1760,7 +1760,7 @@ 

      Returns

      Expand source code -Browse git +Browse git
      def predict(self, mu, var, X=None, full=False):
           """
      @@ -1799,7 +1799,7 @@ 

      Returns

      Expand source code -Browse git +Browse git
      def validate_y(self, y, X=None):
           """
      @@ -1828,7 +1828,7 @@ 

      Returns

      Expand source code -Browse git +Browse git
      def variance(self, f, X=None):
           """
      @@ -1866,7 +1866,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      def variational_expectation(self, y, mu, var, X=None):
           """
      @@ -1914,7 +1914,7 @@ 

      Attributes

      Expand source code -Browse git +Browse git
      class LogGaussianLikelihood(Likelihood):
           """
      @@ -2000,7 +2000,7 @@ 

      Attributes

      Expand source code -Browse git +Browse git
      class LogLogisticLikelihood(Likelihood):
           """
      @@ -2085,7 +2085,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      class MultiOutputLikelihood(Likelihood):
           """
      @@ -2234,7 +2234,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      class PoissonLikelihood(Likelihood):
           """
      @@ -2322,7 +2322,7 @@ 

      Attributes

      Expand source code -Browse git +Browse git
      class StudentTLikelihood(Likelihood):
           """
      @@ -2411,7 +2411,7 @@ 

      Attributes

      Expand source code -Browse git +Browse git
      class WeibullLikelihood(Likelihood):
           """
      diff --git a/docs/gpr/mean.html b/docs/gpr/mean.html
      index 5b44ffa..e5657fd 100644
      --- a/docs/gpr/mean.html
      +++ b/docs/gpr/mean.html
      @@ -9,7 +9,7 @@
       
       
       
      -
      +
       
       
       
      @@ -27,7 +27,7 @@ 

      Module mogptk.gpr.mean

      Expand source code -Browse git +Browse git
      import torch
       from . import Parameter, config
      @@ -165,7 +165,7 @@ 

      Attributes

      Expand source code -Browse git +Browse git
      class ConstantMean(Mean):
           """
      @@ -226,7 +226,7 @@ 

      Attributes

      Expand source code -Browse git +Browse git
      class LinearMean(Mean):
           """
      @@ -274,7 +274,7 @@ 

      Inherited members

      Expand source code -Browse git +Browse git
      class Mean:
           """
      @@ -358,7 +358,7 @@ 

      Returns

      Expand source code -Browse git +Browse git
      def mean(self, X):
           """
      diff --git a/docs/gpr/model.html b/docs/gpr/model.html
      index 209e470..9a3c446 100644
      --- a/docs/gpr/model.html
      +++ b/docs/gpr/model.html
      @@ -9,7 +9,7 @@
       
       
       
      -
      +
       
       
       
      @@ -27,7 +27,7 @@ 

      Module mogptk.gpr.model

      Expand source code -Browse git +Browse git
      import sys
       import torch
      @@ -360,7 +360,7 @@ 

      Module mogptk.gpr.model

      Returns: numpy.ndarray: Kernel matrix of shape (data_points0,data_points1). """ - with torch.no_grad(): + with torch.inference_mode(): return self.kernel(X1, X2).cpu().numpy() def sample(self, Z, n=None, predict_y=True, prior=False): @@ -376,7 +376,7 @@

      Module mogptk.gpr.model

      Returns: torch.tensor: Samples of shape (data_points,samples) or (data_points,) if `n` is not given. """ - with torch.no_grad(): + with torch.inference_mode(): S = n if n is None: S = 1 @@ -453,7 +453,7 @@

      Module mogptk.gpr.model

      return p def predict(self, Xs, full=False, tensor=False, predict_y=True): - with torch.no_grad(): + with torch.inference_mode(): Xs = self._check_input(Xs) # MxD if self.mean is not None: y = self.y - self.mean(self.X).reshape(-1,1) # Nx1 @@ -551,7 +551,7 @@

      Module mogptk.gpr.model

      return p def predict(self, Xs, full=False, tensor=False, predict_y=True): - with torch.no_grad(): + with torch.inference_mode(): Xs = self._check_input(Xs) # MxD if self.mean is not None: y = self.y - self.mean(self.X).reshape(-1,1) # Nx1 @@ -664,7 +664,7 @@

      Module mogptk.gpr.model

      return self.elbo() def predict(self, Xs, full=False, tensor=False, predict_y=True): - with torch.no_grad(): + with torch.inference_mode(): Xs = self._check_input(Xs) # MxD Kff = self.kernel(self.X) @@ -757,7 +757,7 @@

      Module mogptk.gpr.model

      return self.elbo() def predict(self, Xs, full=False, tensor=False, predict_y=True): - with torch.no_grad(): + with torch.inference_mode(): Xs = self._check_input(Xs) # MxD if self.mean is not None: y = self.y - self.mean(self.X).reshape(-1,1) # Nx1 @@ -899,7 +899,7 @@

      Module mogptk.gpr.model

      return mu, var def predict(self, Xs, full=False, tensor=False, predict_y=True): - with torch.no_grad(): + with torch.inference_mode(): Xs = self._check_input(Xs) # MxD mu, var = self._predict(Xs, full=full) @@ -964,7 +964,7 @@

      Returns

      Expand source code -Browse git +Browse git
      def init_inducing_points(Z, X, method='grid', output_dims=None):
           """
      @@ -1016,7 +1016,7 @@ 

      Classes

      Expand source code -Browse git +Browse git
      class CholeskyException(Exception):
           def __init__(self, message, K, model):
      @@ -1062,7 +1062,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      class Exact(Model):
           """
      @@ -1118,7 +1118,7 @@ 

      Args

      return p def predict(self, Xs, full=False, tensor=False, predict_y=True): - with torch.no_grad(): + with torch.inference_mode(): Xs = self._check_input(Xs) # MxD if self.mean is not None: y = self.y - self.mean(self.X).reshape(-1,1) # Nx1 @@ -1170,10 +1170,10 @@

      Methods

      Expand source code -Browse git +Browse git
      def predict(self, Xs, full=False, tensor=False, predict_y=True):
      -    with torch.no_grad():
      +    with torch.inference_mode():
               Xs = self._check_input(Xs)  # MxD
               if self.mean is not None:
                   y = self.y - self.mean(self.X).reshape(-1,1)  # Nx1
      @@ -1257,7 +1257,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      class Hensman(SparseHensman):
           """
      @@ -1318,7 +1318,7 @@ 

      Attributes

      Expand source code -Browse git +Browse git
      class Model:
           """
      @@ -1575,7 +1575,7 @@ 

      Attributes

      Returns: numpy.ndarray: Kernel matrix of shape (data_points0,data_points1). """ - with torch.no_grad(): + with torch.inference_mode(): return self.kernel(X1, X2).cpu().numpy() def sample(self, Z, n=None, predict_y=True, prior=False): @@ -1591,7 +1591,7 @@

      Attributes

      Returns: torch.tensor: Samples of shape (data_points,samples) or (data_points,) if `n` is not given. """ - with torch.no_grad(): + with torch.inference_mode(): S = n if n is None: S = 1 @@ -1644,7 +1644,7 @@

      Returns

      Expand source code -Browse git +Browse git
      def K(self, X1, X2=None):
           """
      @@ -1657,7 +1657,7 @@ 

      Returns

      Returns: numpy.ndarray: Kernel matrix of shape (data_points0,data_points1). """ - with torch.no_grad(): + with torch.inference_mode(): return self.kernel(X1, X2).cpu().numpy()
      @@ -1674,7 +1674,7 @@

      Returns

      Expand source code -Browse git +Browse git
      def get_parameters(self):
           """
      @@ -1700,7 +1700,7 @@ 

      Returns

      Expand source code -Browse git +Browse git
      def log_marginal_likelihood(self):
           """
      @@ -1728,7 +1728,7 @@ 

      Returns

      Expand source code -Browse git +Browse git
      def log_prior(self):
           """
      @@ -1755,7 +1755,7 @@ 

      Returns

      Expand source code -Browse git +Browse git
      def loss(self):
           """
      @@ -1780,7 +1780,7 @@ 

      Returns

      Expand source code -Browse git +Browse git
      def named_parameters(self):
           """
      @@ -1804,7 +1804,7 @@ 

      Returns

      Expand source code -Browse git +Browse git
      def parameters(self):
           """
      @@ -1826,7 +1826,7 @@ 

      Returns

      Expand source code -Browse git +Browse git
      def print_parameters(self, file=None):
           """
      @@ -1907,7 +1907,7 @@ 

      Returns

      Expand source code -Browse git +Browse git
      def sample(self, Z, n=None, predict_y=True, prior=False):
           """
      @@ -1922,7 +1922,7 @@ 

      Returns

      Returns: torch.tensor: Samples of shape (data_points,samples) or (data_points,) if `n` is not given. """ - with torch.no_grad(): + with torch.inference_mode(): S = n if n is None: S = 1 @@ -1954,7 +1954,7 @@

      Returns

      Expand source code -Browse git +Browse git
      def zero_grad(self):
           for p in self._params:
      @@ -1992,7 +1992,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      class OpperArchambeau(Model):
           """
      @@ -2063,7 +2063,7 @@ 

      Args

      return self.elbo() def predict(self, Xs, full=False, tensor=False, predict_y=True): - with torch.no_grad(): + with torch.inference_mode(): Xs = self._check_input(Xs) # MxD Kff = self.kernel(self.X) @@ -2106,7 +2106,7 @@

      Methods

      Expand source code -Browse git +Browse git
      def elbo(self):
           if self.mean is not None:
      @@ -2156,10 +2156,10 @@ 

      Methods

      Expand source code -Browse git +Browse git
      def predict(self, Xs, full=False, tensor=False, predict_y=True):
      -    with torch.no_grad():
      +    with torch.inference_mode():
               Xs = self._check_input(Xs)  # MxD
       
               Kff = self.kernel(self.X)
      @@ -2238,7 +2238,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      class Snelson(Model):
           """
      @@ -2300,7 +2300,7 @@ 

      Args

      return p def predict(self, Xs, full=False, tensor=False, predict_y=True): - with torch.no_grad(): + with torch.inference_mode(): Xs = self._check_input(Xs) # MxD if self.mean is not None: y = self.y - self.mean(self.X).reshape(-1,1) # Nx1 @@ -2358,10 +2358,10 @@

      Methods

      Expand source code -Browse git +Browse git
      def predict(self, Xs, full=False, tensor=False, predict_y=True):
      -    with torch.no_grad():
      +    with torch.inference_mode():
               Xs = self._check_input(Xs)  # MxD
               if self.mean is not None:
                   y = self.y - self.mean(self.X).reshape(-1,1)  # Nx1
      @@ -2455,7 +2455,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      class SparseHensman(Model):
           """
      @@ -2554,7 +2554,7 @@ 

      Args

      return mu, var def predict(self, Xs, full=False, tensor=False, predict_y=True): - with torch.no_grad(): + with torch.inference_mode(): Xs = self._check_input(Xs) # MxD mu, var = self._predict(Xs, full=full) @@ -2586,7 +2586,7 @@

      Methods

      Expand source code -Browse git +Browse git
      def elbo(self):
           if self.mean is not None:
      @@ -2620,7 +2620,7 @@ 

      Methods

      Expand source code -Browse git +Browse git
      def kl_gaussian(self, q_mu, q_sqrt):
           S_diag = q_sqrt.diagonal().square() # NxN
      @@ -2639,10 +2639,10 @@ 

      Methods

      Expand source code -Browse git +Browse git
      def predict(self, Xs, full=False, tensor=False, predict_y=True):
      -    with torch.no_grad():
      +    with torch.inference_mode():
               Xs = self._check_input(Xs)  # MxD
       
               mu, var = self._predict(Xs, full=full)
      @@ -2706,7 +2706,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      class Titsias(Model):
           """
      @@ -2772,7 +2772,7 @@ 

      Args

      return self.elbo() def predict(self, Xs, full=False, tensor=False, predict_y=True): - with torch.no_grad(): + with torch.inference_mode(): Xs = self._check_input(Xs) # MxD if self.mean is not None: y = self.y - self.mean(self.X).reshape(-1,1) # Nx1 @@ -2831,7 +2831,7 @@

      Methods

      Expand source code -Browse git +Browse git
      def elbo(self):
           if self.mean is not None:
      @@ -2868,10 +2868,10 @@ 

      Methods

      Expand source code -Browse git +Browse git
      def predict(self, Xs, full=False, tensor=False, predict_y=True):
      -    with torch.no_grad():
      +    with torch.inference_mode():
               Xs = self._check_input(Xs)  # MxD
               if self.mean is not None:
                   y = self.y - self.mean(self.X).reshape(-1,1)  # Nx1
      diff --git a/docs/gpr/multioutput.html b/docs/gpr/multioutput.html
      index 76abc66..15edfb6 100644
      --- a/docs/gpr/multioutput.html
      +++ b/docs/gpr/multioutput.html
      @@ -9,7 +9,7 @@
       
       
       
      -
      +
       
       
       
      @@ -27,7 +27,7 @@ 

      Module mogptk.gpr.multioutput

      Expand source code -Browse git +Browse git
      import torch
       import numpy as np
      @@ -626,7 +626,7 @@ 

      Attributes

      Expand source code -Browse git +Browse git
      class CrossSpectralKernel(MultiOutputKernel):
           """
      @@ -737,7 +737,7 @@ 

      Attributes

      Expand source code -Browse git +Browse git
      class GaussianConvolutionProcessKernel(MultiOutputKernel):
           """
      @@ -828,7 +828,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      class IndependentMultiOutputKernel(MultiOutputKernel):
           """
      @@ -912,7 +912,7 @@ 

      Attributes

      Expand source code -Browse git +Browse git
      class LinearModelOfCoregionalizationKernel(MultiOutputKernel):
           """
      @@ -1021,7 +1021,7 @@ 

      Attributes

      Expand source code -Browse git +Browse git
      class MultiOutputHarmonizableSpectralKernel(MultiOutputKernel):
           """
      @@ -1185,7 +1185,7 @@ 

      Attributes

      Expand source code -Browse git +Browse git
      class MultiOutputSpectralKernel(MultiOutputKernel):
           """
      @@ -1333,7 +1333,7 @@ 

      Attributes

      Expand source code -Browse git +Browse git
      class MultiOutputSpectralMixtureKernel(MultiOutputKernel):
           """
      @@ -1481,7 +1481,7 @@ 

      Attributes

      Expand source code -Browse git +Browse git
      class UncoupledMultiOutputSpectralKernel(MultiOutputKernel):
           """
      diff --git a/docs/gpr/parameter.html b/docs/gpr/parameter.html
      index 92e936e..680e49f 100644
      --- a/docs/gpr/parameter.html
      +++ b/docs/gpr/parameter.html
      @@ -9,7 +9,7 @@
       
       
       
      -
      +
       
       
       
      @@ -27,7 +27,7 @@ 

      Module mogptk.gpr.parameter

      Expand source code -Browse git +Browse git
      import numpy as np
       import torch
      @@ -354,7 +354,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      class Parameter:
           """
      @@ -582,7 +582,7 @@ 

      Static methods

      Expand source code -Browse git +Browse git
      @staticmethod
       def to_tensor(value):
      @@ -606,7 +606,7 @@ 

      Returns

      Expand source code -Browse git +Browse git
      @property
       def constrained(self):
      @@ -635,7 +635,7 @@ 

      Returns

      Expand source code -Browse git +Browse git
      @property
       def pegged(self):
      @@ -668,7 +668,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      def assign(self, value=None, name=None, lower=None, upper=None, prior=None, train=None):
           """
      @@ -784,7 +784,7 @@ 

      Returns

      Expand source code -Browse git +Browse git
      def log_prior(self):
           """
      @@ -811,7 +811,7 @@ 

      Returns

      Expand source code -Browse git +Browse git
      def numpy(self):
           """
      @@ -838,7 +838,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      def peg(self, other, transform=None):
           """
      @@ -878,7 +878,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      class Sigmoid(Transform):
           """
      @@ -939,7 +939,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      class Softplus(Transform):
           """
      @@ -989,7 +989,7 @@ 

      Inherited members

      Expand source code -Browse git +Browse git
      class Transform:
           """
      @@ -1024,7 +1024,7 @@ 

      Methods

      Expand source code -Browse git +Browse git
      def forward(self, x):
           """
      @@ -1042,7 +1042,7 @@ 

      Methods

      Expand source code -Browse git +Browse git
      def inverse(self, y):
           """
      diff --git a/docs/gpr/plot.html b/docs/gpr/plot.html
      index 0c92e35..e837a19 100644
      --- a/docs/gpr/plot.html
      +++ b/docs/gpr/plot.html
      @@ -9,7 +9,7 @@
       
       
       
      -
      +
       
       
       
      @@ -27,7 +27,7 @@ 

      Module mogptk.gpr.plot

      Expand source code -Browse git +Browse git
      import numpy as np
       import matplotlib
      @@ -79,7 +79,7 @@ 

      Functions

      Expand source code -Browse git +Browse git
      def plot_gram(K):
           fig, ax = plt.subplots(1, 1, figsize=(6,6))
      diff --git a/docs/gpr/singleoutput.html b/docs/gpr/singleoutput.html
      index 7e96b7c..faad218 100644
      --- a/docs/gpr/singleoutput.html
      +++ b/docs/gpr/singleoutput.html
      @@ -9,7 +9,7 @@
       
       
       
      -
      +
       
       
       
      @@ -27,7 +27,7 @@ 

      Module mogptk.gpr.singleoutput

      Expand source code -Browse git +Browse git
      import torch
       import numpy as np
      @@ -735,7 +735,7 @@ 

      Attributes

      Expand source code -Browse git +Browse git
      class ConstantKernel(Kernel):
           """
      @@ -813,7 +813,7 @@ 

      Attributes

      Expand source code -Browse git +Browse git
      class CosineKernel(Kernel):
           """
      @@ -896,7 +896,7 @@ 

      Attributes

      Expand source code -Browse git +Browse git
      class ExponentialKernel(Kernel):
           """
      @@ -979,7 +979,7 @@ 

      Attributes

      Expand source code -Browse git +Browse git
      class FunctionKernel(Kernel):
           """
      @@ -1066,7 +1066,7 @@ 

      Attributes

      Expand source code -Browse git +Browse git
      class LinearKernel(Kernel):
           """
      @@ -1152,7 +1152,7 @@ 

      Attributes

      Expand source code -Browse git +Browse git
      class LocallyPeriodicKernel(Kernel):
           """
      @@ -1257,7 +1257,7 @@ 

      Attributes

      Expand source code -Browse git +Browse git
      class MaternKernel(Kernel):
           """
      @@ -1359,7 +1359,7 @@ 

      Attributes

      Expand source code -Browse git +Browse git
      class PeriodicKernel(Kernel):
           """
      @@ -1465,7 +1465,7 @@ 

      Attributes

      Expand source code -Browse git +Browse git
      class PolynomialKernel(Kernel):
           """
      @@ -1556,7 +1556,7 @@ 

      Attributes

      Expand source code -Browse git +Browse git
      class RationalQuadraticKernel(Kernel):
           """
      @@ -1659,7 +1659,7 @@ 

      Attributes

      Expand source code -Browse git +Browse git
      class SincKernel(Kernel):
           """
      @@ -1753,7 +1753,7 @@ 

      Attributes

      Expand source code -Browse git +Browse git
      class SpectralKernel(Kernel):
           """
      @@ -1847,7 +1847,7 @@ 

      Attributes

      Expand source code -Browse git +Browse git
      class SpectralMixtureKernel(Kernel):
           """
      @@ -1941,7 +1941,7 @@ 

      Attributes

      Expand source code -Browse git +Browse git
      class SquaredExponentialKernel(Kernel):
           """
      @@ -2037,7 +2037,7 @@ 

      Attributes

      Expand source code -Browse git +Browse git
      class WhiteKernel(Kernel):
           """
      diff --git a/docs/gpr/util.html b/docs/gpr/util.html
      index 3dba7e9..5c3c0cf 100644
      --- a/docs/gpr/util.html
      +++ b/docs/gpr/util.html
      @@ -9,7 +9,7 @@
       
       
       
      -
      +
       
       
       
      @@ -27,7 +27,7 @@ 

      Module mogptk.gpr.util

      Expand source code -Browse git +Browse git
      import inspect
       import torch
      @@ -118,7 +118,7 @@ 

      Functions

      Expand source code -Browse git +Browse git
      def merge_data(xs, ys=None):
           if not isinstance(xs, list) or ys is not None and not isinstance(ys, list):
      @@ -153,7 +153,7 @@ 

      Functions

      Expand source code -Browse git +Browse git
      def split_data(N, *Xs):
           if not all(X.ndim == 2 for X in Xs):
      diff --git a/docs/index.html b/docs/index.html
      index e2051b5..35493fc 100644
      --- a/docs/index.html
      +++ b/docs/index.html
      @@ -9,7 +9,7 @@
       
       
       
      -
      +
       
       
       
      @@ -132,10 +132,22 @@ 

      Unstable training: NaNs and Infs

      - Make sure all kernel and model parameters are in their valid range and there are no NaNs or Infs - Make sure your data has no NaNs or Infs - Make sure your data X and Y value ranges are not extremely small or big

      +

      Scalability

      +

      How model training scales in time and memory usage over some of the data and hyperparameter is shown in the plots below.

      +

      Exact model, MOSM kernel, memory and execution time scaling with hyperparameters

      +

      For each plot, we initialize a MOSM kernel and use exact inference (ie. without inducing points). The data is generated randomly of size (data_points,1+input_dims), where the first column contains the output indices. The output indices are assigned by dividing the data points in equal parts of output dimensions. We keep the other four parameters constant while varying one parameter for each of the plots.

      +

      Conclusions:

      +
        +
      • There are no memory leaks since memory is constant for iterations and time is linear
      • +
      • It is quadratic in the number of data points, both in memory and time. I believe that Cholesky decomposition, which scales O(n^3), is really fast but that in this range the O(n^2) nature of the kernel matrix and other calculations is simply the slowest. For larger numbers of data points the cubic nature of time should take over.
      • +
      • Both the number of input dimensions and mixture components are linear in memory and time and are very fast in general. Note that these variables depend on the kernel and not on the inference model.
      • +
      • It is quadratic in time but something like O(1/n) for memory over the output dimensions. Both results are interesting. I believe that the sequential nature of how we compute each sub Gram matrix for each channel combination allows us to use less memory (which is recycled for each channel combination). Time is quadratic since we need to evaluate M*M sub Gram matrices, with M the number of channels.
      • +
      +

      Regarding the output dimensions, the sub Gram matrixes are of course smaller since the total number of data points is kept constant. However instead of using large vectorized operations as we'd have for a single output dimension, we have to process each sub kernel sequentially with smaller vectorized operations for each sub kernel. This can't be optimized further since the number of data points per channel is variable. When the number of data points for all channels is equal, we could write an optimized multi-output kernel that calculates the resulting Gram matrix at once instead of calculating all the sub Gram matrices.

      Expand source code -Browse git +Browse git
      """
       .. include:: ./documentation.md
      @@ -219,6 +231,7 @@ 

      Index

    • Unstable training: NaNs and Infs
    +
  • Scalability
    • diff --git a/docs/init.html b/docs/init.html index cacfde2..3e7a125 100644 --- a/docs/init.html +++ b/docs/init.html @@ -9,7 +9,7 @@ - + @@ -27,7 +27,7 @@

      Module mogptk.init

      Expand source code -Browse git +Browse git
      import torch
       import numpy as np
      @@ -117,7 +117,7 @@ 

      Module mogptk.init

      imag = torch.exp(exp2a)*torch.sin(exp3a) + torch.exp(exp2b)*torch.sin(exp3b) return a * real, a * imag - with torch.no_grad(): + with torch.inference_mode(): Ktt = kernel(x) Ktt += model.likelihood.scale().square() * torch.eye(x.shape[0], device=gpr.config.device, dtype=gpr.config.dtype) Ltt = model._cholesky(Ktt, add_jitter=True) @@ -190,7 +190,7 @@

      Returns

      Expand source code -Browse git +Browse git
      def BNSE(x, y, y_err=None, max_freq=None, n=1000, iters=100):
           """
      @@ -276,7 +276,7 @@ 

      Returns

      imag = torch.exp(exp2a)*torch.sin(exp3a) + torch.exp(exp2b)*torch.sin(exp3b) return a * real, a * imag - with torch.no_grad(): + with torch.inference_mode(): Ktt = kernel(x) Ktt += model.likelihood.scale().square() * torch.eye(x.shape[0], device=gpr.config.device, dtype=gpr.config.dtype) Ltt = model._cholesky(Ktt, add_jitter=True) diff --git a/docs/model.html b/docs/model.html index abea763..43199d6 100644 --- a/docs/model.html +++ b/docs/model.html @@ -9,7 +9,7 @@ - + @@ -27,7 +27,7 @@

      Module mogptk.model

      Expand source code -Browse git +Browse git
      import os
       import time
      @@ -1082,7 +1082,7 @@ 

      Examples

      Expand source code -Browse git +Browse git
      def LoadModel(filename):
           """
      @@ -1120,7 +1120,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      class Exact:
           """
      @@ -1169,7 +1169,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      class Hensman:
           """
      @@ -1212,7 +1212,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      class Kernels(dict):
           __getattr__ = dict.get
      @@ -1257,7 +1257,7 @@

      Attributes

      Expand source code -Browse git +Browse git
      class Model:
           def __init__(self, dataset, kernel, inference=Exact(), mean=None, name=None):
      @@ -2106,7 +2106,7 @@ 

      Examples

      Expand source code -Browse git +Browse git
      def AIC(self):
           """
      @@ -2137,7 +2137,7 @@ 

      Examples

      Expand source code -Browse git +Browse git
      def BIC(self):
           """
      @@ -2177,7 +2177,7 @@ 

      Examples

      Expand source code -Browse git +Browse git
      def K(self, X1, X2=None):
           """
      @@ -2213,7 +2213,7 @@ 

      Examples

      Expand source code -Browse git +Browse git
      def copy_parameters(self, other):
           """
      @@ -2246,7 +2246,7 @@ 

      Examples

      Expand source code -Browse git +Browse git
      def error(self, method='MAE', use_all_data=False):
           """
      @@ -2319,7 +2319,7 @@ 

      Examples

      Expand source code -Browse git +Browse git
      def get_parameters(self):
           """
      @@ -2350,7 +2350,7 @@ 

      Examples

      Expand source code -Browse git +Browse git
      def log_marginal_likelihood(self):
           """
      @@ -2381,7 +2381,7 @@ 

      Examples

      Expand source code -Browse git +Browse git
      def loss(self):
           """
      @@ -2412,7 +2412,7 @@ 

      Examples

      Expand source code -Browse git +Browse git
      def num_parameters(self):
           """
      @@ -2443,7 +2443,7 @@ 

      Examples

      Expand source code -Browse git +Browse git
      def num_training_points(self):
           """
      @@ -2480,7 +2480,7 @@ 

      Returns

      Expand source code -Browse git +Browse git
      def plot_correlation(self, title=None, figsize=(12,12)):
           """
      @@ -2548,7 +2548,7 @@ 

      Returns

      Expand source code -Browse git +Browse git
      def plot_gram(self, start=None, end=None, n=31, title=None, figsize=(12,12)):
           """
      @@ -2639,7 +2639,7 @@ 

      Returns

      Expand source code -Browse git +Browse git
      def plot_kernel(self, dist=None, n=101, title=None, figsize=(12,12)):
           """
      @@ -2713,7 +2713,7 @@ 

      Returns

      Expand source code -Browse git +Browse git
      def plot_losses(self, title=None, figsize=(12,4), legend=True, errors=True, log=False):
           """
      @@ -2798,7 +2798,7 @@ 

      Examples

      Expand source code -Browse git +Browse git
      def plot_prediction(self, X=None, title=None, figsize=None, legend=True, errorbars=True, sigma=2, predict_y=True, transformed=False):
           """
      @@ -2948,7 +2948,7 @@ 

      Examples

      Expand source code -Browse git +Browse git
      def predict(self, X=None, sigma=2, predict_y=True, transformed=False):
           """
      @@ -3014,7 +3014,7 @@ 

      Examples

      Expand source code -Browse git +Browse git
      def print_parameters(self):
           """
      @@ -3057,7 +3057,7 @@ 

      Examples

      Expand source code -Browse git +Browse git
      def sample(self, X=None, n=None, predict_y=True, prior=False, transformed=False):
           """
      @@ -3121,7 +3121,7 @@ 

      Examples

      Expand source code -Browse git +Browse git
      def save(self, filename):
           """
      @@ -3179,7 +3179,7 @@ 

      Examples

      Expand source code -Browse git +Browse git
      def train(
           self,
      @@ -3336,7 +3336,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      class OpperArchambeau:
           """
      @@ -3374,7 +3374,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      class Snelson:
           """
      @@ -3418,7 +3418,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      class Titsias:
           """
      diff --git a/docs/models/conv.html b/docs/models/conv.html
      index 1ffc968..9798fa8 100644
      --- a/docs/models/conv.html
      +++ b/docs/models/conv.html
      @@ -9,7 +9,7 @@
       
       
       
      -
      +
       
       
       
      @@ -27,7 +27,7 @@ 

      Module mogptk.models.conv

      Expand source code -Browse git +Browse git
      import numpy as np
       
      @@ -214,7 +214,7 @@ 

      Attributes

      Expand source code -Browse git +Browse git
      class CONV(Model):
           """
      @@ -340,7 +340,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      def init_parameters(self, method='SM', iters=500):
           """
      diff --git a/docs/models/csm.html b/docs/models/csm.html
      index 4bc0ee9..3294b6a 100644
      --- a/docs/models/csm.html
      +++ b/docs/models/csm.html
      @@ -9,7 +9,7 @@
       
       
       
      -
      +
       
       
       
      @@ -27,7 +27,7 @@ 

      Module mogptk.models.csm

      Expand source code -Browse git +Browse git
      import numpy as np
       
      @@ -224,7 +224,7 @@ 

      Attributes

      Expand source code -Browse git +Browse git
      class CSM(Model):
           """
      @@ -358,7 +358,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      def init_parameters(self, method='BNSE', iters=500):
           """
      diff --git a/docs/models/index.html b/docs/models/index.html
      index 00a8056..9cdac9a 100644
      --- a/docs/models/index.html
      +++ b/docs/models/index.html
      @@ -9,7 +9,7 @@
       
       
       
      -
      +
       
       
       
      diff --git a/docs/models/mohsm.html b/docs/models/mohsm.html
      index 3e195af..7725d80 100644
      --- a/docs/models/mohsm.html
      +++ b/docs/models/mohsm.html
      @@ -9,7 +9,7 @@
       
       
       
      -
      +
       
       
       
      @@ -27,7 +27,7 @@ 

      Module mogptk.models.mohsm

      Expand source code -Browse git +Browse git
      import numpy as np
       
      @@ -254,7 +254,7 @@ 

      Attributes

      Expand source code -Browse git +Browse git
      class MOHSM(Model):
           """
      @@ -420,7 +420,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      def init_parameters(self, method='BNSE', iters=500):
           """
      diff --git a/docs/models/mosm.html b/docs/models/mosm.html
      index b453f77..2bd2d53 100644
      --- a/docs/models/mosm.html
      +++ b/docs/models/mosm.html
      @@ -9,7 +9,7 @@
       
       
       
      -
      +
       
       
       
      @@ -27,7 +27,7 @@ 

      Module mogptk.models.mosm

      Expand source code -Browse git +Browse git
      import numpy as np
       import matplotlib.pyplot as plt
      @@ -364,7 +364,7 @@ 

      Attributes

      Expand source code -Browse git +Browse git
      class MOSM(Model):
           """
      @@ -629,7 +629,7 @@ 

      Methods

      Expand source code -Browse git +Browse git
      def check(self):
           """
      @@ -664,7 +664,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      def init_parameters(self, method='BNSE', iters=500):
           """
      @@ -740,7 +740,7 @@ 

      Returns

      Expand source code -Browse git +Browse git
      def plot_cross_spectrum(self, title=None, figsize=(12,12)):
           """
      @@ -871,7 +871,7 @@ 

      Returns

      Expand source code -Browse git +Browse git
      def plot_spectrum(self, method='LS', maxfreq=None, log=False, noise=False, title=None):
           """
      diff --git a/docs/models/sm.html b/docs/models/sm.html
      index 6d93819..63b1a76 100644
      --- a/docs/models/sm.html
      +++ b/docs/models/sm.html
      @@ -9,7 +9,7 @@
       
       
       
      -
      +
       
       
       
      @@ -27,7 +27,7 @@ 

      Module mogptk.models.sm

      Expand source code -Browse git +Browse git
      import numpy as np
       
      @@ -264,7 +264,7 @@ 

      Attributes

      Expand source code -Browse git +Browse git
      class SM(Model):
           """
      @@ -440,7 +440,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      def init_parameters(self, method='LS', iters=500):
           """
      @@ -532,7 +532,7 @@ 

      Returns

      Expand source code -Browse git +Browse git
      def plot_spectrum(self, method='LS', maxfreq=None, log=False, noise=False, title=None):
           """
      diff --git a/docs/models/sm_lmc.html b/docs/models/sm_lmc.html
      index 764f06e..a15bedf 100644
      --- a/docs/models/sm_lmc.html
      +++ b/docs/models/sm_lmc.html
      @@ -9,7 +9,7 @@
       
       
       
      -
      +
       
       
       
      @@ -27,7 +27,7 @@ 

      Module mogptk.models.sm_lmc

      Expand source code -Browse git +Browse git
      import numpy as np
       
      @@ -228,7 +228,7 @@ 

      Attributes

      Expand source code -Browse git +Browse git
      class SM_LMC(Model):
           """
      @@ -365,7 +365,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      def init_parameters(self, method='BNSE', iters=500):
           """
      diff --git a/docs/transformer.html b/docs/transformer.html
      index 22e993d..2fdd9e3 100644
      --- a/docs/transformer.html
      +++ b/docs/transformer.html
      @@ -9,7 +9,7 @@
       
       
       
      -
      +
       
       
       
      @@ -27,7 +27,7 @@ 

      Module mogptk.transformer

      Expand source code -Browse git +Browse git
      import copy
       import numpy as np
      @@ -201,7 +201,7 @@ 

      Classes

      Expand source code -Browse git +Browse git
      class TransformBase:
           """
      @@ -235,7 +235,7 @@ 

      Methods

      Expand source code -Browse git +Browse git
      def backward(self, y, x=None):
           raise NotImplementedError
      @@ -249,7 +249,7 @@

      Methods

      Expand source code -Browse git +Browse git
      def forward(self, y, x=None):
           raise NotImplementedError
      @@ -263,7 +263,7 @@

      Methods

      Expand source code -Browse git +Browse git
      def set_data(self, y, x=None):
           pass
      @@ -287,7 +287,7 @@

      Args

      Expand source code -Browse git +Browse git
      class TransformDetrend(TransformBase):
           """
      @@ -334,7 +334,7 @@ 

      Methods

      Expand source code -Browse git +Browse git
      def backward(self, y, x):
           if x is None:
      @@ -351,7 +351,7 @@ 

      Methods

      Expand source code -Browse git +Browse git
      def forward(self, y, x):
           if x is None:
      @@ -368,7 +368,7 @@ 

      Methods

      Expand source code -Browse git +Browse git
      def set_data(self, y, x=None):
           self.coef = np.polyfit(x[:,self.dim], y, self.degree)
      @@ -385,7 +385,7 @@

      Methods

      Expand source code -Browse git +Browse git
      class TransformLinear(TransformBase):
           """
      @@ -418,7 +418,7 @@ 

      Methods

      Expand source code -Browse git +Browse git
      def backward(self, y, x=None):
           return self.bias + self.slope*y
      @@ -432,7 +432,7 @@

      Methods

      Expand source code -Browse git +Browse git
      def forward(self, y, x=None):
           return (y-self.bias)/self.slope
      @@ -448,7 +448,7 @@

      Methods

      Expand source code -Browse git +Browse git
      class TransformLog(TransformBase):
           """
      @@ -484,7 +484,7 @@ 

      Methods

      Expand source code -Browse git +Browse git
      def backward(self, y, x=None):
           return np.exp(y + self.mean) - self.shift
      @@ -498,7 +498,7 @@

      Methods

      Expand source code -Browse git +Browse git
      def forward(self, y, x=None):
           return np.log(y + self.shift) - self.mean
      @@ -512,7 +512,7 @@

      Methods

      Expand source code -Browse git +Browse git
      def set_data(self, y, x=None):
           self.shift = 1 - y.min()
      @@ -529,7 +529,7 @@ 

      Methods

      Expand source code -Browse git +Browse git
      class TransformNormalize(TransformBase):
           """
      @@ -565,7 +565,7 @@ 

      Methods

      Expand source code -Browse git +Browse git
      def backward(self, y, x=None):
           return (y+1.0)/2.0*(self.ymax-self.ymin)+self.ymin
      @@ -579,7 +579,7 @@

      Methods

      Expand source code -Browse git +Browse git
      def forward(self, y, x=None):
           return -1.0 + 2.0*(y-self.ymin)/(self.ymax-self.ymin)
      @@ -593,7 +593,7 @@

      Methods

      Expand source code -Browse git +Browse git
      def set_data(self, y, x=None):
           self.ymin = np.amin(y)
      @@ -610,7 +610,7 @@ 

      Methods

      Expand source code -Browse git +Browse git
      class TransformStandard(TransformBase):
           """
      @@ -646,7 +646,7 @@ 

      Methods

      Expand source code -Browse git +Browse git
      def backward(self, y, x=None):
           return (y * self.std) + self.mean
      @@ -660,7 +660,7 @@

      Methods

      Expand source code -Browse git +Browse git
      def forward(self, y, x=None):
           return (y - self.mean) / self.std
      @@ -674,7 +674,7 @@

      Methods

      Expand source code -Browse git +Browse git
      def set_data(self, y, x=None):
           self.mean = y.mean()
      @@ -692,7 +692,7 @@ 

      Methods

      Expand source code -Browse git +Browse git
      class Transformer:
           def __init__(self, transformers=None):
      @@ -733,7 +733,7 @@ 

      Methods

      Expand source code -Browse git +Browse git
      def append(self, t, y, x=None):
           if isinstance(t, type):
      @@ -753,7 +753,7 @@ 

      Methods

      Expand source code -Browse git +Browse git
      def backward(self, y, x=None):
           for t in self.transformers[::-1]:
      @@ -769,7 +769,7 @@ 

      Methods

      Expand source code -Browse git +Browse git
      def forward(self, y, x=None):
           for t in self.transformers:
      diff --git a/docs/util.html b/docs/util.html
      index c44327a..99d670e 100644
      --- a/docs/util.html
      +++ b/docs/util.html
      @@ -9,7 +9,7 @@
       
       
       
      -
      +
       
       
       
      @@ -27,7 +27,7 @@ 

      Module mogptk.util

      Expand source code -Browse git +Browse git
      import numpy as np
       import pandas as pd
      @@ -295,7 +295,7 @@ 

      Example

      Expand source code -Browse git +Browse git
      def error(*models, X=None, Y=None, per_channel=False, transformed=False, disp=False):
           """
      @@ -390,7 +390,7 @@ 

      Example

      Expand source code -Browse git +Browse git
      def mean_absolute_error(y_true, y_pred):
           """
      @@ -408,7 +408,7 @@ 

      Example

      Expand source code -Browse git +Browse git
      def mean_absolute_percentage_error(y_true, y_pred):
           """
      @@ -428,7 +428,7 @@ 

      Example

      Expand source code -Browse git +Browse git
      def mean_squared_error(y_true, y_pred):
           """
      @@ -446,7 +446,7 @@ 

      Example

      Expand source code -Browse git +Browse git
      def plot_spectrum(means, scales, dataset=None, weights=None, noises=None, method='LS', maxfreq=None, log=False, n=10000, titles=None, show=True, filename=None, title=None):
           """
      @@ -557,7 +557,7 @@ 

      Example

      Expand source code -Browse git +Browse git
      def root_mean_squared_error(y_true, y_pred):
           """
      @@ -575,7 +575,7 @@ 

      Example

      Expand source code -Browse git +Browse git
      def symmetric_mean_absolute_percentage_error(y_true, y_pred):
           """
      diff --git a/html.mako b/html.mako
      index 32c762f..84cde04 100644
      --- a/html.mako
      +++ b/html.mako
      @@ -407,8 +407,8 @@
           
         % endif
       
      -  
      -  
      +  
      +  
         % if syntax_highlighting:
           
         %endif
      @@ -435,11 +435,11 @@
         % endif
       
         % if latex_math:
      -    
      +    
         % endif
       
         % if syntax_highlighting:
      -    
      +    
           
         % endif
       
      diff --git a/mogptk/documentation.md b/mogptk/documentation.md
      index 06c4be5..c211ffd 100644
      --- a/mogptk/documentation.md
      +++ b/mogptk/documentation.md
      @@ -104,3 +104,20 @@ Due to numerical issues this is unfortunately quite frequent in Gaussian process
       - Make sure all kernel and model parameters are in their valid range and there are no NaNs or Infs
       - Make sure your data has no NaNs or Infs
       - Make sure your data X and Y value ranges are not extremely small or big
      +
      +
      +## Scalability
      +How model training scales in time and memory usage over some of the data and hyperparameter is shown in the plots below.
      +
      +![Exact model, MOSM kernel, memory and execution time scaling with hyperparameters](exact_mosm.png)
      +
      +For each plot, we initialize a MOSM kernel and use exact inference (ie. without inducing points). The data is generated randomly of size `(data_points,1+input_dims)`, where the first column contains the output indices. The output indices are assigned by dividing the data points in equal parts of output dimensions. We keep the other four parameters constant while varying one parameter for each of the plots.
      +
      +**Conclusions:**
      +
      +* There are no memory leaks since memory is constant for iterations and time is linear
      +* It is quadratic in the number of data points, both in memory and time. I believe that Cholesky decomposition, which scales O(n^3), is really fast but that in this range the O(n^2) nature of the kernel matrix and other calculations is simply the slowest. For larger numbers of data points the cubic nature of time should take over.
      +* Both the number of input dimensions and mixture components are linear in memory and time and are very fast in general. Note that these variables depend on the kernel and not on the inference model.
      +* It is quadratic in time but something like O(1/n) for memory over the output dimensions. Both results are interesting. I believe that the sequential nature of how we compute each sub Gram matrix for each channel combination allows us to use less memory (which is recycled for each channel combination). Time is quadratic since we need to evaluate M*M sub Gram matrices, with M the number of channels.
      +
      +Regarding the output dimensions, the sub Gram matrixes are of course smaller since the total number of data points is kept constant. However instead of using large vectorized operations as we'd have for a single output dimension, we have to process each sub kernel sequentially with smaller vectorized operations for each sub kernel. This can't be optimized further since the number of data points per channel is variable. When the number of data points for all channels is equal, we could write an optimized multi-output kernel that calculates the resulting Gram matrix at once instead of calculating all the sub Gram matrices.
      diff --git a/resources/exact_mosm.png b/resources/exact_mosm.png
      new file mode 100644
      index 0000000..4a695d9
      Binary files /dev/null and b/resources/exact_mosm.png differ