-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from yangguohao/task79
【PaddlePaddle Hackathon】79 图片编码为量子态
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from paddle_quantum.utils import img_to_density_matrix | ||
import paddle | ||
import matplotlib.image | ||
import numpy as np | ||
|
||
|
||
img_file = '/home/aistudio/f1.jpeg' | ||
rho = (img_to_density_matrix(img_file)) | ||
|
||
#半正定 | ||
w,_=np.linalg.eig(rho) | ||
print(all(w>=0)) | ||
#迹为1 | ||
print(np.trace(rho)) | ||
#shape为[2**n,2**n] | ||
print(rho.shape) |