-
Notifications
You must be signed in to change notification settings - Fork 87
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
Univariate user-defined functions with the multivariate signature #2534
Comments
This is needed for my work in lanl-ansi/MathOptAI.jl#90 |
An alternative would be to allow univariate functions to not support second-order derivatives. |
As a motivating example, we have this working: filename = joinpath(dir, "model_Tanh_vector_GrayBox.pt")
PythonCall.pyexec(
"""
import torch
model = torch.nn.Sequential(
torch.nn.Linear(3, 16),
torch.nn.Tanh(),
torch.nn.Linear(16, 2),
)
torch.save(model, filename)
""",
@__MODULE__,
(; filename = filename),
)
# Full-space
model = Model(Ipopt.Optimizer)
set_silent(model)
@variable(model, x[1:3])
ml_model = MathOptAI.PytorchModel(filename)
y = MathOptAI.add_predictor(model, ml_model, x; gray_box = true) where the PyTorch model is loaded as a user-defined function with automatic memoization for the vector-valued output and we use torch to compute the Jacobian via PythonCall. But...it doesn't work if the network has a scalar input. |
I realized that this is no longer trivial, because we've pushed the opt-in part of this into the solvers: So perhaps we just need a way for univariates to not supply second derivatives. |
See https://discourse.julialang.org/t/nested-optimization-matrix-multiplication-and-internal-functions/118098/10?u=odow
The text was updated successfully, but these errors were encountered: