PixelCNN example from the documentation does not work

オープン
#2,013 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
jupyter-notebook, python, tensorflow

調査の方向性

TensorFlow Probability API ドキュメントの URL にある PixelCNN の例から始め、TensorFlow 2.19 を使って Google Colab で再現してください。dist.log_prob(image_input) で発生する失敗を調査し、報告された KerasTensor 例外を追跡してください。完了の条件は、ドキュメントの例がこの例外なしに正常に実行されることです。

索引モデルが issue の本文から書いたものです。

説明

How to repro?

TF version: 2.19.0

  1. Take an example from https://www.tensorflow.org/probability/api_docs/python/tfp/distributions/PixelCNN#examples
  2. Create Google Colab
  3. Past the example into the Google Colab
  4. 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)
    ```
主要言語
Jupyter Notebook
スター
4.4k
フォーク
1.1k
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

tensorflow/probability のほかの issue

tensorflow/probability の issue をすべて見る

似ている issue

Documentation の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。