Closed andgoldschmidt closed 10 months ago
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.
Currently, the
QuantumObjective
function inobjectives.jl
takes aloss::Symbol
which is called internally usingeval(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?