量子相干與量子糾纏_量子分類

量子相干與量子糾纏

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.pswp.cn/news/391310.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/391310.shtml
英文地址,請注明出處:http://en.pswp.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…