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

Can Variable be converted to Tensor #2285

Open
fine4303 opened this issue Nov 7, 2023 · 3 comments
Open

Can Variable be converted to Tensor #2285

fine4303 opened this issue Nov 7, 2023 · 3 comments

Comments

@fine4303
Copy link

fine4303 commented Nov 7, 2023

Hello, I'm a newbie in Machine Learning.
I constructe a neural network using torch and I want Variable serve as neural network inputs.

my code:

model = nn.gen_nn()
model.load_state_dict(torch.load('NN.pt'), strict=True)

p = cvxpy.Variable(n)
V = model(p)
objective = cvxpy.Maximize(V)
constraints = []
prob = cvxpy.Problem(objective, constraints)

the issue is that Variable cannot convert to Tensor. Is my idea feasible?
Any help is great! thanks!

@Transurgeon
Copy link
Contributor

Unfortunately this isn't supported at the moment.
There is no Intermediate Representation between cvxpy and torch currently, but it is something that the developers are planning to add soon.

@fine4303
Copy link
Author

fine4303 commented Nov 8, 2023

Unfortunately this isn't supported at the moment. There is no Intermediate Representation between cvxpy and torch currently, but it is something that the developers are planning to add soon.

Thank you very much for your answer!
To the best of your knowledge, can you tell me what tools can solve the maximum/minimum value of a neural network?

@Transurgeon
Copy link
Contributor

I am not too familiar with Neural Networks, sorry about that.
I would look deeper into torch features, it is possible that something similar exists.
With some little searching I found that the cost-functions of neural networks are generally not convex (see here).
Maybe you could look into cvxpylayers?

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

No branches or pull requests

2 participants