Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add PositiveDefinite #89

Open
wants to merge 27 commits into
base: main
Choose a base branch
from

Conversation

nicholaskl97
Copy link

A PositiveDefinite container wraps an underlying model and results in a model that returns a postive number whenever the input is nonzero (or not equal to a different point specified when defining the container). This is useful, among other applications, in neural Lyapunov applications.

@avik-pal avik-pal force-pushed the positive-definite-container branch from 0445dd8 to ebf0efe Compare January 9, 2025 15:24
src/layers/containers.jl Outdated Show resolved Hide resolved
src/layers/containers.jl Outdated Show resolved Hide resolved
src/layers/embeddings.jl Outdated Show resolved Hide resolved
end
function PositiveDefinite(model; in_dims::Integer, ψ=Base.Fix1(sum, abs2),
r=Base.Fix1(sum, abs2) ∘ -)
return PositiveDefinite(model, () -> zeros(in_dims), ψ, r)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pass in zeros32?

() -> copy(x0)

Here you can pass a dummy function that takes in (rng, in_dims) and ignores them

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean something like the change I just made?

src/layers/containers.jl Outdated Show resolved Hide resolved
src/layers/containers.jl Outdated Show resolved Hide resolved
src/layers/Layers.jl Outdated Show resolved Hide resolved
…ims` on an empty array. Noted broken Tracker gradient test for `PositiveDefinite`
Copy link

codecov bot commented Jan 30, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.92%. Comparing base (29c21ff) to head (76e0fe2).

❗ There is a different number of reports uploaded between BASE (29c21ff) and HEAD (76e0fe2). Click for more details.

HEAD has 20 uploads less than BASE
Flag BASE (29c21ff) HEAD (76e0fe2)
30 10
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #89      +/-   ##
==========================================
- Coverage   88.38%   78.92%   -9.46%     
==========================================
  Files          24       23       -1     
  Lines         439      465      +26     
==========================================
- Hits          388      367      -21     
- Misses         51       98      +47     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nicholaskl97 nicholaskl97 marked this pull request as ready for review January 30, 2025 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants