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

量子相干与量子纠缠

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,一经查实,立即删除!

相关文章

三角函数式的化简

前言 为什么需要化简三角函数式? 一、什么是三角函数式的化简? 二、三角函数式的化简标准是什么? 三、三角函数式化简可能用到的变形: 弦切互化,1的代换,通分约分,配方展开,提取公因…

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

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

计算机工程师分级_这些是每个计算机工程师都应该知道的数字

计算机工程师分级In 2010, Jeff Dean from Google gave a wonderful talk at Stanford that made him quite famous. In it, he discussed a few numbers that are relevant to computing systems. Then Peter Norvig published those numbers for the first time on the inter…

leetcode 377. 组合总和 Ⅳ(dp)

给你一个由 不同 整数组成的数组 nums ,和一个目标整数 target 。请你从 nums 中找出并返回总和为 target 的元素组合的个数。 题目数据保证答案符合 32 位整数范围。 示例 1: 输入:nums [1,2,3], target 4 输出:7 解释&…

1.4- 定时任务总结之九句箴言

1.4定时任务之九句箴言九句箴言---- 不会九句箴言别做运维1.定时任务规则之前加注释2.使用脚本代替命令行制定定时任务3.定时任务中date命令%的特殊含义定时任务中,%表示回车 -----可以使用\转义4.运行脚本一定要用/bin/sh或sh脚本不必须有x权限5.定时任务中-命令或脚本的输出…

ubuntu 18.04 vi里面方向键变成abcd 处理办法

sudo apt-get remove vim-common sudo apt-get install vim 转载于:https://www.cnblogs.com/testing-BH/p/11506400.html

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

知识力量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:存储数据的最常见方式是我们所谓的关系形式。 大多数系统作为独立数据点的集合进行分析…

python里的apply,applymap和map的区别

apply,applymap和map的应用总结:apply 用在dataframe上,用于对row或者column进行计算;applymap 用于dataframe上,是元素级别的操作;map (其实是python自带的)用于series上,是元素级别的操作。如…

验证曲线和学习曲线_如何击败技术学习曲线的怪物

验证曲线和学习曲线Doing what I do for a living, which these days mostly involves creating technology books and courseware, I’m constantly learning new technologies. In a way, my new tech adventures are not much different than the ones most IT pros face, e…

234

234 转载于:https://www.cnblogs.com/Forever77/p/11509588.html

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…

环境变量的作用

1. PATH环境变量。作用是指定命令搜索路径,在shell下面执行命令时,它会到PATH变量所指定的路径中查找看是否能找到相应的命令程序。我们需要把 jdk安装目录下的bin目录增加到现有的PATH变量中,bin目录中包含经常要用到的可执行文件如javac/ja…

WeWork通过向225,000个社区征税来拼命地从Meetup.com榨取现金

Update: A few hours after I published this article, Meetup quietly added a note to the top of their announcement. They have not tweeted or done anything else to publicize this note, but some people noticed it and shared it with me.更新:在我发布本…

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…

leetcode 897. 递增顺序搜索树(中序遍历)

给你一棵二叉搜索树,请你 按中序遍历 将其重新排列为一棵递增顺序搜索树,使树中最左边的节点成为树的根节点,并且每个节点没有左子节点,只有一个右子节点。 示例 1: 输入:root [5,3,6,2,4,null,8,1,null…

【一针见血】 JavaScript this

JavaScript this 指向一站式解决转载于:https://www.cnblogs.com/xueyejinghong/p/8403987.html

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

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

c++飞扬的小鸟游戏_通过建立一个飞扬的鸟游戏来学习从头开始

c飞扬的小鸟游戏Learn how to use Scratch 3.0 by building a flappy bird game in this course developed by Warfame. Scratch is a free programming language and online community where you can create your own interactive stories, games, and animations. Scratch is…