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

Allow access to local variables in shape constraints #6

Open
jesnie opened this issue Apr 22, 2022 · 0 comments
Open

Allow access to local variables in shape constraints #6

jesnie opened this issue Apr 22, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@jesnie
Copy link
Member

jesnie commented Apr 22, 2022

Feature request

Allow access to local variables in shape constraints.

Motivation

For example, to be able to define that shapes of parameters must match class variables:

class MyModel:
    def __init__(self, ...):
        self.n_features = ...
        self.n_outputs = ...

    @check_shapes(
        "train_features: [n_rows, $self.n_features]",
        "train_labels: [n_rows, $self.n_outputs]",
    )
    def train(self, train_features, train_labels):
        ...

Proposal

Some way of being able to refer to local variables. We'd need to be able to distinguish local variables from the usual shapes variables. In the above example I've used $, but we could use some other syntax. Or maybe we can magically guess?

Maybe we can get inspiration for syntax from the popular einops library: https://github.com/arogozhnikov/einops

@jesnie jesnie added the enhancement New feature or request label Apr 22, 2022
@jesnie jesnie changed the title Allow access to local variables from check_shapes. Allow access to local variables in shape constraints Apr 22, 2022
@jesnie jesnie transferred this issue from GPflow/GPflow Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Todo
Development

No branches or pull requests

1 participant