MCPcopy
hub / github.com/GPflow/GPflow / ArcCosine

Class ArcCosine

gpflow/kernels/misc.py:27–200  ·  view source on GitHub ↗

The Arc-cosine family of kernels which mimics the computation in neural networks. The order parameter specifies the assumed activation function. The Multi Layer Perceptron (MLP) kernel is closely related to the ArcCosine kernel of order 0. The key reference is :cite:t:`NIPS2009

Source from the content-addressed store, hash-verified

25
26
27class ArcCosine(Kernel):
28 """
29 The Arc-cosine family of kernels which mimics the computation in neural
30 networks. The order parameter specifies the assumed activation function.
31 The Multi Layer Perceptron (MLP) kernel is closely related to the ArcCosine
32 kernel of order 0.
33
34 The key reference is :cite:t:`NIPS2009_3628`.
35 """
36
37 implemented_orders = {0, 1, 2}
38
39 @check_shapes(
40 "variance: []",
41 "weight_variances: [broadcast n_active_dims]",
42 "bias_variance: []",
43 )
44 def __init__(
45 self,
46 order: int = 0,
47 variance: TensorType = 1.0,
48 weight_variances: TensorType = 1.0,
49 bias_variance: TensorType = 1.0,
50 *,
51 active_dims: Optional[ActiveDims] = None,
52 name: Optional[str] = None,
53 ) -> None:
54 """
55 :param order: specifies the activation function of the neural network
56 the function is a rectified monomial of the chosen order
57 :param variance: the (initial) value for the variance parameter
58 :param weight_variances: the (initial) value for the weight_variances parameter,
59 to induce ARD behaviour this must be initialised as an array the same
60 length as the the number of active dimensions e.g. [1., 1., 1.]
61 :param bias_variance: the (initial) value for the bias_variance parameter
62 defaults to 1.0
63 :param active_dims: a slice or list specifying which columns of X are used
64 """
65 super().__init__(active_dims=active_dims, name=name)
66
67 if order not in self.implemented_orders:
68 raise ValueError("Requested kernel order is not implemented.")
69 self.order = order
70
71 self.variance = Parameter(variance, transform=positive())
72 self.bias_variance = Parameter(bias_variance, transform=positive())
73 self.weight_variances = Parameter(weight_variances, transform=positive())
74 self._validate_ard_active_dims(self.weight_variances)
75
76 @property
77 def ard(self) -> bool:
78 """
79 Whether ARD behaviour is active.
80 """
81 ndims: int = self.weight_variances.shape.ndims
82 return ndims > 0
83
84 @check_shapes(

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…