Closed gerardcelio closed 4 years ago
Hi! Sorry for the late reply. From that error message I'd guess that your test data (xx_test
) has a float64
datatype, but probflow's default datatype is float32
(and so all the weight and bias parameters were float32
tensors), so TensorFlow threw a hissy fit when it tried to do an operation with two tensors of different datatypes.
Assuming your xx_test
is a numpy array, this should work:
lb, ub = model.predictive_interval(xx_test.astype('float32'), ci=0.95)
Alternatively you could change the default datatype used by probflow to be float64
(though I figure variational inference is already super noisy as it is, so do we really need all that extra precision? Thus the choice of a default datatype of float32. I.e. I'd gently discourange this 2nd option both because it's more complicated and because it's probably wicked overkill haha):
# x_train, y_train, and x_test are all float64
# Set the default datatype used by probflow
# note that this must be done before initializing and fitting the model
pf.set_datatype(tf.dtypes.float64)
model = DenseRegression([1, 32, 32, 1])
model.fit(x_train, y_train)
lb, ub = model.predictive_interval(x_test, ci=0.95)
And sorry, I definitely should have included a discussion of datatypes and how to set the default datatype in the user guide, but I hadn't gotten around to it 😬 I've added it here!
Hope that helps!
Works like a charm, thanks!
I am following the tutorial on DenseRegression (using the same versions of packages) but using my own data, when I try to do model.predictive_interval(x_test, ci=0.95), it outputs the following error:
InvalidArgumentError Traceback (most recent call last)