Skip to main content
IBM Quantum Platform

BaseSamplerV1

class qiskit.primitives.BaseSamplerV1(*, options=None)

GitHub

Bases: BasePrimitiveV1, Generic[T]

샘플러 V1 베이스 클래스

양자 회로에서 비트스트링의 준확률을 계산하는 샘플러의 베이스 클래스입니다.

샘플러는 빈 파라미터 세트로 초기화됩니다. 샘플러를 사용하여 JobV1를 생성하는 데 사용됩니다( qiskit.primitives.Sampler.run() 메서드). 이 메서드는 다음 매개 변수를 사용하여 호출됩니다

  • 양자 회로 ( ψi(θ)\psi_i(\theta) ): (매개변수가 지정된) 양자 회로 목록. QuantumCircuit (객체 목록)
  • 파라미터 값 ( θk\theta_k ): 양자 회로의 파라미터에 바인딩할 파라미터 값 집합의 목록입니다. (플로트 목록 목록)

이 메서드는 JobV1 객체를 반환하고 qiskit.providers.JobV1.result() 를 호출하면 SamplerResult 객체를 반환하며, 이 객체에는 비트 문자열의 확률 또는 준확률과 샘플의 오차 막대와 같은 선택적 메타데이터가 포함됩니다.

다음은 샘플러를 사용하는 방법의 예입니다.

# This is a fictional import path.
# There are currently no Sampler implementations in Qiskit.
from sampler_v1_location import SamplerV1
from qiskit import QuantumCircuit
from qiskit.circuit.library import RealAmplitudes

# a Bell circuit
bell = QuantumCircuit(2)
bell.h(0)
bell.cx(0, 1)
bell.measure_all()

# two parameterized circuits
pqc = RealAmplitudes(num_qubits=2, reps=2)
pqc.measure_all()
pqc2 = RealAmplitudes(num_qubits=2, reps=3)
pqc2.measure_all()

theta1 = [0, 1, 1, 2, 3, 5]
theta2 = [0, 1, 2, 3, 4, 5, 6, 7]

# initialization of the sampler
sampler = Sampler()

# Sampler runs a job on the Bell circuit
job = sampler.run(circuits=[bell], parameter_values=[[]], parameters=[[]])
job_result = job.result()
print([q.binary_probabilities() for q in job_result.quasi_dists])

# Sampler runs a job on the parameterized circuits
job2 = sampler.run(
    circuits=[pqc, pqc2],
    parameter_values=[theta1, theta2],
    parameters=[pqc.parameters, pqc2.parameters])
job_result = job2.result()
print([q.binary_probabilities() for q in job_result.quasi_dists])

초기화 SamplerV1.

매개변수

options (dict | None) – 기본 옵션.


속성

options

추정기에 대한 옵션 값을 반환합니다.

리턴

옵션


메소드

run

run(circuits, parameter_values=None, **run_options)

GitHub

비트 문자열 샘플링 작업을 실행합니다.

매개변수

리턴

샘플러 결과의 작업 객체입니다. I 번째 결과는 parameter_values[i] 으로 바인딩된 매개 변수로 평가된 circuits[i] 에 해당합니다.

레이즈

ValueError - 잘못된 인수가 제공됩니다.

리턴 유형

T

set_options

set_options(**fields)

GitHub

추정기의 옵션 값을 설정합니다.

매개변수

**필드 - 옵션을 업데이트할 필드입니다

이 페이지가 도움이 되었습니까?
GitHub에서 버그, 오타를 보고하거나 컨텐츠를 요청하십시오.