Repository navigation
fix: make SqrtInit work with Keras 2 and 3 - #40
Open
kudala-bharani wants to merge 2 commits into
Open
kudala-bharani wants to merge 2 commits into
kudala-bharani wants to merge 2 commits into
Conversation
Owner
|
Thanks for the fix @kudala-bharani . Could you drop the Changelog for now? I don't intend maintaining a changelog for the time being. After that it's good to go form my side. |
Author
|
Dropped the changelog. Both Keras test suites still pass. Thanks for reviewing! |
mikeng07
pushed a commit
to mikeng07/ai301-coursework
that referenced
this pull request
Nov 2, 2026
Built pr-monitor + playbook.md this week. Its first real run on PR #43 found JesperDramsch/keras-complex#40 -- another contributor's PR for the same bug, opened before my claim and already maintainer-approved. Traced this to a real gap in issue-scout's unit-6 "Nobody is already on it" grading (never queried linked PRs, only assignees/comments). Disclosed the overlap on PR #43 and closed it rather than leave two PRs competing for an already-decided outcome. Filled in Learnings and Reflections, Implementation Notes, and the unit-8 Toolkit entry. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SqrtInitpasses the Python integer2to the Keras backend'ssqrt, which expects a tensor and raises before the initializer can return anything. Compute the scalar with NumPy instead, keeping the requested shape and dtype inK.constant.The tests cover scalar/vector/matrix shapes, the default dtype and float16/32/64,
tf.function, and use as a Dense layer initializer. The README no longer listsSqrtInitas broken. The separatecomplexnn.bn.sqrt_initfunction is unchanged.Fixes #37.
Testing
Confirmed the new tests fail on the original code with
AttributeError: 'int' object has no attribute 'dtype'.On Python 3.11.15 with TensorFlow 2.21.0:
pytest -q— 84 passed, 1 xfailed, 416 subtests passed.TF_USE_LEGACY_KERAS=1 pytest -q— 83 passed, 2 skipped, 416 subtests passed.ruff check .andruff format --check --diff .— passed with the repository's pinned Ruff 0.17.0.pre-commit run --all-files— all six checks passed.uv build— wheel and source distribution built successfully (existing setuptools license-metadata deprecation warnings).No dependency changes.