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 26 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
Copy link

codecov bot commented Jan 30, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.40%. Comparing base (cf46767) to head (a5207d2).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #89      +/-   ##
==========================================
- Coverage   88.38%   84.40%   -3.99%     
==========================================
  Files          24       25       +1     
  Lines         439      468      +29     
==========================================
+ Hits          388      395       +7     
- Misses         51       73      +22     

☔ 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
@nicholaskl97
Copy link
Author

@avik-pal What's standing in the way of merging this in? All tests are passing (except Tracker is broken, see above). I'd like to be able to make use of these features in my library once available.

@avik-pal avik-pal force-pushed the positive-definite-container branch from 76e0fe2 to a5207d2 Compare February 6, 2025 21:23
@avik-pal
Copy link
Member

avik-pal commented Feb 6, 2025

tests are failing with the latest package versions

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