kernGradient: Compute the gradient wrt the kernel parameters.

Description Usage Arguments Details Value See Also Examples

Description

Compute the gradient wrt the kernel parameters.

Usage

1
2
3
kernGradient(kern, x, ...)
## kernGradient(kern, x, partial)
## kernGradient(kern, x, x1, x2, partial_)

Arguments

kern

the kernel structure for which the gradients are being computed.

x

the input locations for which the gradients are being computed.

...

other arguments such as: 'partial', a matrix of partial derivatives of the function of interest with respect to the kernel matrix. The argument takes the form of a square matrix of dimension numData, where numData is the number of rows in X, 'x1', the input locations associated with the rows of the kernel matrix, 'x2', the input locations associated with the columns of the kernel matrix, 'partial_', matrix of partial derivatives of the function of interest with respect to the kernel matrix. The matrix should have the same number of rows as X1 and the same number of columns as X2 has rows.

Details

g <- kernGradient(kern, x, partial) g <- *kernGradient(kern, x, partial) computes the gradient of functions with respect to the kernel parameters. As well as the kernel structure and the input positions, the user provides a matrix PARTIAL which gives the partial derivatives of the function with respect to the relevant elements of the kernel matrix.

g <- kernGradient(kern, x1, x2, partial_) g <- *kernGradient(kern, x1, x2, partial_) computes the derivatives as above, but input locations are now provided in two matrices associated with rows and columns of the kernel matrix.

g <- *X*kernGradient(kern1, kern2, x, partial) g <- *X*kernGradient(kern1, kern2, x1, x2, partial_) same as above, but for cross combinations of two kernels, kern1 and kern2.

Value

g

gradients of the function of interest with respect to the kernel parameters. The ordering of the vector should match that provided by the function kernExtractParam.

See Also

kernCompute, kernExtractParam.

Examples

1
2
kern <- kernCreate(1, 'rbf')
g <- kernGradient(kern, as.matrix(c(1, 4)), array(1, c(2, 2)))

Example output

Loading required package: Matrix
Loading required package: fields
Loading required package: spam
Loading required package: dotCall64
Loading required package: grid
Spam version 2.2-2 (2019-03-07) is loaded.
Type 'help( Spam)' or 'demo( spam)' for a short introduction 
and overview of this package.
Help for individual functions is also obtained by adding the
suffix '.spam' to the function name, e.g. 'help( chol.spam)'.

Attaching package: 'spam'

The following object is masked from 'package:Matrix':

    det

The following objects are masked from 'package:base':

    backsolve, forwardsolve

Loading required package: maps
See https://github.com/NCAR/Fields for
 an extensive vignette, other supplements and source code 

gptk documentation built on May 2, 2019, 3:27 p.m.

Related to kernGradient in gptk...