0

UP DATE and ANSWER: My error was using tf.dataset to feed my model like y_hat=model(x_tst) using numpy array data give me the good type of output and work as supposed

I try to run tensorflow probality, but get stuck on output type problem. Followinfg this exemple at cell #3, with

y_hat=model(x_tst)

the y_hat type is: tensorflow_probability.python.layers.internal.distribution_tensor_coercible._TensorCoercible

my input are dataset type build like that (2 heads model)

input_1 = tf.data.Dataset.from_tensor_slices(X)
input_2 = tf.data.Dataset.from_tensor_slices(Xphysio)
output = tf.data.Dataset.from_tensor_slices(y)
combined_dataset = tf.data.Dataset.zip(((input_1, input_2), output))
input_dataset = combined_dataset.batch(32)

but if I use directly (like in exemple)

y_hat=model(x_tst)

instead of (who seem work well and produce results):

y_hat=model.predict(x_tst) 

I get this error

TypeError: Inputs to a layer should be tensors. Got: <BatchDataset element_spec=((TensorSpec(shape=(None, 120, 9), dtype=tf.float32, name=None), TensorSpec(shape=(None, 24), dtype=tf.float32, name=None)), TensorSpec(shape=(None,), dtype=tf.float32, name=None))>

If I use model.predict() the next step using tf probability don't work

1 Answer 1

0

Finaly find it, to use y_hat=model(x_tst) instead of model.predict and get the good type, I need to feed the model with numpy array in lieu of tf.dataset.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.