-
Notifications
You must be signed in to change notification settings - Fork 7
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
Running the example on the README does not work. #118
Comments
Thanks for noticing it, I forgot to update that! And I should make sure to throw a clearer error... Fundamentally, the reason for that error is that an operator is expecting a keyword parameter called From the documentation of Keyword arguments are defined after the @operator
def my_operator(x: FourierSeries, *, dx: float, params=None):
... The argument The default value of the parameters is specified by the def params_initializer(x, *, dx):
return {"stencil": jnp.ones(x.shape) * dx}
@operator(init_params=params_initializer)
def my_operator(x, *, dx, params=None):
b = params["stencil"] / dx
y_params = jnp.convolve(x.params, b, mode="same")
return x.replace_params(y_params) The default value of For constant parameters, the @operator(init_params=constants({"a": 1, "b": 2.0}))
def my_operator(x, *, params):
return x + params["a"] + params["b"] For the readme example, the operator needs to be defined as @operator
def custom_op(u, *, params=None):
grad_u = jops.gradient(u)
diag_jacobian = jops.diag_jacobian(grad_u)
laplacian = jops.sum_over_dims(diag_jacobian)
sin_u = jops.compose(u)(jnp.sin)
return laplacian + sin_u I will change it in the README now 😄 |
updated the example in the readme with the correct parameter use, fixes #118
Should be fixed now, but please feel free to reopen if that's not the case |
Describe the bug
When I run the example given in the readme, it gives me the following error
SignatureError: The argument 'params' must be a keyword argument in . Example: def evaluate(x, *, params): ...
To Reproduce
Steps to reproduce the behavior:
Expected behavior
No error. Computing the gradient at the end.
Desktop (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: