mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-15 06:52:39 +02:00
maint: Wrap very long lines (> 400 chars)
This commit is contained in:
parent
d754bc12de
commit
44f4739efb
4 changed files with 73 additions and 17 deletions
|
|
@ -5,23 +5,40 @@
|
||||||
Introduction
|
Introduction
|
||||||
^^^^^^^^^^^^
|
^^^^^^^^^^^^
|
||||||
|
|
||||||
This module contains the fundamental classes of GPy - classes that are inherited by objects in other parts of GPy in order to provide a consistent interface to major functionality.
|
This module contains the fundamental classes of GPy - classes that are
|
||||||
|
inherited by objects in other parts of GPy in order to provide a
|
||||||
|
consistent interface to major functionality.
|
||||||
|
|
||||||
.. inheritance-diagram:: GPy.core.gp.GP
|
.. inheritance-diagram:: GPy.core.gp.GP
|
||||||
:top-classes: paramz.core.parameter_core.Parameterizable
|
:top-classes: paramz.core.parameter_core.Parameterizable
|
||||||
|
|
||||||
:py:class:`GPy.core.model` is inherited by :py:class:`GPy.core.gp.GP`. And :py:class:`GPy.core.model` itself inherits :py:class:`paramz.model.Model` from the `paramz` package. `paramz` essentially provides an inherited set of properties and functions used to manage state (and state changes) of the model.
|
:py:class:`GPy.core.model` is inherited by
|
||||||
|
:py:class:`GPy.core.gp.GP`. And :py:class:`GPy.core.model` itself
|
||||||
|
inherits :py:class:`paramz.model.Model` from the `paramz`
|
||||||
|
package. `paramz` essentially provides an inherited set of properties
|
||||||
|
and functions used to manage state (and state changes) of the model.
|
||||||
|
|
||||||
:py:class:`GPy.core.gp.GP` represents a GP model. Such an entity is typically passed variables representing known (x) and observed (y) data, along with a kernel and other information needed to create the specific model. It exposes functions which return information derived from the inputs to the model, for example predicting unobserved variables based on new known variables, or the log marginal likelihood of the current state of the model.
|
:py:class:`GPy.core.gp.GP` represents a GP model. Such an entity is
|
||||||
|
typically passed variables representing known (x) and observed (y)
|
||||||
|
data, along with a kernel and other information needed to create the
|
||||||
|
specific model. It exposes functions which return information derived
|
||||||
|
from the inputs to the model, for example predicting unobserved
|
||||||
|
variables based on new known variables, or the log marginal likelihood
|
||||||
|
of the current state of the model.
|
||||||
|
|
||||||
:py:func:`~GPy.core.gp.GP.optimize` is called to optimize hyperparameters of the model. The optimizer argument takes a string which is used to specify non-default optimization schemes.
|
:py:func:`~GPy.core.gp.GP.optimize` is called to optimize
|
||||||
|
hyperparameters of the model. The optimizer argument takes a string
|
||||||
|
which is used to specify non-default optimization schemes.
|
||||||
|
|
||||||
Various plotting functions can be called against :py:class:`GPy.core.gp.GP`.
|
Various plotting functions can be called against :py:class:`GPy.core.gp.GP`.
|
||||||
|
|
||||||
.. inheritance-diagram:: GPy.core.gp_grid.GpGrid GPy.core.sparse_gp.SparseGP GPy.core.sparse_gp_mpi.SparseGP_MPI GPy.core.svgp.SVGP
|
.. inheritance-diagram:: GPy.core.gp_grid.GpGrid GPy.core.sparse_gp.SparseGP GPy.core.sparse_gp_mpi.SparseGP_MPI GPy.core.svgp.SVGP
|
||||||
:top-classes: GPy.core.gp.GP
|
:top-classes: GPy.core.gp.GP
|
||||||
|
|
||||||
:py:class:`GPy.core.gp.GP` is used as the basis for classes supporting more specialized types of Gaussian Process model. These are however generally still not specific enough to be called by the user and are inhereted by members of the :py:class:`GPy.models` package.
|
:py:class:`GPy.core.gp.GP` is used as the basis for classes supporting
|
||||||
|
more specialized types of Gaussian Process model. These are however
|
||||||
|
generally still not specific enough to be called by the user and are
|
||||||
|
inhereted by members of the :py:class:`GPy.models` package.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,20 @@
|
||||||
Introduction
|
Introduction
|
||||||
^^^^^^^^^^^^
|
^^^^^^^^^^^^
|
||||||
|
|
||||||
In terms of Gaussian Processes, a kernel is a function that specifies the degree of similarity between variables given their relative positions in parameter space. If known variables *x* and *x'* are close together then observed variables *y* and *y'* may also be similar, depending on the kernel function and its parameters. *Note: this may be too simple a definition for the broad range of kernels available in :py:class:`GPy`.*
|
In terms of Gaussian Processes, a kernel is a function that specifies
|
||||||
|
the degree of similarity between variables given their relative
|
||||||
|
positions in parameter space. If known variables *x* and *x'* are
|
||||||
|
close together then observed variables *y* and *y'* may also be
|
||||||
|
similar, depending on the kernel function and its parameters. *Note:
|
||||||
|
this may be too simple a definition for the broad range of kernels
|
||||||
|
available in :py:class:`GPy`.*
|
||||||
|
|
||||||
:py:class:`GPy.kern.src.kern.Kern` is a generic kernel object inherited by more specific, end-user kernels used in models. It provides methods that specific kernels should generally have such as :py:class:`GPy.kern.src.kern.Kern.K` to compute the value of the kernel, :py:class:`GPy.kern.src.kern.Kern.add` to combine kernels and numerous functions providing information on kernel gradients.
|
:py:class:`GPy.kern.src.kern.Kern` is a generic kernel object
|
||||||
|
inherited by more specific, end-user kernels used in models. It
|
||||||
|
provides methods that specific kernels should generally have such as
|
||||||
|
:py:class:`GPy.kern.src.kern.Kern.K` to compute the value of the
|
||||||
|
kernel, :py:class:`GPy.kern.src.kern.Kern.add` to combine kernels and
|
||||||
|
numerous functions providing information on kernel gradients.
|
||||||
|
|
||||||
There are several inherited types of kernel that provide a basis for specific end user kernels:
|
There are several inherited types of kernel that provide a basis for specific end user kernels:
|
||||||
|
|
||||||
|
|
@ -20,7 +31,6 @@ e.g. the archetype :py:class:`GPy.kern.RBF` does not inherit directly from :py:c
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
from .src.kern import Kern
|
from .src.kern import Kern
|
||||||
from .src.add import Add
|
from .src.add import Add
|
||||||
from .src.prod import Prod
|
from .src.prod import Prod
|
||||||
|
|
@ -61,4 +71,4 @@ from .src.sde_stationary import sde_RBF,sde_Exponential,sde_RatQuad
|
||||||
from .src.sde_brownian import sde_Brownian
|
from .src.sde_brownian import sde_Brownian
|
||||||
from .src.multioutput_kern import MultioutputKern
|
from .src.multioutput_kern import MultioutputKern
|
||||||
from .src.multioutput_derivative_kern import MultioutputDerivativeKern
|
from .src.multioutput_derivative_kern import MultioutputDerivativeKern
|
||||||
from .src.diff_kern import DiffKern
|
from .src.diff_kern import DiffKern
|
||||||
|
|
|
||||||
|
|
@ -448,12 +448,34 @@ class PSICOMP_SSRBF_GPU(PSICOMP_RBF):
|
||||||
dL_dpsi0_sum = dL_dpsi0.sum()
|
dL_dpsi0_sum = dL_dpsi0.sum()
|
||||||
|
|
||||||
self.reset_derivative()
|
self.reset_derivative()
|
||||||
# t=self.g_psi1compDer(dvar_gpu,dl_gpu,dZ_gpu,dmu_gpu,dS_gpu,dL_dpsi1_gpu,psi1_gpu, np.float64(variance),l_gpu,Z_gpu,mu_gpu,S_gpu, np.int32(N), np.int32(M), np.int32(Q), block=(self.threadnum,1,1), grid=(self.blocknum,1),time_kernel=True)
|
# t=self.g_psi1compDer(dvar_gpu,dl_gpu,dZ_gpu,dmu_gpu,dS_gpu,dL_dpsi1_gpu,psi1_gpu,
|
||||||
|
# np.float64(variance),l_gpu,Z_gpu,mu_gpu,S_gpu, np.int32(N),
|
||||||
|
# np.int32(M), np.int32(Q), block=(self.threadnum,1,1),
|
||||||
|
# grid=(self.blocknum,1),time_kernel=True)
|
||||||
# print 'g_psi1compDer '+str(t)
|
# print 'g_psi1compDer '+str(t)
|
||||||
# t=self.g_psi2compDer(dvar_gpu,dl_gpu,dZ_gpu,dmu_gpu,dS_gpu,dL_dpsi2_gpu,psi2n_gpu, np.float64(variance),l_gpu,Z_gpu,mu_gpu,S_gpu, np.int32(N), np.int32(M), np.int32(Q), block=(self.threadnum,1,1), grid=(self.blocknum,1),time_kernel=True)
|
# t=self.g_psi2compDer(dvar_gpu,dl_gpu,dZ_gpu,dmu_gpu,dS_gpu,dL_dpsi2_gpu,psi2n_gpu,
|
||||||
|
# np.float64(variance),l_gpu,Z_gpu,mu_gpu,S_gpu, np.int32(N),
|
||||||
|
# np.int32(M), np.int32(Q), block=(self.threadnum,1,1),
|
||||||
|
# grid=(self.blocknum,1),time_kernel=True)
|
||||||
# print 'g_psi2compDer '+str(t)
|
# print 'g_psi2compDer '+str(t)
|
||||||
self.g_psi1compDer.prepared_call((self.blocknum,1),(self.threadnum,1,1),dvar_gpu.gpudata,dl_gpu.gpudata,dZ_gpu.gpudata,dmu_gpu.gpudata,dS_gpu.gpudata,dgamma_gpu.gpudata,dL_dpsi1_gpu.gpudata,psi1_gpu.gpudata, log_denom1_gpu.gpudata, log_gamma_gpu.gpudata, log_gamma1_gpu.gpudata, np.float64(variance),l_gpu.gpudata,Z_gpu.gpudata,mu_gpu.gpudata,S_gpu.gpudata,gamma_gpu.gpudata,np.int32(N), np.int32(M), np.int32(Q))
|
self.g_psi1compDer.prepared_call((self.blocknum,1), (self.threadnum,1,1),
|
||||||
self.g_psi2compDer.prepared_call((self.blocknum,1),(self.threadnum,1,1),dvar_gpu.gpudata,dl_gpu.gpudata,dZ_gpu.gpudata,dmu_gpu.gpudata,dS_gpu.gpudata,dgamma_gpu.gpudata,dL_dpsi2_gpu.gpudata,psi2n_gpu.gpudata, log_denom2_gpu.gpudata, log_gamma_gpu.gpudata, log_gamma1_gpu.gpudata, np.float64(variance),l_gpu.gpudata,Z_gpu.gpudata,mu_gpu.gpudata,S_gpu.gpudata,gamma_gpu.gpudata,np.int32(N), np.int32(M), np.int32(Q))
|
dvar_gpu.gpudata, dl_gpu.gpudata, dZ_gpu.gpudata,
|
||||||
|
dmu_gpu.gpudata, dS_gpu.gpudata, dgamma_gpu.gpudata,
|
||||||
|
dL_dpsi1_gpu.gpudata, psi1_gpu.gpudata,
|
||||||
|
log_denom1_gpu.gpudata, log_gamma_gpu.gpudata,
|
||||||
|
log_gamma1_gpu.gpudata, np.float64(variance),
|
||||||
|
l_gpu.gpudata, Z_gpu.gpudata, mu_gpu.gpudata,
|
||||||
|
S_gpu.gpudata, gamma_gpu.gpudata, np.int32(N),
|
||||||
|
np.int32(M), np.int32(Q))
|
||||||
|
self.g_psi2compDer.prepared_call((self.blocknum,1), (self.threadnum,1,1),
|
||||||
|
dvar_gpu.gpudata, dl_gpu.gpudata, dZ_gpu.gpudata,
|
||||||
|
dmu_gpu.gpudata, dS_gpu.gpudata, dgamma_gpu.gpudata,
|
||||||
|
dL_dpsi2_gpu.gpudata, psi2n_gpu.gpudata,
|
||||||
|
log_denom2_gpu.gpudata, log_gamma_gpu.gpudata,
|
||||||
|
log_gamma1_gpu.gpudata, np.float64(variance),
|
||||||
|
l_gpu.gpudata, Z_gpu.gpudata, mu_gpu.gpudata,
|
||||||
|
S_gpu.gpudata, gamma_gpu.gpudata, np.int32(N),
|
||||||
|
np.int32(M), np.int32(Q))
|
||||||
|
|
||||||
dL_dvar = dL_dpsi0_sum + gpuarray.sum(dvar_gpu).get()
|
dL_dvar = dL_dpsi0_sum + gpuarray.sum(dvar_gpu).get()
|
||||||
sum_axis(grad_mu_gpu,dmu_gpu,N*Q,self.blocknum)
|
sum_axis(grad_mu_gpu,dmu_gpu,N*Q,self.blocknum)
|
||||||
|
|
@ -468,7 +490,6 @@ class PSICOMP_SSRBF_GPU(PSICOMP_RBF):
|
||||||
dL_dlengscale = grad_l_gpu.get()
|
dL_dlengscale = grad_l_gpu.get()
|
||||||
else:
|
else:
|
||||||
dL_dlengscale = gpuarray.sum(dl_gpu).get()
|
dL_dlengscale = gpuarray.sum(dl_gpu).get()
|
||||||
|
|
||||||
return dL_dvar, dL_dlengscale, dL_dZ, dL_dmu, dL_dS, dL_dgamma
|
return dL_dvar, dL_dlengscale, dL_dZ, dL_dmu, dL_dS, dL_dgamma
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -500,7 +500,15 @@ def drosophila_knirps(data_set='drosophila_protein'):
|
||||||
|
|
||||||
# This will be for downloading google trends data.
|
# This will be for downloading google trends data.
|
||||||
def google_trends(query_terms=['big data', 'machine learning', 'data science'], data_set='google_trends', refresh_data=False):
|
def google_trends(query_terms=['big data', 'machine learning', 'data science'], data_set='google_trends', refresh_data=False):
|
||||||
"""Data downloaded from Google trends for given query terms. Warning, if you use this function multiple times in a row you get blocked due to terms of service violations. The function will cache the result of your query, if you wish to refresh an old query set refresh_data to True. The function is inspired by this notebook: http://nbviewer.ipython.org/github/sahuguet/notebooks/blob/master/GoogleTrends%20meet%20Notebook.ipynb"""
|
"""Data downloaded from Google trends for given query terms.
|
||||||
|
|
||||||
|
Warning, if you use this function multiple times in a row you get
|
||||||
|
blocked due to terms of service violations. The function will cache
|
||||||
|
the result of your query, if you wish to refresh an old query set
|
||||||
|
refresh_data to True.
|
||||||
|
|
||||||
|
The function is inspired by this notebook:
|
||||||
|
http://nbviewer.ipython.org/github/sahuguet/notebooks/blob/master/GoogleTrends%20meet%20Notebook.ipynb"""
|
||||||
query_terms.sort()
|
query_terms.sort()
|
||||||
import pandas
|
import pandas
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue