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

Pyvqnet中测量模块的功能使用 #34

Open
lingjiajie opened this issue Dec 7, 2023 · 1 comment
Open

Pyvqnet中测量模块的功能使用 #34

lingjiajie opened this issue Dec 7, 2023 · 1 comment

Comments

@lingjiajie
Copy link

您好。

对于特定的量子线路,即使不同的输入,ProbsMeasure的输出结果也是一样的。我不太清楚为什么有这样的结果(ProbsMeasure介绍下给的链接我跳转不到对应页面)。所以,可否提供更多关于 pyvqnet.qnn.measure中ProbsMeasure函数的介绍。
image

以下是我的代码:
`

from pyvqnet.qnn.measure import ProbsMeasure
import pyqpanda as pq
from pyqpanda.Visualization import draw_qprog
import os
import warnings
warnings.filterwarnings("ignore")
dir = os.path.join(
    os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))), 
    'results/quantum'
)

if __name__ == '__main__':

    input = [[0.56,0.1], [0, 0.1],[0.1, 1]]
    for i in range(3):
        print('input:', input[i])
        measure_qubits = [0,2]
        machine = pq.init_quantum_machine(pq.QMachineType.CPU)
        m_prog = pq.QProg()
        m_qlist = machine.qAlloc_many(3)
        cir = pq.QCircuit()
        cir.insert(pq.H(m_qlist[0]))
        cir.insert(pq.H(m_qlist[1]))
        cir.insert(pq.H(m_qlist[2]))
        cir.insert(pq.RZ(m_qlist[0], input[i][0]))
        cir.insert(pq.CNOT(m_qlist[0],m_qlist[1]))
        cir.insert(pq.RY(m_qlist[1], input[i][1]))
        cir.insert(pq.CNOT(m_qlist[0], m_qlist[2]))
        m_prog.insert(cir)
        rlt_prob = ProbsMeasure([0, 2], m_prog, machine, m_qlist)
        print('ProbsMeasure output:', rlt_prob)

    draw_qprog(m_prog, 'pic', filename=dir + '/cir.png')

`

结果:
image

@kevzos
Copy link
Contributor

kevzos commented Dec 7, 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