量子相干与量子纠缠_量子分类

量子相干与量子纠缠

My goal here was to build a quantum deep neural network for classification tasks, but all the effort involved in calculating errors, updating weights, training a model, and so forth turned out to be completely unnecessary. The above circuit is much simpler than it must already look, and I am going to fully break it down for you.

我的目标是建立一个用于分类任务的量子深层神经网络,但是计算误差,更新权重,训练模型等所有工作完全没有必要。 上面的电路比必须已经看起来的要简单得多,我将为您详细介绍一下。

Disclaimer

免责声明

This circuit is intentionally not optimized. Rather, it is intended to be comprehensible. I intend to address optimization as I add complexity to future circuits, which will have their own associated articles.

该电路有意未进行优化。 相反,其意图是易于理解的。 我打算解决优化问题,因为这会增加将来的电路的复杂性,这些电路将有自己的相关文章。

Background

背景

This origin of this classification task is a very simple neural network that had been written in Python. Long ago, I rewrote this neural network in C to force me to better understand how it worked. Without the use of NumPy, in particular, I had to write all the functions from scratch (I avoided potentially-helpful C libraries, as well). Armed with this relatively-deep understanding, I selected this same neural network to translate further from C into OpenQASM.

分类任务的起源是一个非常简单的神经网络,该网络已经用Python编写。 很久以前,我用C语言重写了这个神经网络,以迫使我更好地了解它的工作原理。 特别是在不使用NumPy的情况下,我不得不从头开始编写所有功能(我也避免了可能有用的C库)。 有了相对较深的理解,我选择了相同的神经网络将其从C进一步转换为OpenQASM。

Registers

寄存器

This circuit uses four registers. The “a” register consists of two ancilla qubits, each paired up with one qubit from the two-qubit “data” register. The “train” register consists of the training data from the original neural network in Python; the data is mapped to 11 qubits. And, of course, there is a classical register for taking measurements.

该电路使用四个寄存器。 “ a”寄存器由两个辅助量子位组成,每个辅助量子位与两个量子位“数据”寄存器中的一个量子位配对。 “训练”寄存器由Python中原始神经网络的训练数据组成; 数据被映射到11个量子位。 当然,还有一个经典的寄存器可以进行测量。

The reason for the two ancilla qubits and the two data qubits is that the original neural network had only two classifications, represented numerically by 0 and 1. One ancilla-data pair is used to compare the test state to the training data that is classified as 0, and the other ancilla-data pair is used to compare the test state to the training data that is classified as 1.

使用两个辅助量子位和两个数据量子位的原因是,原始神经网络只有两个分类,用数字0和1表示。一个辅助数据对用于将测试状态与分类为的训练数据进行比较0,另一个辅助数据对用于将测试状态与分类为1的训练数据进行比较。

Initial States

初始状态

The ancilla qubits are initialized with Hadamard gates, the first operation when performing SWAP Tests, which are used to compare quantum states.

使用Hadamard门初始化辅助量子位,这是执行SWAP测试时的第一个操作,用于比较量子态。

Read more about SWAP Tests:

进一步了解SWAP测试:

  • Comparing Quantum States

    比较量子态

  • Basis-Specific SWAP Test

    基础特定的SWAP测试

  • Simplified Quantum Machine Learning (QML) Classification

    简化量子机器学习(QML)分类

  • Comparing Entangled States

    比较纠缠的国家

The data qubits are prepared identically with simple rotations around the y axis. The training data is also mapped with y rotations, except for one qubit which remains in it’s ground state and one which has a Pauli-X (NOT) gate applied to it.

围绕y轴进行简单旋转即可完全相同地准备数据量子位。 训练数据还映射了y旋转,除了一个qubit保持其基态,另一个保留了Pauli-X(NOT)门。

Normalization

正常化

The reason why the data qubits and training qubits can be mapped with y rotations is because the original data contained integer values that had to be normalized between zero and one. If you have values ranging from 0 to 360, the 360 would be normalized to 1, 180 would be normalized to 0.5, 90 would be normalized to 0.25, and so forth. I took the normalized values from my C language implementation and converted them to y-axis rotations.

可以使用y旋转映射数据qubit和训练qubit的原因是,原始数据包含必须在0到1之间归一化的整数值。 如果您的值介于0到360之间,则将360标准化为1,将180标准化为0.5,将90标准化为0.25,依此类推。 我从C语言实现中获取了标准化的值,并将其转换为y轴旋转。

Calculating Theta

计算θ

Calculating the angle of rotation around the y axis is normally a matter of trigonometry, but not in this case. I did not want the normalized values to be converted into probabilities of measuring |1> because that would cause states closer to |0> and |1> to seem closer together than states near the equator of the Bloch Sphere. For purposes of SWAP Testing, the distance between 0 and 1 has to be the same as the distance between 49 and 50. Therefore, each qubit’s rotation around the y axis is merely the classical normalized value multiplied times pi.

计算绕y轴的旋转角度通常是三角问题,但在这种情况下不是。 我不希望将规范化的值转换为测量| 1>的概率,因为这将导致比| Bloch球的赤道附近的状态更接近| 0>和| 1>的状态在一起。 为了进行SWAP测试,0和1之间的距离必须与49和50之间的距离相同。因此,每个qubit绕y轴的旋转仅仅是经典归一化值乘以pi。

Controlled-SWAPs

受控交换

SWAP Tests begin by applying Hadamard gates to the ancilla qubits. These are followed by Fredkin gates, which are controlled-SWAP gates. The ancilla qubits are the control qubits. For additional detail, I refer again to the links I provided earlier.

SWAP测试通过将Hadamard门应用到辅助量子位开始。 这些之后是Fredkin门,它们是受控SWAP门。 辅助量子位是控制量子位。 有关更多详细信息,请再次参考我之前提供的链接。

I went in simple numerical order for viewability. If the training data is classified as 0, the Fredkin gate takes a[0] as it’s control and compares data[0] to that training qubit. If the training data is classified as 1, the Fredkin gate takes a[1] as it’s control and compares data[1] to that training qubit. In other words, a[0] and data[0] are being used to compare the test state to all the training data that is classified as 0 and a[1] and data[1] are being used to compare the test state to all the training data that is classified as 1.

我以简单的数字顺序查看。 如果训练数据被分类为0,则Fredkin门将a [0]作为控制,并将data [0]与该训练量子位进行比较。 如果训练数据分类为1,则Fredkin门将a [1]作为控制,并将data [1]与该训练量子位进行比较。 换句话说,a [0]和data [0]用于将测试状态与分类为0的所有训练数据进行比较,而a [1]和data [1]用于将测试状态与进行比较的测试状态进行比较。所有分类为1的训练数据。

Finalizing the SWAP Tests

完成SWAP测试

SWAP Tests are finalized by taking x measurements of the ancilla qubits. The x measurements are distinguishable from the usual z measurements by the presence of Hadamard gates that are applied immediately preceding the measurements.

通过对辅助量子比特进行x次测量来完成SWAP测试。 x测量值与通常的z测量值的区别在于存在哈达玛德门(Hadamard gate),这些门紧接在测量之前被应用。

Measurements

测量

Measuring the ancilla qubits provides the distance between the test data and the training data. You measure |0> with a probability of 1 when states are identical and you measure |0> with a probability of 0.5 when states are maximally different. The a[0] qubit measures the distance between the test data and the training data that is classified as 0, and the a[1] qubit measures the distance between the test data and the training data that is classified as 1.

测量辅助量子位可提供测试数据和训练数据之间的距离。 当状态相同时,以0的概率测量| 0>,而在状态最大不同时,以0.5的概率测量| 0>。 a [0]量子位测量测试数据和分类为0的训练数据之间的距离,而a [1]量子位测量测量数据与分类为1的训练数据之间的距离。

Classification

分类

Image for post

For this article, I selected a value for the test data that should result in it being classified as a 1. That is to say that the same value is determined to be probably 1 when you run it classically. And, according to the histogram, the ancilla qubit representing the 1 classification did, in fact, have a higher probability of being measured as |0> than the 0 classification. This means that the test data is closer to the training data that is classified as 1 than it is to the training data that is classified as 0.

在本文中,我为测试数据选择了一个值,该值应将其分类为1。也就是说,当您经典运行它时,确定该值可能为1。 并且,根据直方图,代表1分类的辅助量子比特实际上被测量为| 0>的概率要大于0分类。 这意味着测试数据离分类为1的训练数据更近,而离分类为0的训练数据更近。

Future Work

未来的工作

The original neural network was slightly more complex. It actually used three features to distinguish the two classes, but I only used one of those features here. Therefore, a logical next step would be to perform quantum classification using multiple features. Beyond that, another logical step would be to allow more than just two classes, however that would require changing the classical model that the circuit is based on; at this stage, it is important to know that the quantum result is aligned with the classical result, especially as the quantum circuit grows in complexity.

原始的神经网络稍微复杂一些。 它实际上使用了三个功能来区分这两个类,但是我在这里只使用了其中一个功能。 因此,逻辑上的下一步将是使用多个特征执行量子分类。 除此之外,另一个逻辑步骤是允许不止两个类别,但是这将需要更改电路所基于的经典模型; 在这一阶段,重要的是要知道量子结果与经典结果一致,尤其是随着量子电路复杂性的增长。

Acknowledgment

致谢

This circuit was written in OpenQASM using the IBM Q Experience circuit editor, and it ran on the provided 32-qubit simulator.

该电路是使用IBM Q Experience电路编辑器以OpenQASM编写的,并在提供的32量子位模拟器上运行。

翻译自: https://medium.com/swlh/quantum-classification-cecbc7831be

量子相干与量子纠缠

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/391310.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Python -- xlrd,xlwt,xlutils 读写同一个Excel

最近开始学习python,想做做简单的自动化测试,需要读写excel,然后就找到了xlrd来读取Excel文件,使用xlwt来生成Excel文件(可以控制Excel中单元格的格式),需要注意的是,用xlrd读取excel是不能对其进行操作的&…

知识力量_网络分析的力量

知识力量The most common way to store data is in what we call relational form. Most systems get analyzed as collections of independent data points. It looks something like this:存储数据的最常见方式是我们所谓的关系形式。 大多数系统作为独立数据点的集合进行分析…

SCCM PXE客户端无法加载DP(分发点)映像

上一篇文章我们讲到了一个比较典型的PXE客户端无法找到操作系统映像的故障,今天再和大家一起分享一个关于 PXE客户端无法加载分发点映像的问题。具体的报错截图如下:从报错中我们可以看到,PXE客户端已经成功的找到了SCCM服务器,并…

Docker 入门(2)技术实现和核心组成

1. Docker 的技术实现 Docker 的实现,主要归结于三大技术: 命名空间 ( Namespaces )控制组 ( Control Groups )联合文件系统 ( Union File System ) 1.1 Namespace 命名空间可以有效地帮助Docker分离进程树、网络接口、挂载点以及进程间通信等资源。L…

marlin 三角洲_带火花的三角洲湖:什么和为什么?

marlin 三角洲Let me start by introducing two problems that I have dealt time and again with my experience with Apache Spark:首先,我介绍一下我在Apache Spark上的经历反复解决的两个问题: Data “overwrite” on the same path causing data l…

eda分析_EDA理论指南

eda分析Most data analysis problems start with understanding the data. It is the most crucial and complicated step. This step also affects the further decisions that we make in a predictive modeling problem, one of which is what algorithm we are going to ch…

基于ssm框架和freemarker的商品销售系统

项目说明 1、项目文件结构 2、项目主要接口及其实现 (1)Index: 首页页面:展示商品功能,可登录或查看商品详细信息 (2)登录:/ApiLogin 3、dao层 数据持久化层,把商品和用户…

简·雅各布斯指数第二部分:测试

In Part I, I took you through the data gathering and compilation required to rank Census tracts by the four features identified by Jane Jacobs as the foundation of a great neighborhood:在第一部分中 ,我带您完成了根据简雅各布斯(Jacobs Jacobs)所确定…

Docker 入门(3)Docke的安装和基本配置

1. Docker Linux下的安装 1.1 Docker Engine 的版本 社区版 ( CE, Community Edition ) 社区版 ( Docker Engine CE ) 主要提供了 Docker 中的容器管理等基础功能,主要针对开发者和小型团队进行开发和试验企业版 ( EE, Enterprise Edition ) 企业版 ( Docker Engi…

python:单元测试框架pytest的一个简单例子

之前一般做自动化测试用的是unitest框架,发现pytest同样不错,写一个例子感受一下 test_sample.py import cx_Oracle import config from send_message import send_message from insert_cainiao_oracle import insert_cainiao_oracledef test_cainiao_mo…

抑郁症损伤神经细胞吗_使用神经网络探索COVID-19与抑郁症之间的联系

抑郁症损伤神经细胞吗The drastic changes in our lifestyles coupled with restrictions, quarantines, and social distancing measures introduced to combat the corona virus outbreak have lead to an alarming rise in mental health issues all over the world. Social…

Docker 入门(4)镜像与容器

1. 镜像与容器 1.1 镜像 Docker镜像类似于未运行的exe应用程序,或者停止运行的VM。当使用docker run命令基于镜像启动容器时,容器应用便能为外部提供服务。 镜像实际上就是这个用来为容器进程提供隔离后执行环境的文件系统。我们也称之为根文件系统&a…

python:pytest中的setup和teardown

原文:https://www.cnblogs.com/peiminer/p/9376352.html  之前我写的unittest的setup和teardown,还有setupClass和teardownClass(需要配合classmethod装饰器一起使用),接下来就介绍pytest的类似于这类的固件。 &#…

如何开始使用任何类型的数据? - 第1部分

从数据开始 (START WITH DATA) My data science journey began with a student job in the Advanced Analytics department of one of the biggest automotive manufacturers in Germany. I was nave and still doing my masters.我的数据科学之旅从在德国最大的汽车制造商之一…

iHealth基于Docker的DevOps CI/CD实践

本文由1月31日晚iHealth运维技术负责人郭拓在Rancher官方技术交流群内所做分享的内容整理而成,分享了iHealth从最初的服务器端直接部署,到现在实现全自动CI/CD的实践经验。作者简介郭拓,北京爱和健康科技有限公司(iHealth)。负责公…

机器学习图像源代码_使用带有代码的机器学习进行快速房地产图像分类

机器学习图像源代码RoomNet is a very lightweight (700 KB) and fast Convolutional Neural Net to classify pictures of different rooms of a house/apartment with 88.9 % validation accuracy over 1839 images. I have written this in python and TensorFlow.RoomNet是…

leetcode 938. 二叉搜索树的范围和

给定二叉搜索树的根结点 root,返回值位于范围 [low, high] 之间的所有结点的值的和。 示例 1: 输入:root [10,5,15,3,7,null,18], low 7, high 15 输出:32 示例 2: 输入:root [10,5,15,3,7,13,18,1,nul…

COVID-19和世界幸福报告数据告诉我们什么?

For many people, the idea of ​​staying home actually sounded good at first. This process was really efficient for Netflix and Amazon. But then sad truths awaited us. What was boring was the number of dead and intubated patients one after the other. We al…

iOS 开发一定要尝试的 Texture(ASDK)

原文链接 - iOS 开发一定要尝试的 Texture(ASDK)(排版正常, 包含视频) 前言 本篇所涉及的性能问题我都将根据滑动的流畅性来评判, 包括掉帧情况和一些实际体验 ASDK 已经改名为 Texture, 我习惯称作 ASDK 编译环境: MacOS 10.13.3, Xcode 9.2 参与测试机型: iPhone 6 10.3.3, i…

lisp语言是最好的语言_Lisp可能不是数据科学的最佳语言,但是我们仍然可以从中学到什么呢?...

lisp语言是最好的语言This article is in response to Emmet Boudreau’s article ‘Should We be Using Lisp for Data-Science’.本文是对 Emmet Boudreau的文章“我们应该将Lisp用于数据科学”的 回应 。 Below, unless otherwise stated, lisp refers to Common Lisp; in …