mindquantum.framework.MQOps
===========================

.. image:: https://mindspore-website.obs.cn-north-4.myhuaweicloud.com/website-images/r2.5.0/resource/_static/logo_source.svg
    :target: https://gitee.com/mindspore/mindquantum/blob/r0.10/docs/api_python/framework/operations/mindquantum.framework.MQOps.rst
    :alt: 查看源文件


.. py:class:: mindquantum.framework.MQOps(expectation_with_grad)

    包含encoder和ansatz线路的量子线路演化算子,算子返回在参数化量子线路(PQC)演化出的量子态上哈密顿量期望值。此算子只能在 `PYNATIVE_MODE` 下执行。

    参数:
        - **expectation_with_grad** (GradOpsWrapper) - 接收encoder数据和ansatz数据,并返回期望值和参数相对于期望的梯度值。

    输入:
        - **enc_data** (Tensor) - 希望编码为量子态的Tensor,其shape为 :math:`(N, M)` ,其中 :math:`N` 表示batch大小, :math:`M` 表示encoder参数的数量。
        - **ans_data** (Tensor) - shape为 :math:`N` 的Tensor,用于ansatz电路,其中 :math:`N` 表示ansatz参数的数量。

    输出:
        Tensor,hamiltonian的期望值。