PixelCNN example from the documentation does not work

Đang mở
#2,013 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
jupyter-notebook, python, tensorflow

Hướng nghiên cứu

Bắt đầu với ví dụ PixelCNN tại URL tài liệu API TensorFlow Probability và tái hiện ví dụ đó trong Google Colab với TensorFlow 2.19. Kiểm tra lỗi tại dist.log_prob(image_input) và lần theo ngoại lệ KerasTensor được báo cáo. Công việc được coi là hoàn tất khi ví dụ được tài liệu hóa chạy thành công mà không có ngoại lệ này.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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)
    ```
Ngôn ngữ chính
Jupyter Notebook
Star
4.4k
Fork
1.1k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của tensorflow/probability

Tất cả issue của tensorflow/probability

Issue tương tự

Thêm issue về Documentation

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.