-
Notifications
You must be signed in to change notification settings - Fork 0
enchantment: check projection dimensions #77
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
base: main
Are you sure you want to change the base?
Conversation
| end | ||
|
|
||
| try | ||
| projection_argument.logpdf!([0.0], randn(prj.dims)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I understand what you actually want to do. You want to take a sample from a representative of a distribution class and check if the logpdf! actually supports these samples. But why does it need to be implemented here, first? And second, it would simply never work - prj.dims does not support sampling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t think it’s very clean code to intentionally trigger an error. Instead, I’d suggest extending the projection_argument interface — for example, by introducing a method such as:
ExponentialFamilyProjection.check_dimensionality_compatibility(projection_argument, prj.dims)
This method could be optionally implemented by the user before applying the projection. By default, it might do nothing, but if the user wants dimensionality checks, they can override it. The documentation could encourage implementing this method when appropriate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this idea. I think maybe instead of just check_dimensionality_compatibility, we could check compatibility with the manifold argument—it's richer and allows us to do all sorts of checks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example, it can implement the check that @ofSingularMind wants. You can sample a random distribution d from M and sample a random sample from this d and do the check with logpdf! call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prj.dims is just a number, and randn(d) is just a vector. I'm not intending to sample anything - just insert the suggested size vector as input into the logpdf!() call to ensure these dimensions are supported. Can use zeros(prj.dims) etc.
For sure you guys can find a better way. I just feel like if adding this simple check erases three issues/discussions from popping up from users, maybe it is worth it. Anyways, my code works now ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot review this discussion and the suggested change, and the associated package / file and suggest a clean, simple, stable check
|
@ofSingularMind I've opened a new pull request, #78, to work on those changes. Once the pull request is ready, I'll request review from you. |
Addresses Issue #76