Decoupling tensorflow from keras in stubs
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 5.1k
- Fork
- 2.1k
- Merge trung bình
- 1 ngày 19 giờ
- Pull request đã merge (30 ngày)
- 82
Mô tả
Whilst working on https://github.com/python/typeshed/pull/11696, I was having issues referencing the source code. After reading the doc and a bit of investigation, I realized why:
The runtime of https://github.com/python/typeshed/tree/main/stubs/tensorflow/tensorflow/keras actually are just references to the keras source code at https://github.com/keras-team/keras/tree/master/keras (import keras), and is generated / injected in import tensorflow.keras by https://github.com/keras-team/keras/blob/6454a4888a494c20ab0ea1dc6912cbcc13c5f940/pip_build.py#L62
Even tensorflow's own doc links back to karas source code https://www.tensorflow.org/api_docs/python/tf/keras/callbacks/Callback
>>> from keras import callbacks
2024-04-03 23:28:35.387416: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
2024-04-03 23:28:36.959410: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
>>> callbacks.__file__
'...\\typeshed\\.venv\\lib\\site-packages\\keras\\callbacks\\__init__.py'
>>> from tensorflow.keras import callbacks
>>> callbacks.__file__
'...\\typeshed\\.venv\\lib\\site-packages\\keras\\callbacks\\__init__.py'
In other words, keras "pollutes" the tensorflow namespace! I don't know if the type stubs specifications allow two distributions to write to the same stub-only package, which would allow us to perfectly reflect what's truly happening. Second best thing would be to have stubs for keras and keep tensorflow.keras in the tensorflow stubs (since tensorflow is dependent on keras anyway)
CC @hoel-bagard & @hmc-cs-mdrissi
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Đọc stubs/tensorflow/tensorflow/keras cùng với pip_build.py của Keras và các mã nguồn runtime được liên kết để hiểu cách tensorflow.keras được chèn vào. Xác nhận với các maintainer về cách sắp xếp stub package được hỗ trợ; được xem là hoàn thành khi layout đã chọn thể hiện chính xác cả keras và tensorflow.keras mà không có sự mơ hồ về namespace.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python, tensorflow
- Lĩnh vực
- devtools, machine-learning
- Loại issue
- Tái cấu trúc
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 30/100