UCL-SML / Doubly-Stochastic-DGP

Deep Gaussian Processes with Doubly Stochastic Variational Inference
Apache License 2.0
142 stars 48 forks source link

MNIST demo, make_dgp ValueError: #36

Open Mirgahney opened 5 years ago

Mirgahney commented 5 years ago

Hello Hugh,

I have encountered the following error when I'm running MNIST_demo notebook, more specifically one running.

m_sgp = SVGP(X, Y, RBF(784, lengthscales=2., variance=2.), MultiClass(10), 
             Z=Z, num_latent=10, minibatch_size=1000, whiten=True)

def make_dgp(L):
    kernels = [RBF(784, lengthscales=2., variance=2.)]
    for l in range(L-1):
        kernels.append(RBF(30, lengthscales=2., variance=2.))
    model = DGP(X, Y, Z, kernels, MultiClass(10), 
                minibatch_size=1000,
                num_outputs=10)

    # start things deterministic 
    for layer in model.layers[:-1]:
        layer.q_sqrt = layer.q_sqrt.value * 1e-5 

    return model

-->m_dgp2 = make_dgp(2)
m_dgp3 = make_dgp(3)

The error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-3-1d4261b29a37> in <module>()
     16     return model
     17 
---> 18 m_dgp2 = make_dgp(2)
     19 m_dgp3 = make_dgp(3)

<ipython-input-3-1d4261b29a37> in make_dgp(L)
      8     model = DGP(X, Y, Z, kernels, MultiClass(10), 
      9                 minibatch_size=1000,
---> 10                 num_outputs=10)
     11 
     12     # start things deterministic

\Anaconda3\lib\site-packages\gpflow\core\compilable.py in __init__(self, *args, **kwargs)
     84                     break
     85                 frame = frame.f_back
---> 86             origin_init(self, *args, **kwargs)
     87             autobuild_on = __execute_autobuild__ == AutoBuildStatus.BUILD
     88             global_autobuild_on = AutoBuildStatus.__autobuild_enabled_global__

\Anaconda3\lib\site-packages\doubly_stochastic_dgp-1.0-py3.6.egg\doubly_stochastic_dgp\dgp.py in __init__(self, X, Y, Z, kernels, likelihood, num_outputs, mean_function, white, **kwargs)
    189                                     num_outputs=num_outputs,
    190                                     mean_function=mean_function,
--> 191                                     white=white)
    192         DGP_Base.__init__(self, X, Y, likelihood, layers, **kwargs)
    193 

\Anaconda3\lib\site-packages\doubly_stochastic_dgp-1.0-py3.6.egg\doubly_stochastic_dgp\layer_initializations.py in init_layers_linear(X, Y, Z, kernels, num_outputs, mean_function, Layer, white)
     42             mf.set_trainable(False)
     43 
---> 44         layers.append(Layer(kern_in, Z_running, dim_out, mf, white=white))
     45 
     46         if dim_in != dim_out:

\Anaconda3\lib\site-packages\gpflow\core\compilable.py in __init__(self, *args, **kwargs)
     84                     break
     85                 frame = frame.f_back
---> 86             origin_init(self, *args, **kwargs)
     87             autobuild_on = __execute_autobuild__ == AutoBuildStatus.BUILD
     88             global_autobuild_on = AutoBuildStatus.__autobuild_enabled_global__

\Anaconda3\lib\site-packages\doubly_stochastic_dgp-1.0-py3.6.egg\doubly_stochastic_dgp\layers.py in __init__(self, kern, num_outputs, mean_function, Z, feature, white, input_prop_dim, q_mu, q_sqrt, **kwargs)
    149         Layer.__init__(self, input_prop_dim, **kwargs)
    150         if feature is None:
--> 151             feature = InducingPoints(Z)
    152 
    153         self.num_inducing = len(feature)

\Anaconda3\lib\site-packages\gpflow\core\compilable.py in __init__(self, *args, **kwargs)
     84                     break
     85                 frame = frame.f_back
---> 86             origin_init(self, *args, **kwargs)
     87             autobuild_on = __execute_autobuild__ == AutoBuildStatus.BUILD
     88             global_autobuild_on = AutoBuildStatus.__autobuild_enabled_global__

\Anaconda3\lib\site-packages\gpflow\core\compilable.py in __init__(self, *args, **kwargs)
     84                     break
     85                 frame = frame.f_back
---> 86             origin_init(self, *args, **kwargs)
     87             autobuild_on = __execute_autobuild__ == AutoBuildStatus.BUILD
     88             global_autobuild_on = AutoBuildStatus.__autobuild_enabled_global__

\Anaconda3\lib\site-packages\gpflow\features.py in __init__(self, Z)
     76         """
     77         super().__init__()
---> 78         self.Z = Parameter(Z, dtype=settings.float_type)
     79 
     80     def __len__(self):

\Anaconda3\lib\site-packages\gpflow\core\compilable.py in __init__(self, *args, **kwargs)
     84                     break
     85                 frame = frame.f_back
---> 86             origin_init(self, *args, **kwargs)
     87             autobuild_on = __execute_autobuild__ == AutoBuildStatus.BUILD
     88             global_autobuild_on = AutoBuildStatus.__autobuild_enabled_global__

\Anaconda3\lib\site-packages\gpflow\params\parameter.py in __init__(self, value, transform, prior, trainable, dtype, fix_shape, name)
    136         self._externally_defined = False
    137         self._fixed_shape = fix_shape
--> 138         value = self._valid_input(value, dtype=dtype)
    139 
    140         super().__init__(name)

\Anaconda3\lib\site-packages\gpflow\params\parameter.py in _valid_input(self, value, dtype)
    312         if not misc.is_valid_param_value(value):
    313             msg = 'The value must be either a tensorflow variable, an array or a scalar.'
--> 314             raise ValueError(msg)
    315         cast = not (dtype is None)
    316         is_built = False

ValueError: The value must be either a tensorflow variable, an array or a scalar.
hughsalimbeni commented 5 years ago

Thanks for noticing this. I think it is a compatibility issue with gpflow1.1, but I need to investigate. Do you get this error with gpflow1.0?