PaddlePaddle / Quantum

Other
567 stars 176 forks source link

【PaddlePaddle Hackathon】78 实现密度矩阵可视化 #29

Closed gsq7474741 closed 2 years ago

gsq7474741 commented 2 years ago

【PaddlePaddle Hackathon】78 实现密度矩阵可视化

PR types

New features

PR changes

APIs

Describe

gsq7474741 commented 2 years ago

@Quleaf

gsq7474741 commented 2 years ago

@TCChenlong

Quleaf commented 2 years ago

使用以下代码测试,显示的图片会有bug。

import numpy as np
import paddle
from paddle_quantum.circuit import UAnsatz
from paddle_quantum.utils import plot_density_graph
import matplotlib.pyplot as plt

cir = UAnsatz(3)
rng = np.random.default_rng()
a = rng.random(size=[3, 3, 3])
a = paddle.to_tensor(a)
cir.complex_entangled_layer(a, 3)
cir.ry(paddle.to_tensor(1, dtype='float64'), 0)
state = cir.run_density_matrix()
figure = plot_density_graph(state)
plt.show()
gsq7474741 commented 2 years ago

@Quleaf 感谢指正,已修复