2023 mindspore量子计算黑客马拉松全国大赛热身题
第一题
受控比特门的操作
X.on(2,[0,1])#.on(int,array)
第二题
压缩量子比特
circ.compress()#考察量子比特压缩函数、清除不用的函数
第三题
翻转电路,切换至大头端
reverse_qubits()
第四题
添加后缀
add_suffix(circ,p)
第五题
查看TimeEvolution类的函数
TimeEvolution(h).circuit
第六题
量子线路搭建
from mindquantum.core.circuit import Circuit # 导入Circuit模块,用于搭建量子线路
from mindquantum.core.circuit import UN # 导入UN模块
from mindquantum.core.gates import H, X, RZ # 导入量子门H, X, RZ
encoder = Circuit() # 初始化量子线路
encoder += UN(H, 4) # H门作用在每1位量子比特
for i in range(4): # i = 0, 1, 2, 3
encoder += RZ(f'alpha{i}').on(i) # RZ(alpha_i)门作用在第i位量子比特
for j in range(3): # j = 0, 1, 2
# 请补充如下代码片段
encoder += X.on(j+1,j)
encoder += RZ(f'alpha{j+4}').on(j+1)
encoder += X.on(j+1,j)

第七、八、九题
参考文档https://hiq.huaweicloud.com/tutorial/classification_of_iris_by_qnn
This line appears after every note.
Notes mentioning this note
Projects
0.百科全书
[[github问题]] 2024.10.08
[[笔记本电脑]]
[[华为手机安装google框架]]
[[科研问题]]
[[github问题]]
[[huggingface]]
[[linux]]
[[Python使用]]
[[Vscode使用]]
[[港科广二期HPC使用]] 2025.07.25
[[顶会论文及检索网址]] 2025.10.10
1.前后端
[[使用Flask快速构建浏览器实现图片交互]]