Closed jingc769 closed 2 years ago
Hi Jing,
Thanks for the report.
We removed the rayleigh_quotient
function in favor of explicitly calling the inner
function but didn't update that example (example/10_vqe.jl
) appropriately.
It should work if you replace the loss function with:
function loss(θ⃗)
circuit = variationalcircuit(N, depth, θ⃗)
Uψ = runcircuit(ψ, circuit; cutoff=1e-8)
return inner(Uψ', H, Uψ)
end
I've updated the example and README with this change.
@mtfishman Thank you very much!
Hi, @GTorlai and @mtfishman
I'm Jing. I'm playing with the code. I tried to run the example code. However, I got a "rayleigh_quotient was not defined " error. I searched on the repo, and did not found its definition.
`julia> θ⃗, fs, gs, niter, normgradhistory = optimize(loss_n_grad, θ⃗₀, optimizer) ERROR: UndefVarError: rayleigh_quotient not defined Stacktrace: [1] loss(θ⃗::Vector{Vector{Float64}}) @ Main ./REPL[43]:5 [2] loss_n_grad(x::Vector{Vector{Float64}}) @ Main ./REPL[46]:1 [3] optimize(fg::typeof(loss_n_grad), x::Vector{Vector{Float64}}, alg::LBFGS{Float64, HagerZhangLineSearch{Rational{Int64}}}; precondition::typeof(OptimKit._precondition), finalize!::typeof(OptimKit._finalize!), retract::Function, inner::typeof(OptimKit._inner), transport!::typeof(OptimKit._transport!), scale!::typeof(OptimKit._scale!), add!::typeof(OptimKit._add!), isometrictransport::Bool) @ OptimKit ~/.julia/packages/OptimKit/xpmbV/src/lbfgs.jl:21 [4] optimize(fg::Function, x::Vector{Vector{Float64}}, alg::LBFGS{Float64, HagerZhangLineSearch{Rational{Int64}}}) @ OptimKit ~/.julia/packages/OptimKit/xpmbV/src/lbfgs.jl:20 [5] top-level scope @ REPL[55]:1
`