量子计算 qiskit

总览 (Overview)

There exist two popular integrations of quantum computing packages in standard deep learning libraries:

标准深度学习库中存在两种流行的量子计算软件包集成:

  1. Tensorflow and Cirq as Tensorflow Quantum

    Tensorflow和Cirq作为Tensorflow Quantum

  2. Pytorch and Qiskit

    Pytorch和Qiskit

In this article, we will be talking about integrating Qiskit in custom Keras layers.

在本文中,我们将讨论如何将Qiskit集成到自定义Keras图层中。

介绍 (Introduction)

Quantum machine learning has an interesting application of assisting classical neural networks with quantum layers that involve computation not realisable classically. Recent work in academia has stressed on applications of quantum-assisted deep learning which can have complex activations, better representation, and other salient features not achievable in classical networks.

量子机器学习在将经典神经网络与量子层相辅相成方面具有有趣的应用,其中涉及无法经典实现的计算。 学术界的最新工作强调了量子辅助深度学习的应用,该应用可能具有复杂的激活,更好的表示以及其他经典网络无法实现的显着特征。

For the implementation side, this means finding a way to integrate quantum processing in normal deep neural networks. Several ways exist to achieve this. Here, we discuss integrating Qiskit as subclasses of Keras layers. Let’s get started.

对于实现方面,这意味着找到一种在常规深度神经网络中集成量子处理的方法。 存在几种实现此目的的方法。 在这里,我们讨论将Qiskit集成为Keras图层的子类。 让我们开始吧。

定义量子层 (Defining the quantum layer)

This obviously depends on specific application. The thing to keep in mind is to be consistent in the inputs and outputs this layer has. With eager_execution as default in Tensorflow 2.x, it is only natural to fall back to numpy arrays as our default inputs to and outputs from all quantum layers.

这显然取决于特定的应用程序。 要记住的是,该层的输入和输出要保持一致。 在tensorflow 2.x eager_execution作为默认设置,自然而然地退回到numpy数组作为我们对所有量子层的默认输入和输出。

Sample quantum layer
样品量子层

This is an arbitrary quantum layer taking in four inputs and outputting a numpy array of length 4. We calculate the expectations of standard Pauli operators, create a list, and return it. This layer would change according to the specifics of the underlying application.

这是一个任意的量子层,接受四个输入并输出一个长度为4的numpy数组。我们计算标准Pauli运算符的期望值,创建一个列表,然后将其返回。 该层将根据基础应用程序的细节进行更改。

与量子层相互作用 (Interacting with the quantum layer)

Now we need to create a Keras layer that integrates the quantum layer we defined earlier. For this, we need to extend the tensorflow.keras.Layer class that allows writing custom layers for Keras models.

现在,我们需要创建一个Keras层,该层集成了我们先前定义的量子层。 为此,我们需要扩展tensorflow.keras.Layer类,以允许为Keras模型编写自定义层。

Subclassed Layer
子层

The layer receives inputs according to the batch_size of training. So we need to make sure every training example goes through the quantum layer to create an output, thus the need for the loop.

该层根据训练的batch_size接收输入。 因此,我们需要确保每个训练示例都经过量子层以创建输出,因此需要循环。

tf.executing_eagerly() is important as it will allow us to convert the default input Tensor to a numpy array via inputs.numpy() . If application depends on Tensorflow 1.x, tf.enable_eager_execution() may be called to enable eager execution. Eager execution, intuitively, allows us to access the values of the tensor as they become available. If it is disabled, we need to bring in the complexity of tensorflow’s sessions and execution graphs.

tf.executing_eagerly()很重要,因为它将允许我们通过inputs.numpy()将默认输入Tensor转换为numpy数组。 如果应用程序依赖于Tensorflow 1.x,则可以调用tf.enable_eager_execution()启用急切执行。 直观地执行急切操作可以使我们在张量值可用时对其进行访问。 如果禁用它,我们需要引入tensorflow会话和执行图的复杂性。

建立模型 (Building the model)

Building the model is straightforward. We may build a functional model or a Sequential model for our use.

建立模型很简单。 我们可以建立一个功能模型或一个顺序模型供我们使用。

Model workflow
模型工作流程

Compiling the model with run_eagerly is important. I have observed some saved models don’t work as expected after loading them if they are not compiled with run_eagerly set to True.

使用run_eagerly编译模型很重要。 我观察到某些保存的模型如果未将run_eagerly设置为True编译,则在加载它们后将无法按预期工作。

保存和加载模型 (Saving and loading the model)

Saving proceeds as normal. Loading, however, asks you to define the custom class for the custom layer we created.

照常保存收益。 但是,加载会要求您为我们创建的自定义图层定义自定义类。

Saving and loading models
保存和加载模型

The custom_objects allows you to define custom objects. It takes a dictionary with keys corresponding to the custom layers you have, and their values corresponding to the custom classes you want the custom layers to be associated with. This has a subtle caveat: it is possible to change implementations of these layers between different training sessions of some model. If you have a model trained on the quantum layer given previously in this post, it is possible to load such a model and retrain it on some other quantum logic.

custom_objects允许您定义自定义对象。 它需要一个字典,该字典的keys与您拥有的自定义图层相对应,其values与您希望与自定义图层关联的自定义类相对应。 这有一个细微的警告:可以在某些模型的不同培训课程之间更改这些层的实现。 如果您有一个在本文前面给出的量子层上训练过的模型,则可以加载这样的模型并在其他一些量子逻辑上对其进行重新训练。

结论 (Conclusion)

This post is a basic skeleton to set up a working quantum assisted deep learning architecture using Qiskit and Tensorflow. Some things are to be noted:

这篇文章是使用Qiskit和Tensorflow建立可行的量子辅助深度学习架构的基本框架。 需要注意一些事项:

  1. Calculating the expectation values is a major bottleneck. An enormous slowdown may be experienced for large batch sizes since we have completely done away with the advantage matrix multiplication in classical deep learning had.计算期望值是一个主要瓶颈。 对于大批量生产,可能会经历极大的速度下降,因为我们已经完全消除了经典深度学习中矩阵乘法的优势。
  2. Expectation values may be really small. An appropriate scalar multiplier may be used to scale them up.期望值可能确实很小。 可以使用适当的标量乘数来放大它们。

Hope this will get you started with putting Qiskit powered layers in Tensorflow networks. Have a great day :)

希望这会帮助您开始在Tensorflow网络中放置由Qiskit支持的层。 祝你有美好的一天 :)

翻译自: https://towardsdatascience.com/integrating-tensorflow-and-qiskit-for-quantum-machine-learning-7fa6b14d5294

量子计算 qiskit


http://www.taodudu.cc/news/show-863426.html

相关文章:

  • throw 烦人_烦人的简单句子聚类
  • 使用NumPy优于Python列表的优势
  • 迷你5和迷你4区别_可变大小的视频迷你批处理
  • power bi可视化表_如何使用Power BI可视化数据?
  • 变形金刚2_变形金刚(
  • 机器学习 测试_测试优先机器学习
  • azure机器学习_Microsoft Azure机器学习x Udacity —第4课笔记
  • 机器学习嵌入式实现_机器学习中的嵌入
  • 无监督学习 k-means_无监督学习-第3部分
  • linkedin爬虫_机器学习的学生和从业者的常见问题在LinkedIn上提问
  • lime 深度学习_用LIME解释机器学习预测并建立信任
  • 神经网络 梯度下降_梯度下降优化器对神经网络训练的影响
  • 深度学习实践:计算机视觉_深度学习与传统计算机视觉技术:您应该选择哪个?
  • 卷积神经网络如何解释和预测图像
  • 深度学习 正则化 正则化率_何时以及如何在深度学习中使用正则化
  • 杨超越微数据_资料来源同意:数据科学技能超越数据
  • 统计概率分布_概率统计中的重要分布
  • 人口预测和阻尼-增长模型_使用分类模型预测利率-第1部分
  • 基于kb的问答系统_1KB以下基于表的Q学习
  • 图论为什么这么难_图论是什么,为什么要关心?
  • 使用RNN和TensorFlow创建自己的Harry Potter短故事
  • bitnami如何使用_使用Bitnami获取完全配置的Apache Airflow Docker开发堆栈
  • cox风险回归模型参数估计_信用风险管理:分类模型和超参数调整
  • 支持向量机 回归分析_支持向量机和回归分析
  • ai/ml_您本周应阅读的有趣的AI / ML文章(8月15日)
  • chime-4 lstm_CHIME-6挑战赛回顾
  • 文本文件加密和解密_解密文本见解和相关业务用例
  • 有关糖尿病模型建立的论文_预测糖尿病结果的模型比较
  • chi-squared检验_每位数据科学家都必须具备Chi-S方检验统计量:客户流失中的案例研究
  • 深度学习:在图像上找到手势_使用深度学习的人类情绪和手势检测器:第2部分

量子计算 qiskit_将Tensorflow和Qiskit集成到量子机器学习中相关推荐

  1. 谷歌迈出量子计算开源第一步,推出首个量子机器学习库TensorFlow Quantum

    点击上方"AI遇见机器学习",选择"星标"公众号 重磅干货,第一时间送达 乾明 十三 发自 凹非寺 量子位 报道 | 公众号 QbitAI 刚刚,谷歌在量子计算 ...

  2. 施尧耘:量子计算终将实现;段路明:大规模量子计算还任重道远

    [新智元导读]上周六,清华大学"人工智能前沿与产业趋势"系列讲座的第四讲开讲.本讲将由阿里云量子技术首席量子科学家施尧耘亲临现场,与清华大学海峡研究院大数据AI中心专家委员.百度七 ...

  3. AI公开课:18.05.05 施尧耘(阿里云量子技术CS)—清华AI第四讲之《人工智能与量子计算》Quantum课堂笔记——带你了解量子计算

    AI公开课:18.05.05 施尧耘(阿里云量子技术CS)-清华AI第四讲之<人工智能与量子计算>Quantum课堂笔记--带你了解量子计算 导读 清华大学"人工智能前沿与产业趋 ...

  4. IBM量子计算新突破:成功构建50个量子比特原型机

    本文来自AI新媒体量子位(QbitAI) IBM去年开始以云计算服务的形式提供量子计算能力.当时,IBM发布了包含5个量子比特的计算机.在短短18个月之后,IBM周五宣布,将发布包含20个量子比特的计 ...

  5. 量子计算更适用于优化:专访首家量子计算上市公司IonQ创始人 克里斯·门罗

    ​ IonQ创始人兼首席科学家克里斯·门罗(Chris Monroe) 从更准确的天气预报到更快的药物开发,量子计算机的未来令人兴奋.但在此过程中,我们必须解决一些问题. 美国首家量子计算上市公司Io ...

  6. 谷歌量子计算登上Nature封面,首次实现量子优越性,里程碑式突破

    这是量子计算领域的里程碑事件:谷歌在被称为「量子优越性」方向上的重大突破研究,登上了<自然>杂志 150 周年版的封面. 它或许标志着量子计算正在走向实用化:谷歌已经利用一台 54 量子比 ...

  7. 走进量子计算的大门——使用量桨PaddleQuantum创建单量子比特门

    使用量桨PaddleQuantum创建单量子比特门 一.量子计算概述 量子计算机为什么能同时存储0和1? 如何测量量子计算的结果 量子计算背后的哲学原理 二.量子计算的数学基础 1.量子比特 2.量子 ...

  8. 【产业互联网周报】三家量子计算初创企业宣布融资,华为公开量子密钥相关专利;钉钉高调押注低代码,腾讯云低码平台开启公测...

    关注ITValue,看企业级最新鲜.最价值报道! 谷歌超导量子计算机 |图 [产业互联网周报是由钛媒体TMTpost发布的特色产品,将整合本周最重要的企业级服务.云计算.大数据领域的前沿趋势.重磅政策 ...

  9. 玻色量子创始人COO马寅出席首届量子计算产业峰会,算力升级迫切呼唤量子计算

    ​8月21日,第一届CCF量子计算大会暨首届量子计算产业峰会在合肥成功召开.本次峰会由中国计算机学会(China Computer Federation,CCF)主办,CCF量子计算专业组.安徽省量子 ...

最新文章

  1. Nature会议:驾驭植物微生物组(21年10月22-24,在线,优惠截止9月24日)
  2. 2015 年 Git@OSC 新增热门开源软件项目 Top 50
  3. USACO翻译:USACO 2012 JAN三题(3)
  4. string类的实现终极版
  5. Maven中scope依赖范围和依赖的传递性
  6. ccform 单据打印的规则调整与新增功能发布说明
  7. linux svn同步到本地目录,LINUX中SVN服务的搭建与实现SVN 自动同步到web目录,SVN自动启动...
  8. 3.15 排列对称串
  9. 数据暑假实习面试_面试数据科学实习如何准备
  10. 如何用阿里云实行全链路数据追踪
  11. IAR执行到断点处不能单步运行解决方法
  12. WebApi系列(从.Net FrameWork 到 .Net Core)
  13. mysql删除重复记录只保留一条
  14. 北理乐学大学计算机实验4,北理工乐学上机实验五
  15. 数据分析 超市条码_超市小程序做得比较好的功能点是什么?
  16. fms2.0视频服务器系统,[FMS]adobe FMS(flash media server )服务器安装过程
  17. 如何解决移动硬盘弹出后还在转的问题
  18. 戴文渊 李一男 李三琦
  19. matplotlib 绘制柱状图且上方显示数据
  20. 配置 Spring Batch 批处理失败重试机制

热门文章

  1. MQ产品比较-ActiveMQ-RocketMQ
  2. Golang实现web api接口调用及web数据抓取[get post模式]
  3. pyCharm运行python提示“please select a valid interpreter”
  4. Linq中的group by多表多字段,Sum求和
  5. 高性能 TCP UDP 通信框架 HP-Socket v3.2.3
  6. 用HTTP的PUT方式发送请求
  7. android制作相册浏览器_电脑上用什么软件做电子相册
  8. sql另一个安装程序实例已在运行_SQL 经典实例
  9. 计算机系统结构树形流程图,计算机系统结构 第七章自考练习题答案
  10. 计算机的前端总线又称为,《计算机组成原理》复习资料