mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-15 06:52:39 +02:00
Merge branch 'devel' of github.com:SheffieldML/GPy into devel
This commit is contained in:
commit
a976d2b42b
16 changed files with 100 additions and 85 deletions
|
|
@ -15,7 +15,7 @@ class GP(GPBase):
|
||||||
|
|
||||||
:param X: input observations
|
:param X: input observations
|
||||||
:param kernel: a GPy kernel, defaults to rbf+white
|
:param kernel: a GPy kernel, defaults to rbf+white
|
||||||
:parm likelihood: a GPy likelihood
|
:param likelihood: a GPy likelihood
|
||||||
:param normalize_X: whether to normalize the input data before computing (predictions will be in original scales)
|
:param normalize_X: whether to normalize the input data before computing (predictions will be in original scales)
|
||||||
:type normalize_X: False|True
|
:type normalize_X: False|True
|
||||||
:rtype: model object
|
:rtype: model object
|
||||||
|
|
@ -132,17 +132,16 @@ class GP(GPBase):
|
||||||
def predict(self, Xnew, which_parts='all', full_cov=False, likelihood_args=dict()):
|
def predict(self, Xnew, which_parts='all', full_cov=False, likelihood_args=dict()):
|
||||||
"""
|
"""
|
||||||
Predict the function(s) at the new point(s) Xnew.
|
Predict the function(s) at the new point(s) Xnew.
|
||||||
Arguments
|
|
||||||
---------
|
|
||||||
:param Xnew: The points at which to make a prediction
|
:param Xnew: The points at which to make a prediction
|
||||||
:type Xnew: np.ndarray, Nnew x self.input_dim
|
:type Xnew: np.ndarray, Nnew x self.input_dim
|
||||||
:param which_parts: specifies which outputs kernel(s) to use in prediction
|
:param which_parts: specifies which outputs kernel(s) to use in prediction
|
||||||
:type which_parts: ('all', list of bools)
|
:type which_parts: ('all', list of bools)
|
||||||
:param full_cov: whether to return the full covariance matrix, or just the diagonal
|
:param full_cov: whether to return the full covariance matrix, or just the diagonal
|
||||||
:type full_cov: bool
|
:type full_cov: bool
|
||||||
:rtype: posterior mean, a Numpy array, Nnew x self.input_dim
|
:returns: mean: posterior mean, a Numpy array, Nnew x self.input_dim
|
||||||
:rtype: posterior variance, a Numpy array, Nnew x 1 if full_cov=False, Nnew x Nnew otherwise
|
:returns: var: posterior variance, a Numpy array, Nnew x 1 if full_cov=False, Nnew x Nnew otherwise
|
||||||
:rtype: lower and upper boundaries of the 95% confidence intervals, Numpy arrays, Nnew x self.input_dim
|
:returns: lower and upper boundaries of the 95% confidence intervals, Numpy arrays, Nnew x self.input_dim
|
||||||
|
|
||||||
|
|
||||||
If full_cov and self.input_dim > 1, the return shape of var is Nnew x Nnew x self.input_dim. If self.input_dim == 1, the return shape is Nnew x Nnew.
|
If full_cov and self.input_dim > 1, the return shape of var is Nnew x Nnew x self.input_dim. If self.input_dim == 1, the return shape is Nnew x Nnew.
|
||||||
|
|
@ -160,8 +159,7 @@ class GP(GPBase):
|
||||||
def predict_single_output(self, Xnew, output=0, which_parts='all', full_cov=False):
|
def predict_single_output(self, Xnew, output=0, which_parts='all', full_cov=False):
|
||||||
"""
|
"""
|
||||||
For a specific output, predict the function at the new point(s) Xnew.
|
For a specific output, predict the function at the new point(s) Xnew.
|
||||||
Arguments
|
|
||||||
---------
|
|
||||||
:param Xnew: The points at which to make a prediction
|
:param Xnew: The points at which to make a prediction
|
||||||
:type Xnew: np.ndarray, Nnew x self.input_dim
|
:type Xnew: np.ndarray, Nnew x self.input_dim
|
||||||
:param output: output to predict
|
:param output: output to predict
|
||||||
|
|
@ -170,9 +168,9 @@ class GP(GPBase):
|
||||||
:type which_parts: ('all', list of bools)
|
:type which_parts: ('all', list of bools)
|
||||||
:param full_cov: whether to return the full covariance matrix, or just the diagonal
|
:param full_cov: whether to return the full covariance matrix, or just the diagonal
|
||||||
:type full_cov: bool
|
:type full_cov: bool
|
||||||
:rtype: posterior mean, a Numpy array, Nnew x self.input_dim
|
:returns: posterior mean, a Numpy array, Nnew x self.input_dim
|
||||||
:rtype: posterior variance, a Numpy array, Nnew x 1 if full_cov=False, Nnew x Nnew otherwise
|
:returns: posterior variance, a Numpy array, Nnew x 1 if full_cov=False, Nnew x Nnew otherwise
|
||||||
:rtype: lower and upper boundaries of the 95% confidence intervals, Numpy arrays, Nnew x self.input_dim
|
:returns: lower and upper boundaries of the 95% confidence intervals, Numpy arrays, Nnew x self.input_dim
|
||||||
|
|
||||||
.. Note:: For multiple output models only
|
.. Note:: For multiple output models only
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ class Model(Parameterized):
|
||||||
|
|
||||||
:param state: the state of the model.
|
:param state: the state of the model.
|
||||||
:type state: list as returned from getstate.
|
:type state: list as returned from getstate.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
self.preferred_optimizer = state.pop()
|
self.preferred_optimizer = state.pop()
|
||||||
self.sampling_runs = state.pop()
|
self.sampling_runs = state.pop()
|
||||||
|
|
@ -543,10 +544,11 @@ class Model(Parameterized):
|
||||||
"""
|
"""
|
||||||
EM - like algorithm for Expectation Propagation and Laplace approximation
|
EM - like algorithm for Expectation Propagation and Laplace approximation
|
||||||
|
|
||||||
:stop_crit: convergence criterion
|
:param stop_crit: convergence criterion
|
||||||
:type stop_crit: float
|
:type stop_crit: float
|
||||||
|
|
||||||
..Note: kwargs are passed to update_likelihood and optimize functions. """
|
.. Note: kwargs are passed to update_likelihood and optimize functions.
|
||||||
|
"""
|
||||||
assert isinstance(self.likelihood, likelihoods.EP) or isinstance(self.likelihood, likelihoods.EP_Mixed_Noise), "pseudo_EM is only available for EP likelihoods"
|
assert isinstance(self.likelihood, likelihoods.EP) or isinstance(self.likelihood, likelihoods.EP_Mixed_Noise), "pseudo_EM is only available for EP likelihoods"
|
||||||
ll_change = stop_crit + 1.
|
ll_change = stop_crit + 1.
|
||||||
iteration = 0
|
iteration = 0
|
||||||
|
|
|
||||||
|
|
@ -393,8 +393,7 @@ class SparseGP(GPBase):
|
||||||
def predict_single_output(self, Xnew, output=0, which_parts='all', full_cov=False):
|
def predict_single_output(self, Xnew, output=0, which_parts='all', full_cov=False):
|
||||||
"""
|
"""
|
||||||
For a specific output, predict the function at the new point(s) Xnew.
|
For a specific output, predict the function at the new point(s) Xnew.
|
||||||
Arguments
|
|
||||||
---------
|
|
||||||
:param Xnew: The points at which to make a prediction
|
:param Xnew: The points at which to make a prediction
|
||||||
:type Xnew: np.ndarray, Nnew x self.input_dim
|
:type Xnew: np.ndarray, Nnew x self.input_dim
|
||||||
:param output: output to predict
|
:param output: output to predict
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,10 @@ class opt_SGD(Optimizer):
|
||||||
"""
|
"""
|
||||||
Optimize using stochastic gradient descent.
|
Optimize using stochastic gradient descent.
|
||||||
|
|
||||||
*** Parameters ***
|
:param Model: reference to the Model object
|
||||||
Model: reference to the Model object
|
:param iterations: number of iterations
|
||||||
iterations: number of iterations
|
:param learning_rate: learning rate
|
||||||
learning_rate: learning rate
|
:param momentum: momentum
|
||||||
momentum: momentum
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -80,27 +80,28 @@ def gibbs(input_dim,variance=1., mapping=None):
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
r = sqrt((x_i - x_j)'*(x_i - x_j))
|
r = \\sqrt{((x_i - x_j)'*(x_i - x_j))}
|
||||||
|
|
||||||
k(x_i, x_j) = \sigma^2*Z*exp(-r^2/(l(x)*l(x) + l(x')*l(x')))
|
k(x_i, x_j) = \\sigma^2*Z*exp(-r^2/(l(x)*l(x) + l(x')*l(x')))
|
||||||
|
|
||||||
Z = \sqrt{2*l(x)*l(x')/(l(x)*l(x) + l(x')*l(x')}
|
Z = \\sqrt{2*l(x)*l(x')/(l(x)*l(x) + l(x')*l(x')}
|
||||||
|
|
||||||
|
Where :math:`l(x)` is a function giving the length scale as a function of space.
|
||||||
|
|
||||||
where :math:`l(x)` is a function giving the length scale as a function of space.
|
|
||||||
This is the non stationary kernel proposed by Mark Gibbs in his 1997
|
This is the non stationary kernel proposed by Mark Gibbs in his 1997
|
||||||
thesis. It is similar to an RBF but has a length scale that varies
|
thesis. It is similar to an RBF but has a length scale that varies
|
||||||
with input location. This leads to an additional term in front of
|
with input location. This leads to an additional term in front of
|
||||||
the kernel.
|
the kernel.
|
||||||
|
|
||||||
The parameters are :math:`\sigma^2`, the process variance, and the parameters of l(x) which is a function that can be specified by the user, by default an multi-layer peceptron is used is used.
|
The parameters are :math:`\\sigma^2`, the process variance, and the parameters of l(x) which is a function that can be specified by the user, by default an multi-layer peceptron is used is used.
|
||||||
|
|
||||||
:param input_dim: the number of input dimensions
|
:param input_dim: the number of input dimensions
|
||||||
:type input_dim: int
|
:type input_dim: int
|
||||||
:param variance: the variance :math:`\sigma^2`
|
:param variance: the variance :math:`\\sigma^2`
|
||||||
:type variance: float
|
:type variance: float
|
||||||
:param mapping: the mapping that gives the lengthscale across the input space.
|
:param mapping: the mapping that gives the lengthscale across the input space.
|
||||||
:type mapping: GPy.core.Mapping
|
:type mapping: GPy.core.Mapping
|
||||||
:param ARD: Auto Relevance Determination. If equal to "False", the kernel is isotropic (ie. one weight variance parameter \sigma^2_w), otherwise there is one weight variance parameter per dimension.
|
:param ARD: Auto Relevance Determination. If equal to "False", the kernel is isotropic (ie. one weight variance parameter :math:`\\sigma^2_w`), otherwise there is one weight variance parameter per dimension.
|
||||||
:type ARD: Boolean
|
:type ARD: Boolean
|
||||||
:rtype: Kernpart object
|
:rtype: Kernpart object
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -222,7 +222,8 @@ class kern(Parameterized):
|
||||||
|
|
||||||
def prod(self, other, tensor=False):
|
def prod(self, other, tensor=False):
|
||||||
"""
|
"""
|
||||||
multiply two kernels (either on the same space, or on the tensor product of the input space).
|
Multiply two kernels (either on the same space, or on the tensor product of the input space).
|
||||||
|
|
||||||
:param other: the other kernel to be added
|
:param other: the other kernel to be added
|
||||||
:type other: GPy.kern
|
:type other: GPy.kern
|
||||||
:param tensor: whether or not to use the tensor space (default is false).
|
:param tensor: whether or not to use the tensor space (default is false).
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,7 @@ class EP(likelihood):
|
||||||
:type epsilon: float
|
:type epsilon: float
|
||||||
:param power_ep: Power EP parameters
|
:param power_ep: Power EP parameters
|
||||||
:type power_ep: list of floats
|
:type power_ep: list of floats
|
||||||
|
|
||||||
"""
|
"""
|
||||||
self.epsilon = epsilon
|
self.epsilon = epsilon
|
||||||
self.eta, self.delta = power_ep
|
self.eta, self.delta = power_ep
|
||||||
|
|
@ -165,6 +166,7 @@ class EP(likelihood):
|
||||||
:type epsilon: float
|
:type epsilon: float
|
||||||
:param power_ep: Power EP parameters
|
:param power_ep: Power EP parameters
|
||||||
:type power_ep: list of floats
|
:type power_ep: list of floats
|
||||||
|
|
||||||
"""
|
"""
|
||||||
self.epsilon = epsilon
|
self.epsilon = epsilon
|
||||||
self.eta, self.delta = power_ep
|
self.eta, self.delta = power_ep
|
||||||
|
|
|
||||||
|
|
@ -10,14 +10,16 @@ class likelihood(Parameterized):
|
||||||
(Gaussian) inherits directly from this, as does the EP algorithm
|
(Gaussian) inherits directly from this, as does the EP algorithm
|
||||||
|
|
||||||
Some things must be defined for this to work properly:
|
Some things must be defined for this to work properly:
|
||||||
self.Y : the effective Gaussian target of the GP
|
|
||||||
self.N, self.D : Y.shape
|
- self.Y : the effective Gaussian target of the GP
|
||||||
self.covariance_matrix : the effective (noise) covariance of the GP targets
|
- self.N, self.D : Y.shape
|
||||||
self.Z : a factor which gets added to the likelihood (0 for a Gaussian, Z_EP for EP)
|
- self.covariance_matrix : the effective (noise) covariance of the GP targets
|
||||||
self.is_heteroscedastic : enables significant computational savings in GP
|
- self.Z : a factor which gets added to the likelihood (0 for a Gaussian, Z_EP for EP)
|
||||||
self.precision : a scalar or vector representation of the effective target precision
|
- self.is_heteroscedastic : enables significant computational savings in GP
|
||||||
self.YYT : (optional) = np.dot(self.Y, self.Y.T) enables computational savings for D>N
|
- self.precision : a scalar or vector representation of the effective target precision
|
||||||
self.V : self.precision * self.Y
|
- self.YYT : (optional) = np.dot(self.Y, self.Y.T) enables computational savings for D>N
|
||||||
|
- self.V : self.precision * self.Y
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
Parameterized.__init__(self)
|
Parameterized.__init__(self)
|
||||||
|
|
|
||||||
|
|
@ -245,12 +245,13 @@ class BayesianGPLVM(SparseGP, GPLVM):
|
||||||
"""
|
"""
|
||||||
Plot latent space X in 1D:
|
Plot latent space X in 1D:
|
||||||
|
|
||||||
-if fig is given, create input_dim subplots in fig and plot in these
|
- if fig is given, create input_dim subplots in fig and plot in these
|
||||||
-if ax is given plot input_dim 1D latent space plots of X into each `axis`
|
- if ax is given plot input_dim 1D latent space plots of X into each `axis`
|
||||||
-if neither fig nor ax is given create a figure with fignum and plot in there
|
- if neither fig nor ax is given create a figure with fignum and plot in there
|
||||||
|
|
||||||
colors:
|
colors:
|
||||||
colors of different latent space dimensions input_dim
|
colors of different latent space dimensions input_dim
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import pylab
|
import pylab
|
||||||
if ax is None:
|
if ax is None:
|
||||||
|
|
|
||||||
|
|
@ -524,11 +524,14 @@ def simulation_BGPLVM():
|
||||||
'info': "Simulated test dataset generated in MATLAB to compare BGPLVM between python and MATLAB"}
|
'info': "Simulated test dataset generated in MATLAB to compare BGPLVM between python and MATLAB"}
|
||||||
|
|
||||||
def toy_rbf_1d(seed=default_seed, num_samples=500):
|
def toy_rbf_1d(seed=default_seed, num_samples=500):
|
||||||
"""Samples values of a function from an RBF covariance with very small noise for inputs uniformly distributed between -1 and 1.
|
"""
|
||||||
|
Samples values of a function from an RBF covariance with very small noise for inputs uniformly distributed between -1 and 1.
|
||||||
|
|
||||||
:param seed: seed to use for random sampling.
|
:param seed: seed to use for random sampling.
|
||||||
:type seed: int
|
:type seed: int
|
||||||
:param num_samples: number of samples to sample in the function (default 500).
|
:param num_samples: number of samples to sample in the function (default 500).
|
||||||
:type num_samples: int
|
:type num_samples: int
|
||||||
|
|
||||||
"""
|
"""
|
||||||
np.random.seed(seed=seed)
|
np.random.seed(seed=seed)
|
||||||
num_in = 1
|
num_in = 1
|
||||||
|
|
@ -631,11 +634,15 @@ def olympic_marathon_men(data_set='olympic_marathon_men'):
|
||||||
|
|
||||||
|
|
||||||
def crescent_data(num_data=200, seed=default_seed):
|
def crescent_data(num_data=200, seed=default_seed):
|
||||||
"""Data set formed from a mixture of four Gaussians. In each class two of the Gaussians are elongated at right angles to each other and offset to form an approximation to the crescent data that is popular in semi-supervised learning as a toy problem.
|
"""
|
||||||
|
Data set formed from a mixture of four Gaussians. In each class two of the Gaussians are elongated at right angles to each other and offset to form an approximation to the crescent data that is popular in semi-supervised learning as a toy problem.
|
||||||
|
|
||||||
:param num_data_part: number of data to be sampled (default is 200).
|
:param num_data_part: number of data to be sampled (default is 200).
|
||||||
:type num_data: int
|
:type num_data: int
|
||||||
:param seed: random seed to be used for data generation.
|
:param seed: random seed to be used for data generation.
|
||||||
:type seed: int"""
|
:type seed: int
|
||||||
|
|
||||||
|
"""
|
||||||
np.random.seed(seed=seed)
|
np.random.seed(seed=seed)
|
||||||
sqrt2 = np.sqrt(2)
|
sqrt2 = np.sqrt(2)
|
||||||
# Rotation matrix
|
# Rotation matrix
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,7 @@ def jitchol(A, maxtries=5):
|
||||||
|
|
||||||
def jitchol_old(A, maxtries=5):
|
def jitchol_old(A, maxtries=5):
|
||||||
"""
|
"""
|
||||||
:param A : An almost pd square matrix
|
:param A: An almost pd square matrix
|
||||||
|
|
||||||
:rval L: the Cholesky decomposition of A
|
:rval L: the Cholesky decomposition of A
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,12 +17,9 @@ def linear_grid(D, n = 100, min_max = (-100, 100)):
|
||||||
"""
|
"""
|
||||||
Creates a D-dimensional grid of n linearly spaced points
|
Creates a D-dimensional grid of n linearly spaced points
|
||||||
|
|
||||||
Parameters:
|
:param D: dimension of the grid
|
||||||
|
:param n: number of points
|
||||||
D: dimension of the grid
|
:param min_max: (min, max) list
|
||||||
n: number of points
|
|
||||||
min_max: (min, max) list
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
@ -39,6 +36,7 @@ def kmm_init(X, m = 10):
|
||||||
|
|
||||||
:param X: data
|
:param X: data
|
||||||
:param m: number of inducing points
|
:param m: number of inducing points
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# compute the distances
|
# compute the distances
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,7 @@ class tree:
|
||||||
def rotation_matrix(xangle, yangle, zangle, order='zxy', degrees=False):
|
def rotation_matrix(xangle, yangle, zangle, order='zxy', degrees=False):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
Compute the rotation matrix for an angle in each direction.
|
Compute the rotation matrix for an angle in each direction.
|
||||||
This is a helper function for computing the rotation matrix for a given set of angles in a given order.
|
This is a helper function for computing the rotation matrix for a given set of angles in a given order.
|
||||||
|
|
||||||
|
|
@ -309,10 +310,8 @@ class acclaim_skeleton(skeleton):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Loads an ASF file into a skeleton structure.
|
Loads an ASF file into a skeleton structure.
|
||||||
loads skeleton structure from an acclaim skeleton file.
|
|
||||||
|
|
||||||
:param file_name: the file name to load in.
|
:param file_name: The file name to load in.
|
||||||
:rval skel: the skeleton for the file. - TODO isn't returning this?
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -502,11 +502,14 @@ def data_play(Y, visualizer, frame_rate=30):
|
||||||
|
|
||||||
This example loads in the CMU mocap database (http://mocap.cs.cmu.edu) subject number 35 motion number 01. It then plays it using the mocap_show visualize object.
|
This example loads in the CMU mocap database (http://mocap.cs.cmu.edu) subject number 35 motion number 01. It then plays it using the mocap_show visualize object.
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
data = GPy.util.datasets.cmu_mocap(subject='35', train_motions=['01'])
|
data = GPy.util.datasets.cmu_mocap(subject='35', train_motions=['01'])
|
||||||
Y = data['Y']
|
Y = data['Y']
|
||||||
Y[:, 0:3] = 0. # Make figure walk in place
|
Y[:, 0:3] = 0. # Make figure walk in place
|
||||||
visualize = GPy.util.visualize.skeleton_show(Y[0, :], data['skel'])
|
visualize = GPy.util.visualize.skeleton_show(Y[0, :], data['skel'])
|
||||||
GPy.util.visualize.data_play(Y, visualize)
|
GPy.util.visualize.data_play(Y, visualize)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,9 +53,11 @@ class TanhWarpingFunction(WarpingFunction):
|
||||||
self.num_parameters = 3 * self.n_terms
|
self.num_parameters = 3 * self.n_terms
|
||||||
|
|
||||||
def f(self,y,psi):
|
def f(self,y,psi):
|
||||||
"""transform y with f using parameter vector psi
|
"""
|
||||||
|
transform y with f using parameter vector psi
|
||||||
psi = [[a,b,c]]
|
psi = [[a,b,c]]
|
||||||
f = \sum_{terms} a * tanh(b*(y+c))
|
::math::`f = \\sum_{terms} a * tanh(b*(y+c))`
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
#1. check that number of params is consistent
|
#1. check that number of params is consistent
|
||||||
|
|
@ -77,8 +79,7 @@ class TanhWarpingFunction(WarpingFunction):
|
||||||
"""
|
"""
|
||||||
calculate the numerical inverse of f
|
calculate the numerical inverse of f
|
||||||
|
|
||||||
== input ==
|
:param iterations: number of N.R. iterations
|
||||||
iterations: number of N.R. iterations
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
@ -165,9 +166,11 @@ class TanhWarpingFunction_d(WarpingFunction):
|
||||||
self.num_parameters = 3 * self.n_terms + 1
|
self.num_parameters = 3 * self.n_terms + 1
|
||||||
|
|
||||||
def f(self,y,psi):
|
def f(self,y,psi):
|
||||||
"""transform y with f using parameter vector psi
|
"""
|
||||||
|
Transform y with f using parameter vector psi
|
||||||
psi = [[a,b,c]]
|
psi = [[a,b,c]]
|
||||||
f = \sum_{terms} a * tanh(b*(y+c))
|
|
||||||
|
:math:`f = \\sum_{terms} a * tanh(b*(y+c))`
|
||||||
"""
|
"""
|
||||||
|
|
||||||
#1. check that number of params is consistent
|
#1. check that number of params is consistent
|
||||||
|
|
@ -189,8 +192,7 @@ class TanhWarpingFunction_d(WarpingFunction):
|
||||||
"""
|
"""
|
||||||
calculate the numerical inverse of f
|
calculate the numerical inverse of f
|
||||||
|
|
||||||
== input ==
|
:param max_iterations: maximum number of N.R. iterations
|
||||||
iterations: number of N.R. iterations
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
@ -214,12 +216,13 @@ class TanhWarpingFunction_d(WarpingFunction):
|
||||||
def fgrad_y(self, y, psi, return_precalc = False):
|
def fgrad_y(self, y, psi, return_precalc = False):
|
||||||
"""
|
"""
|
||||||
gradient of f w.r.t to y ([N x 1])
|
gradient of f w.r.t to y ([N x 1])
|
||||||
returns: Nx1 vector of derivatives, unless return_precalc is true,
|
|
||||||
then it also returns the precomputed stuff
|
:returns: Nx1 vector of derivatives, unless return_precalc is true, then it also returns the precomputed stuff
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
mpsi = psi.copy()
|
mpsi = psi.coSpy()
|
||||||
d = psi[-1]
|
d = psi[-1]
|
||||||
mpsi = mpsi[:self.num_parameters-1].reshape(self.n_terms, 3)
|
mpsi = mpsi[:self.num_parameters-1].reshape(self.n_terms, 3)
|
||||||
|
|
||||||
|
|
@ -242,7 +245,7 @@ class TanhWarpingFunction_d(WarpingFunction):
|
||||||
"""
|
"""
|
||||||
gradient of f w.r.t to y and psi
|
gradient of f w.r.t to y and psi
|
||||||
|
|
||||||
returns: NxIx4 tensor of partial derivatives
|
:returns: NxIx4 tensor of partial derivatives
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue