首页 > 其他分享 >Quanutm machine learning demos from pennylane

Quanutm machine learning demos from pennylane

时间:2024-05-29 22:01:31浏览次数:14  
标签:opt pennylane machine demos state params qml learning import

Qubit rotation

Using qubit rotation example to understand basic syntax of pennylane, gradient descent. See this link for more details.

import pennylane as qml
from jax import numpy as np
import jax
import jaxopt

dev1 = qml.device("lightning.qubit",wires=1)

@qml.qnode(dev1)
def circuit(params):
    qml.RX(params[0], wires=0)
    qml.RY(params[1], wires=0)
    return qml.expval(qml.PauliZ(0))


# how the gradiat is calculated?
dcircuit = jax.grad(circuit, argnums=0)

def cost(x):
    return circuit(x)

init_params = np.array([0.011, 0.012])

opt = jaxopt.GradientDescent(cost, stepsize=1, acceleration=False)

steps = 100
params = init_params
opt_state = opt.init_state(params)
for i in range(steps):
    params, opt_state = opt.update(params, opt_state)
    if (i + 1) % 5 == 0:
        print("Cost after step {:5d}: {: .7f}".format(i + 1, cost(params)))
print("Optimized rotation angles: {}".format(params))

标签:opt,pennylane,machine,demos,state,params,qml,learning,import
From: https://www.cnblogs.com/nana22/p/18221189

相关文章

  • Learning Transferable Visual Models From Natural Language Supervision
    郑重声明:原文参见标题,如有侵权,请联系作者,将会撤销发布!Proceedingsofthe38thInternationalConferenceonMachineLearning,PMLR139,2021.  Abstract 1.IntroductionandMotivatingWork 2.Approach 2.1.CreatingaSufficientlyLargeDataset ......
  • Deep Models Under the GAN: Information Leakage from Collaborative Deep Learning
    最近要看一些推理攻击的内容,把看过的都放过来吧DeepModelsUndertheGAN:InformationLeakagefromCollaborativeDeepLearningGAN下的深度模型:协作深度学习的信息泄漏ACMCCS2017文章目录一、论文信息1.题目2.作者3.期刊年限4.关键词二、背景三、创新......
  • Learning Model Predictive Control for Iterative Tasks. A Data-Driven Control Fra
    LearningModelPredictiveControlforIterativeTasks.AData-DrivenControlFramework一句话MPC:在每个采用点处,根据被控对象的状态和预测模型,预测系统在未来一段时间内的状态,依据某一性能指标(成本函数)来求解最优的一组控制序列,并将这组控制序列的第一个控制作用作为输出......
  • Towards Universal Sequence Representation Learning for Recommender Systems
    目录概符号说明UniSRec统一的文本表示统一的序列表示Parameter-EfficientFine-tuning代码HouY.,MuS.,ZhaoW.X.,LiY.,DingB.andWenJ.TowardsUniversalSequenceRepresentationLearningforRecommenderSystems.KDD,2022.概本文提出了一个用text替代ID......
  • POSEIDON: Privacy-Preserving Federated NeuralNetwork Learning
    写在最前面,感觉这一篇的技术更贴近于密码学,所以部分核心技术读起来比较吃力。仅供大家参考哇~Abstract—Inthispaper,weaddresstheproblemofprivacypreservingtrainingandevaluationofneuralnetworksinanN-party,federatedlearningsetting.Weproposea......
  • MachineUnlearn 的一种方法
    MachineUnlearnMethod半白盒攻击LLMunlearning[1][2]可以视为RLHF的替代方案,用于消除LLM的幻觉,删除受版权保护的内容等,也可以视为事后防御策略,用于防止JailBreak在Eraser:JailbreakingDefense[2:1]文章中,作者直观地认为同一个问题的多个答案应当有相似之处......
  • LGMRec Local and Global Graph Learning for Multimodal Recommendation
    目录概符号说明MotivationLGMRecLocalGraphEmbeddingGlobalGraphEmbeddingFusion代码GuoZ.,LiJ.,LiG.,WangC.,ShiS.andRuanB.LGMRec:Localandglobalgraphlearningformultimodalrecommendation.AAAI,2024.概本文采用分解的方法进行对ID和模态信......
  • git_learning
    Git常用的是以下6个命令:gitclone、gitpush、gitadd 、gitcommit、gitcheckout、gitpull.workspace:工作区stagingarea:暂存区/缓存区localrepository:版本库或本地仓库remoterepository:远程仓库......
  • InfoTS: 具有信息感知增强的时间序列对比学习《Time Series Contrastive Learning wit
    现在是2024年5月23日,14:30,开始看论文。论文:TimeSeriesContrastiveLearningwithInformation-AwareAugmentations或者是:Timeseriescontrastivelearningwithinformation-awareaugmentationsGitHub:https://github.com/chengw07/InfoTSAAAI2023的论文。 摘要近年......
  • Survey on Large Language Model-Enhanced Reinforcement Learning: Concept, Taxonom
    发表时间:2024文章要点:文章对LLM增强强化学习(LLM-enhancedRL)的现有文献进行了总结。在agent-environment交互的范式下,讨论LLM对RL算法的帮助。文章先给出LLM-enhancedRL的概念:themethodsthatutilizethemulti-modalinformationprocessing,generating,reasoning,etc.......