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

QuantumObjective function: Pass a symbol or function for Loss #17

Closed
andgoldschmidt opened this issue May 8, 2023 · 1 comment
Closed

Comments

@andgoldschmidt
Copy link
Member

Currently, the QuantumObjective function in objectives.jl takes a loss::Symbol which is called internally using eval(loss). This makes it hard for the user to define a local loss function, which might be a common task. Can the quantum objectives function take a loss function instead of symbol? In this alternative, the user passes an existing loss function fromlosses.jl instead of a symbol.

What are the tradeoffs here?

@aarontrowbridge
Copy link
Member

the reason for passing a symbol and not a function (currently) is to allow problems to be saved with the objective. julia does not allow saving of functions so the way around this was to make the argument a symbol that evals to a function defined in losses.jl that can be saved and used to reconstruct the objective during a load. modifying the code to include a user-defined loss function should be pretty straight forward -- basically we just need to define a new Objective constructor that accepts a function (or potentially a Loss <: AbstractLoss defined on line 61 of losses.jl; though this was primarily meant for quantum state (or unitary) losses though). saving and loading should be modified to handle this case. unfortunately tests don't yet exist for this part of the code.

@andgoldschmidt andgoldschmidt closed this as not planned Won't fix, can't repro, duplicate, stale Nov 8, 2023
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