量子相干与量子纠缠_130780点量子分类

量子相干与量子纠缠

Dr. Vishal Sharma, a Postdoctoral Research Fellow, recently asked me via LinkedIn messaging about quantum classification. I won’t reveal anything about his 5-column, 26,156-row dataset other than its size — 130,780 total data points — but I will reveal the modified algorithm that I shared with him.

博士后研究员Vishal Sharma博士最近通过LinkedIn向我询问了有关量子分类的信息 。 除了其大小(总共130,780个数据点)以外,我不会透露他的5列26156行数据集的任何信息,但是我将透露与他共享的修改算法。

介绍 (Introduction)

Quantum computing and machine learning are two distinct fields. Although they compliment each other nicely, it is possible to be familiar with one but not the other. Therefore, before providing a brief introduction to quantum classification, it may be beneficial to provide a brief introduction to classification.

量子计算和机器学习是两个不同的领域。 尽管他们很好地互相称赞,但有可能彼此熟悉却又不熟悉。 因此,在提供量子分类的简要介绍之前,对分类进行简要介绍可能是有益的。

An oversimplified description of classification is that we have a number of data points that are divided into classes (groups) and we have new data that we want to assign to an existing group. Typically, that new data is a single data point, just like all the other single data points that are already grouped together, although it is also possible to assign a new group to an existing group.

对分类的过于简单的描述是,我们将许多数据点划分为类(组),并且有新数据要分配给现有组。 通常,新数据是单个数据点,就像已经分组在一起的所有其他单个数据点一样,尽管也可以将新组分配给现有组。

Quantum classification, therefore, is the use of quantum processors, or simulations thereof, to perform this task. Because of both fields' relationship to linear algebra, quantum computing is expected to excel at machine learning tasks.

因此,量子分类是使用量子处理器或其模拟来执行此任务。 由于这两个领域与线性代数的关系,因此量子计算有望在机器学习任务中脱颖而出。

ibmq_16_melbourne (ibmq_16_melbourne)

My initial intent was to run this algorithm on both a NISQ processor and a quantum computing simulator, and to compare runtimes, but it quickly became evident that this would not be possible.

我最初的意图是在NISQ处理器和量子计算模拟器上都运行该算法,并比较运行时间,但是很快就证明这是不可能的。

Image for post

This circuit compares one test state to one class. Because of the limited number of qubits available, it would have to run one time per class.

该电路将一种测试状态与一类进行比较。 由于可用的量子位数量有限,因此每个类必须运行一次。

The first five qubits each represent one feature of one class from the dataset, and the second five qubits each represent one feature from the test data point. The last qubit is the ancilla qubit for the SWAP Test, to determine how close the test data is to the class data. Each Fredkin gate (controlled-SWAP) uses the ancilla qubit as its control and the qubits that represent the same feature as the target qubits.

前五个qubit分别表示数据集中一类的一个特征,后五个qubit分别表示测试数据点中的一个特征。 最后一个量子位是SWAP Test的辅助量子位,用于确定测试数据与类数据的接近程度。 每个Fredkin门(受控SWAP)都使用辅助量子位作为其控制,并且这些量子位表示与目标量子位相同的特征。

Image for post

This is what the transpiled circuit looks like. Not only do Fredkin gates add significant circuit depth during transpilation, the limited connectivity of the processor requires many additional SWAP operations.

这就是转换电路的样子。 弗雷德金(Fredkin)门不仅在转换过程中增加了可观的电路深度,而且处理器的有限连接性还要求许多其他SWAP操作。

Because of the overall circuit depth, the results are worthless. The SWAP Test measures |0> with a probability of 1 when states are identical and with a probability of 0.5 when states are maximally opposite, but the probability of measuring |0> was well under 0.5. That’s just wrong.

由于整个电路的深度,结果毫无价值。 当状态相同时,SWAP测试测得| 0>的概率为1,而当状态最大相反时,SWAP测试的概率为0.5,但测量| 0>的概率远低于0.5。 那是错误的。

ibmq_qasm_simulator (ibmq_qasm_simulator)

Because the 32-qubit IBM Q Experience simulator allows reset gates — NISQ processors do not — it is possible to compare the test data to multiple classes within one circuit. Reset operations also reduce the number of qubits that need to be simulated, which can reduce runtime considerably for large circuits.

由于32位数的IBM Q Experience仿真器允许使用复位门,而NISQ处理器不允许,因此可以将测试数据与一个电路中的多个类别进行比较。 复位操作还减少了需要模拟的qubit数量,这可以大大减少大型电路的运行时间。

Image for post

The first round doesn’t use reset gates because the qubits are freshly initialized, but here is how each class comparison works:

第一轮不使用复位门,因为量子位是新初始化的,但是这是每个类比较的工作方式:

  1. initialize or reset the class data and test data qubits

    初始化或重置类数据和测试数据量子位
  2. map the data to the respective qubits using RY rotations; because the test data remains the same for each class comparison, the “set” block is a subroutine simplifying the OpenQASM code

    使用RY旋转将数据映射到相应的量子位; 因为每个类比较的测试数据都相同,所以“ set”块是简化OpenQASM代码的子例程
  3. compare each test feature to each class feature; the “test” block is a subroutine that performs the same Hadamard operations and SWAP Tests as shown in the ibmq_16_melbourne circuit above

    将每个测试功能与每个类功能进行比较; “ test”块是执行与上面的ibmq_16_melbourne电路相同的Hadamard操作和SWAP测试的子例程。
  4. not shown in this cropped circuit: measure the control qubit “ax,” which is the ancilla qubit for the SWAP Tests

    在此裁剪电路中未显示:测量控制量子比特“ ax”,它是SWAP测试的辅助量子比特

算法 (Algorithm)

This algorithm requires a modest amount of classical preprocessing. Because I received the data in a CSV file, I opened it up in Excel and did the computation there. Functions such as MIN, MAX, and AVERAGE are straightforward to use, and even the normalization function is merely subtraction and division.

该算法需要适量的经典预处理。 因为我是通过CSV文件接收数据的,所以我在Excel中打开了数据并在那里进行了计算。 MIN,MAX和AVERAGE之类的函数易于使用,甚至归一化函数也仅是减法和除法运算。

  1. Calculate the global minimum and global maximum for each feature

    计算每个功能的全局最小值和全局最大值
  2. Calculate the mean value (average) per feature per class

    计算每类每个特征的平均值(平均值)
  3. Select testing data

    选择测试数据
  4. Use the global minima and maxima to normalize the average values and test data points from 0 to 1 using the formula (( input - min ) / ( max - min ))

    使用全局最小值和最大值使用公式((input-min)/(max-min))归一化平均值和测试数据点从0到1
  5. Rotate qubits around the y axis by the normalized values multiplied by pi; use one qubit per feature for the class data and one qubit per feature for the test data

    围绕y轴旋转qubit乘以归一化值乘以pi; 对于类数据,每个特征使用一个量子比特,对于测试数据,每个特征使用一个量子比特
  6. Use the SWAP Test to compare the test data to the class data, feature by feature

    使用SWAP测试逐项将测试数据与类数据进行比较
  7. The SWAP Test with the highest probability of measuring |0> is the closest class to the test data

    具有最高测量可能性| 0>的SWAP测试是最接近测试数据的类别

You could do all this in Python, of course, but I prefer to do everything related to quantum computing in OpenQASM so that the focus is on the circuit.

当然,您可以使用Python来完成所有这些工作,但是我更喜欢在OpenQASM中进行与量子计算有关的所有工作,因此重点放在电路上。

了解数据 (Understanding the Data)

Because of my familiarity with SWAP Tests and my confidence that this algorithm should work, I identified an issue with the data that might be helpful when pursuing other machine learning approaches. In a nutshell, the normalized data was way too close together. Consequently, any test data point could have been classified as any of the classes, as if the algorithm was just generating results randomly. Not one test result was accurate.

由于我熟悉SWAP测试并相信该算法可以工作,因此我发现了数据方面的问题,这可能在追求其他机器学习方法时会有所帮助。 简而言之,归一化的数据太紧密了。 因此,任何测试数据点都可以归为任何类别,就好像该算法只是随机生成结果一样。 没有一个测试结果是准确的。

Fortunately, it was possible to select a subset of the data that resolved this issue without compromising the results. This allowed the normalized values to have a little bit of space between them, and I finally began to see accurate classifications.

幸运的是,可以选择可以解决此问题的数据子集而不会影响结果。 这使归一化的值之间可以有一些间隔,我终于开始看到准确的分类。

结果与结论 (Results and Conclusion)

I normally include histograms in my articles, but this project required far too much testing for that. Instead, I will summarize my findings.

我通常在文章中包含直方图,但是此项目为此需要进行过多的测试。 相反,我将总结我的发现。

If you visually inspect the test data and the class data, you will see that this algorithm accurately classifies test data that obviously belongs to a certain class. The accuracy diminishes when the test values are in between the class values. Some data looks like it could be classified one way, and yet it is labelled a different way. I don’t know enough about the data to know why that is, but I don’t consider that to be an algorithm problem. The data points are legitimately closer to other labels than their own.

如果您目视检查测试数据和类数据,您会发现该算法可以准确地对显然属于某个类的测试数据进行分类。 当测试值介于类值之间时,精度会降低。 某些数据看起来可以按一种方式分类,但被标记为另一种方式。 我对数据了解不足,无法知道为什么,但是我不认为这是算法问题。 数据点合法地比它们自己更靠近其他标签。

未来的工作 (Future Work)

Dr. Sharma initially inquired about Quantum Restricted Boltzmann Machines (QRBM), but I am far more familiar with SWAP Tests so I presented this approach to him. It would, of course, be interesting to compare my approach to a QRBM implementation, as well as a scikit-learn implementation. Simple QRBM, it seems, might have a possibility of working on a NISQ processor, and that would certainly be interesting.

Sharma博士最初询问了量子限制玻尔兹曼机(QRBM),但是我对SWAP测试更为熟悉,因此我向他介绍了这种方法。 当然,将我的方法与QRBM实现以及scikit-learn实现进行比较会很有趣。 看来,简单的QRBM可能有可能在NISQ处理器上工作,这当然很有趣。

致谢 (Acknowledgement)

All images are from IBM Q Experience.

所有图像均来自IBM Q Experience。

翻译自: https://medium.com/@bsiegelwax/130-780-point-quantum-classification-ddeea767adb1

量子相干与量子纠缠

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值