tensorflow / tensorflow/probability
In examples/models/bayesian_vgg.py How does one compute the loss of the model?
Open
@jburnim is already working on this.
Since May 9, 2019.
keras
layers
- Dominant language
- Jupyter Notebook
- Stars
- 4.4k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
Once defined as
x = tf.keras.layers.Flatten()(x)
x = tfp.layers.DenseFlipout(
num_classes,
kernel_posterior_fn=kernel_posterior_fn)(x)
model = tf.keras.Model(inputs=image, outputs=x, name='vgg16')
How do you compute the elbo Loss?
Does model.losses work?
which then would lead to this computation
labels_distribution = tfd.Categorical(logits=logits)
neg_log_likelihood = -tf.reduce_mean(input_tensor=labels_distribution.log_prob(abels))
kl = sum(model.losses) / mnist_data.train.num_examples
elbo_loss = neg_log_likelihood + kl
self._loss_op = elbo_loss
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.