tensorflow / tensorflow/probability

Crash when manually calling DenseReparameterization.build()

Open
#113 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

layers
Dominant language
Jupyter Notebook
Stars
4.4k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

When first applying the layer inside a symbolic loop, I have to manually call build before the loop. However, this fails for two reasons right now. First, the input shape is expected to be 2D but should only be 1D. Second, the data type of the layer is not yet set. See dense_variational.py#L146.

Example:

layer = tfp.layers.DenseReparameterization(20, tf.tanh)
layer.build((10,))
# ValueError: Shape (10,) must have rank at least 2

layer = tfp.layers.DenseReparameterization(20, tf.tanh)
layer.build((9999, 10))
# TypeError: Cannot convert value None to a TensorFlow DType.

layer = tfp.layers.DenseReparameterization(20, tf.tanh)
layer._dtype = tf.float32
layer.build((9999, 10))
# Works!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at tensorflow_probability/python/layers/dense_variational.py#L146 and reproduce the three DenseReparameterization.build() examples from the issue. Trace the input-shape and dtype handling during build; done means a one-dimensional input shape builds successfully without manually assigning the layer dtype, while preserving the existing valid behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, tensorflow
Domain
machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.