You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 18, 2021. It is now read-only.
I was reading the documentation of Yao and found that in the description of function expect', the Note (blue box) says that expect' is a slight modification of expect for the cases of batched registers when we input a pair of register and circuit, which I assume implies that expect can also return gradients.
However, it is also stated that "expect" only returns the expectation value of the observable, which is contradictory to the Note (blue box).
From my test
julia> expect(h, zero_state(4) => c) == expect(h, zero_state(4) |> c)
true
julia> expect'(h, zero_state(4)|>c)
ArrayReg{1, Complex{Float64}, Array...}
active qubits: 4/4
So it seems that expect just returns the expectation value in either case and expect' doesn't return expectation value even when we don't input the pair of register and circuit.
Do you intend to differ expect and expect' by just the functionality of accumulating the outputs for multiple-batch cases? Or do you want to specify expect' as the function to get gradients of a differentiable circuit? So far I find the logic and documentation about those two functions are a bit confusing.
Also, I think it would be better if you could specify the requirement of the circuit inside the input pair. Does it have to be the variational_circuit from YaoExtension.jl or can it be any parameterized circuit but marked with differentiable blocks?
Thank you very much!
The text was updated successfully, but these errors were encountered:
frankwswang
changed the title
Has the functionality of expect' already changed?
Should expect return gradients of parameters when inputting a pair of register and circuit?
Jun 17, 2020
frankwswang
changed the title
Should expect return gradients of parameters when inputting a pair of register and circuit?
The different behaviors between expect and expect' when inputting a pair of register and circuit
Jun 17, 2020
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I was reading the documentation of Yao and found that in the description of function
expect'
, the Note (blue box) says thatexpect'
is a slight modification ofexpect
for the cases of batched registers when we input a pair of register and circuit, which I assume implies thatexpect
can also return gradients.However, it is also stated that "expect" only returns the expectation value of the observable, which is contradictory to the Note (blue box).
From my test
So it seems that
expect
just returns the expectation value in either case andexpect'
doesn't return expectation value even when we don't input the pair of register and circuit.Do you intend to differ
expect
andexpect'
by just the functionality of accumulating the outputs for multiple-batch cases? Or do you want to specifyexpect'
as the function to get gradients of a differentiable circuit? So far I find the logic and documentation about those two functions are a bit confusing.Also, I think it would be better if you could specify the requirement of the circuit inside the input pair. Does it have to be the
variational_circuit
fromYaoExtension.jl
or can it be any parameterized circuit but marked with differentiable blocks?Thank you very much!
The text was updated successfully, but these errors were encountered: