23
23
https://people.eecs.berkeley.edu/~brecht/papers/07.rah.rec.nips.pdf
24
24
"""
25
25
import math
26
+ from edward2 .tensorflow import initializers
27
+
26
28
import tensorflow .compat .v2 as tf
27
29
30
+
28
31
_SUPPORTED_LIKELIHOOD = ('binary_logistic' , 'poisson' , 'gaussian' )
29
32
30
33
@@ -66,7 +69,7 @@ def __init__(self,
66
69
gp_cov_ridge_penalty = 1e-6 ,
67
70
scale_random_features = True ,
68
71
return_random_features = False ,
69
- use_custom_random_features = False ,
72
+ use_custom_random_features = True ,
70
73
custom_random_features_initializer = None ,
71
74
custom_random_features_activation = None ,
72
75
l2_regularization = 0. ,
@@ -121,7 +124,7 @@ def __init__(self,
121
124
122
125
self .normalize_input = normalize_input
123
126
self .gp_input_scale = 1. / tf .sqrt (gp_kernel_scale )
124
- self .gp_feature_scale = 2. / tf . sqrt ( float (num_inducing ))
127
+ self .gp_feature_scale = tf . sqrt ( 2. / float (num_inducing ))
125
128
126
129
self .scale_random_features = scale_random_features
127
130
self .return_random_features = return_random_features
@@ -144,12 +147,12 @@ def __init__(self,
144
147
self .gp_cov_likelihood = gp_cov_likelihood
145
148
146
149
if self .use_custom_random_features :
147
- # Use classic Random Fourier Feature by default.
150
+ # Use orthogonal random features by default.
148
151
self .random_features_bias_initializer = tf .random_uniform_initializer (
149
152
minval = 0. , maxval = 2. * math .pi )
150
153
if self .custom_random_features_initializer is None :
151
- self .custom_random_features_initializer = tf . initializers . random_normal (
152
- stddev = 1. )
154
+ self .custom_random_features_initializer = (
155
+ initializers . OrthogonalRandomFeatures ( stddev = 1.0 ) )
153
156
if self .custom_random_features_activation is None :
154
157
self .custom_random_features_activation = tf .math .cos
155
158
@@ -289,7 +292,7 @@ def build(self, input_shape):
289
292
if isinstance (gp_feature_dim , tf .compat .v1 .Dimension ):
290
293
gp_feature_dim = gp_feature_dim .value
291
294
292
- # Posterior precision matrix for the GP' random feature coefficients.
295
+ # Posterior precision matrix for the GP's random feature coefficients.
293
296
self .initial_precision_matrix = (
294
297
self .ridge_penalty * tf .eye (gp_feature_dim , dtype = self .dtype ))
295
298
0 commit comments