PixelCNN example from the documentation does not work
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- jupyter-notebook, python, tensorflow
- Domain
- documentation, machine-learning
Research direction
Start with the PixelCNN example at the TensorFlow Probability API documentation URL and reproduce it in Google Colab with TensorFlow 2.19. Inspect the failure at dist.log_prob(image_input) and trace the reported KerasTensor exception. Done means the documented example runs successfully without this exception.
Written by the indexing model from the issue text.
Description
How to repro?
TF version: 2.19.0
- Take an example from https://www.tensorflow.org/probability/api_docs/python/tfp/distributions/PixelCNN#examples
- Create Google Colab
- Past the example into the Google Colab
- Run it
The following exception occurs:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
[/tmp/ipython-input-624558695.py](https://localhost:8080/#) in <cell line: 0>()
33
34 # Define the log likelihood for the loss fn
---> 35 log_prob = dist.log_prob(image_input)
36
37 # Define the model
6 frames
<decorator-gen-128> in shape_v2(input, out_type, name)
[/usr/local/lib/python3.12/dist-packages/keras/src/backend/common/keras_tensor.py](https://localhost:8080/#) in __tf_tensor__(self, dtype, name)
154
155 def __tf_tensor__(self, dtype=None, name=None):
--> 156 raise ValueError(
157 "A KerasTensor cannot be used as input to a TensorFlow function. "
158 "A KerasTensor is a symbolic placeholder for a shape and dtype, "
ValueError: A KerasTensor cannot be used as input to a TensorFlow function. A KerasTensor is a symbolic placeholder for a shape and dtype, used when constructing Keras Functional models or Keras Functions. You can only use it as input to a Keras layer or a Keras operation (from the namespaces `keras.layers` and `keras.ops`). You are likely doing something like:
```
x = Input(...)
...
tf_fn(x) # Invalid.
```
What you should do instead is wrap `tf_fn` in a layer:
```
class MyLayer(Layer):
def call(self, x):
return tf_fn(x)
x = MyLayer()(x)
```
- Dominant language
- Jupyter Notebook
- Stars
- 4.4k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing 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.
More from tensorflow/probability
-
KL divergence between two `TransformedDistribution`s with a shared non-injective bijector (`AbsoluteValue`) returns the base KLPossibly taken @Andreas-Hum claimed this 10 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
tensorflow/probability#2036 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 54/100
tensorflow/probability#2040 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
tensorflow/probability#2034 ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
tensorflow/probability#2021 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
tensorflow/probability#2015 ·
All issues in tensorflow/probability
Similar issues
-
release
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
MichaelYcJo/SpecSeal#1535 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
paperclipai/paperclip#20942 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
cadence-workflow/cadence-ai-samples#174 ·
Maintainers usually reply within 1 day
-
docs
Difficulty 1/5 1-3 hours Newbie friendliness 69/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 63/100