338 questions
1
vote
1
answer
77
views
Why GenPareto from Scipy and Tensorflow-Probability show difference?
I'm trying to understand why the Generalized Pareto distribution shows different results for the same parameters. The results from SciPy make sense, while the results from TensorFlow Probability do ...
1
vote
0
answers
49
views
One-Step Ahead Forecasting with TensorFlow Structural Time Series
I have the following situation: I’m given a univariate time-series dataset y that I wish to model using feature variables X, which are provided alongside y. Naturally, my instinct is to split the data ...
0
votes
1
answer
61
views
Tensorflow Probability: Normal Distribution: log_prob Incompatible shapes
I am working on TF Probability tutorials and working on a 2D grid approximation for mu, sigma of Normal distribution. I am trying to understand to what level I should expect broadcasting to work for ...
0
votes
0
answers
134
views
RuntimeError: 'tuple' object has no attribute 'rank'—custom DenseVariational prior/posterior functions are returning a tuple instead of a tensor
I'm encountering a runtime error when building my Bayesian neural network using tfp.layers.DenseVariational layers on QuantConnect. The error occurs during model construction and states:
pgsql
Copy
...
2
votes
1
answer
63
views
Tensorflow Probability MixtureNormal layer example not working as in example
Tensorflow version is 2.17.1
Tensoflow probability version is 0.24.0
Example from the documentation https://www.tensorflow.org/probability/api_docs/python/tfp/layers/MixtureNormal?hl=en is the ...
1
vote
1
answer
46
views
Is CDF implemented in tensorflow_probability MultivariateNormalFullCovariance?
I am trying to calculate the CDF of a multivariate normal distribution. The documentation at https://www.tensorflow.org/probability/api_docs/python/tfp/distributions/MultivariateNormalFullCovariance ...
1
vote
4
answers
227
views
Model definition in Keras tutorial "Probabilistic Bayesian Neural Networks" leads to error "AttributeError: 'tuple' object has no attribute 'rank'"
I am trying to run the keras-tutorial Probabilistic Bayesian Neural Networks to get an understanding of Bayesian neural networks (BNN). The tutorial contains a google-colab notebook, so you can run it ...
0
votes
1
answer
32
views
Confusing output of tensorflow_probability.bijectors.ScaleMatvecDiag. Left or right multiplication?
The official page says, Compute Y = g(X; scale) = scale @ X.
So I understand scale is left-multiplied to X,
but I see that ScaleMatvecDiag calculates X @ scale.
The following code produces
import ...
0
votes
0
answers
326
views
AttributeError: 'tuple' object has no attribute 'rank' when using tensorflow_probability.layers.DenseVariational
I'm trying to use bayesian neural networks, adding a bayesian layer to a neural networks model. Here is the code I'm using and it's from the keras website.
import numpy as np
import tensorflow as tf
...
1
vote
1
answer
73
views
How do I train a model in Tensorflow that captures Joint Class Dependencies?
I've been doing some modeling of fantasy points for baseball players as a hobby. For a given team in a given game, there are nine (9) starting batters who bat in order.
I've trained each of their ...
1
vote
0
answers
122
views
How can I efficiently calculate the score function gradient estimator (REINFORCE algorithm)?
I wish to use the score function gradient estimator (also called the REINFORCE algorithm). Taking the notation and equations from the first link, this allows us to estimate gradients of the expected ...
1
vote
1
answer
152
views
Relu and sigmoid activation function with tfp.layers.DenseVariational Bayesian Neural Net
I am trying to set up a Bayesian Neural Network which is implemented with a statistical layer, tfp.layers.DenseVariational.
I was about to test various activation functions. From my data, tanh or relu ...
1
vote
0
answers
107
views
Interpretation of Tensorflow Probability tensor_coercible object
I have a tensorflow model (keras sequential) that ends with a Tensorflow Probability (TFP) mixture layer.
My goal is to fit this network with a custom loss function. The unexpected behaviour is the ...
0
votes
1
answer
183
views
Keras TensorFlow Probability model not learning distribution spread
I built and trained a Keras Tensorflow Probability model. It's basically a fully connected Neural Network model with a DistributionLambda on the output layer. Last Layer code example here:
tfp....
0
votes
1
answer
224
views
AttributeError: 'SymbolicTensor' object has no attribute 'log_prob' when exporting train signature with `IndependentNormal` layer
I want to export the training signature to train my model with the C++ API. However, I am not able to export the model, even after reading through
https://github.com/tensorflow/probability/issues/742,
...
1
vote
0
answers
47
views
Hierarchical Bayesian Unobserved Component Model
I'm pretty new to TFP, and probabilistic programming in general, so apologies in advance.
I'm wanting to know how to build a Hierarchical UCM in TFP state space.
The idea would be to do something like ...
0
votes
1
answer
201
views
Getting a Bayesian NN to learn the noise within training data and thereby calculating prediction uncertainties
I am trying to train a bayesian NN for noisy time series prediction. I have problems in
getting the model to learn the linear releationship in the data
getting the model to learn the increasing noise
...
0
votes
1
answer
396
views
difference between dense-layer types in tensor-flow probability
I study Bayesian Deep learning and for implement it, i found a library tensor-flow probability , for Dense layer in standard deep learning , there Dense-Variational ,Dense-reparameterize and Dense-...
0
votes
1
answer
78
views
target_log_prob_fn for JointDistributionNamed
I'm currently learning Bayesian approaches through the book "Rethinking" and would like to utilize TensorFlow Probability.
Specifically, I'm working on this chapter : https://colab.research....
0
votes
1
answer
503
views
AttributeError: module 'tensorflow_probability' has no attribute 'stats'
I have a Problem with tensorflow-probability, I want to calculate the variance of my tensor using
tfp.stats.variance(E)
But I am always getting the following error message:
AttributeError: module '...
1
vote
0
answers
193
views
Issues installing TensorFlow-probability on CentOS 7
I’m trying to install TensorFlow probability on a CentOS 7 machine. My Tensorflow (v 2.6) installation runs on virtual environment with Python 3.8. I have tried installing the package using pip3 ...
0
votes
0
answers
79
views
Tensorflow Probability CDF lower than it's PDF value
I've been testing Tensorflow Probability on some use cases and have some error. Working backwards, I found that, at least in the Normal distribution, you can see that while the PDF value for 0.9568... ...
0
votes
1
answer
50
views
TensorFlow Probability inference error input type
I train a model using tensorflow_probability and distributions.
To train it I format my data like this (2 heads model so 2 inputs set):
input_1 = tf.data.Dataset.from_tensor_slices(Xdata)
input_2 = tf....
0
votes
1
answer
58
views
fail to run a probalistic tensorflow model
I build a test of tensorflow lstm 2 heads and 2 ouputs model with oune of the output is probalilist. This odel work fine.
I do the same work but adding more layers, following the same procedure... but ...
0
votes
1
answer
73
views
tensorflow probabitily wrong output type
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,...
0
votes
1
answer
174
views
How can I change the dtype of a distribution in Tensorflow Probability?
Is there any possibility of changing the dtype of a tensorflow_probability.distribution, either on instantiation or with a respective setter()?
I want to use tf.float64 instead of the standard tf....
2
votes
1
answer
143
views
Passing tf.RaggedTensor to tfp.Distribution's methods in Python Tensorflow
Suppose I have a tensorflow-probability distribution
import tensorflow as tf
import tensorflow_probability as tfp
tfd = tfp.distributions
distr = tfd.Normal(loc=0, scale=1)
and I want to evaluate ...
0
votes
2
answers
397
views
How would I learn parameters of a beta distribution in TensorFlow Probability?
I'm trying to use TensorFlow Probability to learn the alpha and beta parameters of a beta distribution. I can't get it to work for some reason - the loss is all NaN values. Here's what I have:
from ...
1
vote
0
answers
296
views
Has anyone used LBFGS Optimizer in Tensorflow 2.0 ? How to use tfp.lbfgs_minimize inside a standard sequential training network?
I have been building a simple sequential network in Keras. So far I used Adam optimizer for fine-tuning the results. Now I need LBFGS Optimizer in the training to improve the loss.
It seems like the ...
0
votes
1
answer
118
views
Tensorflow distributions do not integrate/sum to 1
I was experimenting with tensorflow-probability (tfp). I wanted to check, if the density of a Normal-distribution in tfp does integrate (sum) to one. I thought the following calculation inside the ...
0
votes
2
answers
483
views
TensorFlow Probability (tfp) equivalent of np.quantile()
I am trying to find a TensorFlow equivalent of np.quantile(). I have found tfp.stats.quantiles() (tfp stands for TensorFlow Probability). However, its constructs are a bit different from that of np....
2
votes
1
answer
1k
views
Unable to import tensorflow_probability.substrates.jax
I am trying to import tensorflow_probability.substrates.jax (specifically to use the distributions) and getting the error shown below (it looks like a self-import). I have installed tensorflow (2.8.2),...
1
vote
0
answers
313
views
Implemented L-BFGS from TensorFlow Probability, But how to store loss values in every epoch
Implemented L-BFGS from TensorFlow Probability with Tf2 neural network model, referring to the method in this article https://pychao.com/2019/11/02/optimize-tensorflow-keras-models-with-l-bfgs-from-...
0
votes
2
answers
136
views
Deploy TensorFlow probability regression model as Sagemaker endpoint
I would like to develop a TensorFlow probability regression model locally and deploy as Sagemaker endpoint. I have deployed standard XGB models like this previously and understand that one can deploy ...
2
votes
1
answer
3k
views
conda/mamba can't solve tensorflow_probability and tensorflow dependencies
Problem
I am trying to create a conda environment and it seems that conda/mamba can't resolve tensorflow_probability dependencies with respect to tensorflow.
More context
I am trying to create a conda ...
0
votes
1
answer
145
views
validation loss goes up and down [variational inference]
i was training a mlp through variational inference for a regression task on a small dataset with 1 feature. The nn works and the training loss goes down but the validation loss has random spikes ...
0
votes
1
answer
130
views
Only Last TensorFlow Probability Layer Being Output (Multiple Times)
I'm building a TensorFlow Probability Bayesian network. In the example below, I've got a simple 2 distribution output, but both outputs are coming from the last distribution added to the network (...
1
vote
0
answers
77
views
Polynomial linear regression with Tensorflow probability
As an exercise, I'm trying to perform a simple polynomial linear regression in tensorflow probability. I'm getting consistent, but bad results.
It's a very simple problem, but somehow I can't see what'...
0
votes
0
answers
130
views
Type error in tensorflow probability binomial
I'm trying to run a model using tensorflow-probability on an Apple M1 (I've successfully run other tensorflow models on this computer, but I mention the architecture in case it's part of the issue). I ...
0
votes
1
answer
73
views
How to passa a Tensor Flow Distribution as parameter to another distribution?
I am new in Tensor Flow Probability.
I am trying to create an Overdispersion Poisson Distribution, that have as rate parameter a continuous Gamma random variable.
How I should create this ...
1
vote
0
answers
66
views
sampling within GradientTape
I am computing the different terms of the ELBO and its expectations to illustrate and get a better grasp of the reparametrization trick, as nicely explained here under undifferentiable expectations.
...
0
votes
2
answers
426
views
How to use values from previous Keras layer in convert_to_tensor_fn for TensorFlow Probability DistributionLambda
I have a Keras/TensorFlow Probability model where I would like to include values from the prior layer in the convert_to_tensor_fn parameter in the following DistributionLambda layer. Ideally, I wish ...
0
votes
1
answer
197
views
How to implement Multinomial conditional distributions depending on the conditional binary value in Tensorflow Probability?
I am trying to build a graphical model in Tensorflow Probability, where we first sample a number of positive (1) and negative (0) examples (count_i) from Categorical distribution and then construct ...
0
votes
1
answer
221
views
How to clone/duplicate a TensorFlow Probability neural network model
I have a TensorFlow Probability model that is built similar to models described in this YouTube Video.
I'm using
python==3.8.11
tensorflow==2.10.0
tensorflow-probability==0.18.0
Here's the code to ...
2
votes
1
answer
443
views
How to add a custom layer after a densevariational layer?
I have made a small bayesian neural network with few dense variational layers.
import numpy as np
from sklearn.model_selection import train_test_split
from tqdm.notebook import tqdm
import ...
0
votes
2
answers
830
views
Getting a probability distribution curve from a TensorFlow model
I am trying to learn working with TensorFlow and so I was trying to make a probablistic ML model to get the probability distribution of the next day stock price based on the last n days price sequence,...
0
votes
0
answers
147
views
Get component layer from MixtureSameFamily distribution layer - Tensorflow Probability
I'm making a Mixture Density Network model class in Tensorflow Probability that combines a fully connected left-hand side with a distribution layer right-hand. I want to instantiate the class with the ...
1
vote
1
answer
213
views
Tensorflow returning same outputs despite changing inputs for predicting a time series
I am trying to use tensorflow probability to predict the distribution of a time series in the future, improving my current model which is based on a classical time series model (GARCH). Essentially I ...
0
votes
1
answer
124
views
Numerical instabilities when bounding GPFlow hyperparameters
in Bounding hyperparameter optimization with Tensorflow bijector chain in GPflow 2.0, I found an excellent explanation of how to set boundaries to my hyperparameters.
Unfortunately, I noticed that ...
1
vote
0
answers
65
views
Tensorflow Keras bayesian model : model(X) is longer and lead to OOM while model.predict(X) is fine
I have a bayesian network that I call several times to predict value and estimate epistemic uncertainty.
I've seen here that it is better to use model(X) than model.predict(X) as first option is ...