# Questions tagged [tensorflow-probability]

17 questions

0

votes

0

answer

3

Views

### TypeError: Eager execution of tf.constant with unsupported shape

I'm trying to modify the code from 'Probabilistic_Layers_Regression.ipynb' for input_shape of 8 and output_shape of 8. I get the following error from the sample code below. Any ideas why? Thanks
----Error------
TypeError Traceback (most recent call last)
in ()
11 dtype=x.dtype)[..., np.newaxis]),
12...

1

votes

0

answer

13

Views

### tensorflow_probability: Gradients always zero when backpropagating the log_prob of a sample of a normal distribution

As part of a project I am having trouble with the gradients of a normal distribution with tensorflow_probability. For this I create a normal distribution of which a sample is drawn. The log_prob of this sample shall then be fed into an optimizer to update the weights of network.
If I get the log_pro...

1

votes

0

answer

98

Views

### Using Normal distribution instead of Bernoulli Distribution

I am new to Tensorflow and machine learning. I need to use the Normal distribution with variational autoencoder. I have searched for examples that are used Normal distribution with no luck.
Can anyone provide an example of a Normal distribution of output values in the neural network?
def make_decod...

1

votes

1

answer

73

Views

### Saving and restoring functions in TensorFlow

I am working on a VAE project in TensorFlow where the encoder/decoder networks are build in functions. The idea is to be able to save, then load the trained model and do sampling, using the encoder function.
After restoring the model, I am having trouble getting the decoder function to run and give...

1

votes

1

answer

172

Views

### Bayesian neural network in tensorflow-probability

I am new to tensorflow and I am trying to set up a bayesian neural network with dense flipout-layers. My code looks as follows:
from tensorflow.keras.models import Sequential
import tensorflow_probability as tfp
import tensorflow as tf
def train_BNN(training_data, training_labels, test_data, test_l...

1

votes

1

answer

47

Views

### How to correctly use tensorflow_probability to sampling from random variables' function?

I`m interested in the features of bijectors in tensorflow_probability, so I tried to sampling from a random variable function which is constructed by tfp.bijectors.
I just provide my test code blow, and here I privide some detials: the case I used to tested is the Chi_square distribution. I got the...

0

votes

0

answer

2

Views

### How do I translate this Edward code to TFP code?

I have coded a Probabilistic Matrix Factorization model in Edward. I am trying to port it over to TFP, but I am not sure how to define the log-likelihood and KL divergence terms. Here is the code in Edward -
# MODEL
U = Normal(
loc=0.0,
scale=1.0,
sample_shape=[n_latent_dims, batch_size])
V = Norma...

1

votes

1

answer

130

Views

### Specifying a DirichletMultinomial in tensorflow probability

This is probably quite basic, but I can't figure it out -- I have a 100x5 matrix y that is generated from a Dirichlet-Multinomial and I want to infer the parameters gamma using tensorflow probability. Below is the model I implemented (for simplicity I'm assuming that gamma is the same for all 5 clas...

1

votes

1

answer

0

Views

### Tensorflow mix two multivariate distribution

I would like to mix two multivariate distribution in tensorflow. For example:
import tensorflow_probability as tfp
import tensorflow as tf
import numpy as np
tfd = tfp.distributions
#mean,var,pi have the same shape(3,4).
mean = tf.convert_to_tensor(np.arange(12.0).reshape(3,4))
var = mean
dist = tfd...

1

votes

0

answer

28

Views

### How to implement Gaussian Mixture for VAE?

I feel like I don't really know what I'm doing so I will describe what I think I'm doing and what I want to do and where that fails.
Given a normal variational autoencoder:
...
net = tf.layers.dense(net, units=code_size * 2, activation=None)
mean = net[:, :code_size]
std = net[:, code_size:]
posteri...

1

votes

1

answer

22

Views

### Tensorflow Probability returns unstable Predictions

I'm using a Tensorflow Probability model. Of course is a probabilistic outcome, and the derivative of error does not go to zero (otherwise the model would be deterministic). The prediction is not stable, because we have a range in the derivative of loss, let's say, in a convex optimization, from 1.2...

2

votes

0

answer

17

Views

### InvalidArgumentError in tensorflow probability

I am following the tutorial: https://medium.com/tensorflow/regression-with-probabilistic-layers-in-tensorflow-probability-e46ff5d37baf
But am getting the following error:
InvalidArgumentError: data[0].shape = [2] does not start with indices[0].shape = [3]
[[{{node training/Adam/gradients/loss/output...

1

votes

1

answer

250

Views

### tensorflow distribution create probability greater than 1

I am using tensorflow distribution API for sampling, following is the sample code I am using, but I found the probability is greater than 1, then log probability is smaller than 0. I have tried both CPU and GPU, both produce this weird result. the tensorflow is 1.3.
from __future__ import absolute_i...

0

votes

0

answer

4

Views

### Tensorflow: Sampling a tensor according to another tensor?

I have a tensor T of shape Batch_Size x Num_Items x Item_Dimension and another tensor P of shape Batch_Size x Num_Items, where the Num_Items values in each batch of P sum to 1 (a probability distribution of items for each batch). I want to sample without replacement N items from T according to proba...

3

votes

0

answer

145

Views

### How to obtain prediction results in edward

Thank you for this community. I am a beginner and I have a very dumb question on using Edward. I am using a tutorial regression model. Everything is perfect. I was wondering how to obtain the prediction on testing set. for example, assuming
y = Normal(loc=neural_network(X), scale=0.1 * tf.ones(M), n...

6

votes

1

answer

545

Views

### the -ELBO loss of variational inference implemented in Tensorflow Probability Bayesian neural network

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 to the summation of two terms, namely 'neg_log_likelihood' and 'kl' implemented in the code....

1

votes

1

answer

0

Views

### Question on Using SoftmaxCentered Bijector

I am playing with SofmaxCenter bijector in tensorflow_probability and get some errors. Since the document for it is at the infancy state, I was not able to figure out what is wrong. I hope you can help me out.
Basically, given that X is a log-normal random vector of three components, I would like to...