Questions tagged [tensorflow-probability]

For questions about TensorFlow Probability (a library for probabilistic reasoning and statistical analysis in TensorFlow), TF probability distributions (everything in `tf.distributions` and `tf.contrib.distributions`), use of Edward2 in Tensorflow and general probability related issues with Tensorflow.

TensorFlow Probability is a library for probabilistic reasoning and statistical analysis in TensorFlow. As part of the TensorFlow ecosystem, TensorFlow Probability provides integration of probabilistic methods with deep networks, gradient-based inference via automatic differentiation, and scalability to large datasets and models via hardware acceleration (e.g., GPUs) and distributed computation.

335 questions
18
votes
1 answer

TypeError: An op outside of the function building code is being passed a Graph tensor

I am getting the following exception TypeError: An op outside of the function building code is being passed a "Graph" tensor. It is possible to have Graph tensors leak out of the function building context by including a tf.init_scope in your…
nbro
  • 15,395
  • 32
  • 113
  • 196
13
votes
3 answers

No module named 'tensorflow_probability'

I need to use Tensorflow and Tensorflow_Probability. After installing it by these commands: conda install tensorflow-probability or pip install --upgrade tensorflow-probability , I ran it in the notebook: import tensorflow_probability as tfp but it…
Ham82
  • 665
  • 1
  • 4
  • 16
11
votes
1 answer

NumPyro vs Pyro: Why is former 100x faster and when should I use the latter?

From Pytorch-Pyro's website: We’re excited to announce the release of NumPyro, a NumPy-backed Pyro using JAX for automatic differentiation and JIT compilation, with over 100x speedup for HMC and NUTS! My questions: Where is the performance gain…
11
votes
1 answer

What does the property losses of the Bayesian layers of TensorFlow Probability represent?

I am running the example code on Bayesian Neural Network implemented using Tensorflow Probability. My question is about the implementation of the ELBO loss used for variational inference. The ELBO equals the summation of two terms, namely…
rort1989
  • 263
  • 2
  • 9
7
votes
1 answer

Generating random integers in TensorFlow

I would like to generate random integers in TensorFlow but I don't which command I should use. In particular, I would like to generate from a uniform random variable which takes values in {1, 2, 3, 4}. I have tried to look among the distributions…
Maurizio Serra
  • 113
  • 1
  • 1
  • 6
6
votes
0 answers

Non-linear optimization with Tensorflow-probability

I'm trying to implement a Gaussian fitting using TensorFlow-probability's Nelder-Mead optimizer: tfp.optimizer.nelder_mead_minimize(). It does not converge, while scipy.optimizer.minimize() provide good result in less than 1 second of computation…
Anais
  • 69
  • 4
6
votes
1 answer

Variable tf.Variable has 'None' for gradient in TensorFlow Probability

I'm having trouble constructing a basic BNN in TFP. I'm new to TFP and BNNs in general, so I apologize if I've missed something simple. I can train a basic NN in Tensorflow by doing the following: model = keras.Sequential([ …
mackdelany
  • 198
  • 1
  • 7
5
votes
2 answers

TensorFlow Probability - want NN to output multiple distributions

I have a simple model that currently outputs a single numerical value which I've adapted to instead output a distribution using TFP (mean + std deviation) so I can instead understand the model's confidence around the prediction. model =…
Deftness
  • 265
  • 1
  • 4
  • 21
5
votes
0 answers

How to incorporate many features into a TensorFlow Probability Structural Time Series

I'm wondering how to train a Multivariate Bayesian Structural Time Series (BSTS) model that automatically performs feature selection on hundreds of input time series using Tensorflow Probability. The TF-Probability BSTS blog post shows how to…
5
votes
2 answers

Saving and loading Tensorflow probability layers inside Keras sequential module

I am using Tensorflow probability layers inside Keras sequentials. However, saving the model as json and then loading it throws and exception. I am using custom_objects to be able to load custom layers. Here is the minimalistic code to reproduce…
Hamed
  • 474
  • 5
  • 17
5
votes
2 answers

Is there a way to call a Numpy function inside a TensorFlow session?

I am trying to implement a Expectation Maximization algorithm using TensorFlow and TensorFlow Probability. It worked very well until I tried to implement Missing Data (data can contain NaN values in some random dimensions). The problem is that with…
igonro
  • 174
  • 1
  • 13
4
votes
0 answers

TypeError: Cannot interpret '' as a data type

Very simple question. I am using tensorflow probability package to use a bijector to form a trainable_distribution from a simple distribution (let's say gaussian) Everything works properly in jupyter notebook but as I bring it to terminal (where I…
4
votes
0 answers

How to fix "WARNING:tensorflow:@custom_gradient grad_fn has 'variables' in signature, but no ResourceVariables were used on the forward pass"?

I have been getting this warning when using model.fit() or even model.summary(). Using (on Windows 10): Tensorflow 2.6.2 Tensorflow Probability 0.14 Keras 2.6 Also tested on Google Colab with tf==2.8, tfp==0.16, keras==2.8, without any…
4
votes
3 answers

How to save a model with DenseVariational layer?

I'm trying to build a model with DenseVariational layer so that it can report epistemic uncertainties. Something like https://www.tensorflow.org/probability/examples/Probabilistic_Layers_Regression#figure_3_epistemic_uncertainty The model training…
4
votes
1 answer

Getting AttributeError: 'Tensor' object has no attribute 'log_prob' while saving a tensorflow model

I am trying to save a variational autoencoder built using TensorFlow and Tensorflow probability. My goal is to serve the model using TensorFlow serving. I am open to serving the model in other fashion. Here is my model: def…
1
2 3
22 23