Python3 学习笔记4_运算符_20180223

【电力负荷预测】项目介绍 MATLAB实现基于BO-Transformer-LSTM贝叶斯优化算法(BO)优化Transformer-LSTM组合模型进行居民用户多步电力负荷预测(含模型描述及部分示例 内容概要:本文介绍了一个基于BO-Transformer-LSTM的组合模型,用于实现居民用户多步电力负荷预测的完整项目实例。该模型融合Transformer的全局注意力机制与LSTM的局部时序记忆能力,构建能够捕捉长时依赖与周期性特征的深度学习架构,并引入贝叶斯优化(BO)自动搜索最优超参数组合,提升预测精度与训练效率。项目涵盖从原始数据清洗、特征工程、滑动窗口样本构建、模型设计到超参数优化、反归一化及多步误差评估的全流程,强调时间顺序划分以防止信息泄露,并通过周期编码、外生变量融合等方式增强数据表达能力。文中提供了详细的MATLAB代码示例,包括数据预处理、网络搭建、贝叶斯优化配置和预测结果评估等关键步骤。 适合人群:具备一定机器学习和时间序列分析基础,熟悉MATLAB编程环境,从事电力系统预测、智能电网、负荷管理等相关领域的研究人员、工程师及研究生。 使用场景及目标:①应用于居民级或多用户聚合负荷的短期至中期多步预测(如未来24小时);②服务于配电系统运行调度、需求响应基线设定、家庭能源管理系统优化、分布式能源协调控制等实际工程场景;③为科研提供可复现的深度学习+贝叶斯优化的技术路线参考。 阅读建议:此资源以实际项目为导向,建议读者结合提供的代码逐步实现并调试模型,重点关注数据质量控制、时间特征编码、组合网络结构设计与贝叶斯优化稳定性之间的协同关系,在实践中深入理解多步预测中的误差累积机制与超参数敏感性问题。 立即下载
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 学习网站:www.runoob.com

#****************************************************
#                   Python3 运算符                 *
#****************************************************
'''
python支持以下类型的运算符:算术运算符、比较(关系)运算符、赋值运算符
逻辑运算符、位运算符、成员运算符、身份运算符、运算符优先级。
'''
#============
# 算术运算符
#============
# +(加)、-(减)、*(乘)、/(除)、//(整除)、%(模)、**(幂)

#============
# 比较运算符
#============
# ==(等于)、!=(不等于)、>(大于)、<(小于)、>=(大于等于)、<=(小于等于)

#============
# 赋值运算符
#============
# =(正常赋值)、+=(加法赋值)、-=(减法赋值)、*=(乘法赋值)、/=(除法赋值)、
# %=(取模赋值)、**=(幂赋值)、//=(取整除赋值)

#============
# 位运算符
#============
# &(按位与)、|(按位或)、^(按位异或)、~(按位取反)、<<(按位左移)、
# >>(按位右移) 

#============
# 逻辑运算符
#============
'''
 x and y: 布尔“与” - 如果x,y同时为True,则返回True,否则返回False
 x or y: 布尔“或” - 如果x,y同时为False,则返回False,反正返回True
 not x: 布尔“非” - 如果x为True,返回False。如果x为False,返回True
'''

#============
# 成员运算符
#============
# in - 如果在指定的序列中找到值返回True,否则返回False
# not in - 如果在指定的序列中没有找到值返回True,否则返回False
x = 1; y = 20
l_tmp = [1, 2, 3, 4, 5]

print ( x in l_tmp )            # True
print ( x not in l_tmp )        # False
print ( y in l_tmp )            # False
print ( y not in l_tmp )        # True
print ("--------------------分割线------------------")

#============
# 身份运算符
#============
# 身份运算符用于比较两个对象的存储单元
# is - 判断两个标识符是不是引用自一个对象,是则True,否则False.
# not is - 判断两个标识符是不是引用自不同对象,不是则True,否则False.
x = 20; y = 20
print ( x is y )                # True
print ( id(x) == id(y) )        # True 
# id()函数用于获取对象内存地址
y = 30
print ( x is y )                # False
print ( id(x) == id(y) )        # False
print ("--------------------分割线------------------")
# is 与 == 区别:http://blog.youkuaiyun.com/metears/article/details/79353357

#============
# 运算符优先级
#============
'''
运算符             描述
**                  指数 (最高优先级)
~ + -              按位翻转, 一元加号和减号(最后两个的方法名为+@和-@)
* / % //            乘,除,取模和取整除
+ -                 加法减法
>> <<               右移,左移运算符
&                   位 'AND'
^ |                 位运算符
<= < > >=           比较运算符
<> == !=            等于运算符
= %= /= //= -= += *= **=    赋值运算符
is is not           身份运算符
in not in           成员运算符
not or and          逻辑运算符
'''

#============
# 数字表示方式
#============
'''
2 进制是以 0b 开头的: 例如: 0b11 则表示十进制的 3
8 进制是以 0o 开头的: 例如: 0o11 则表示十进制的 9
16 进制是以 0x 开头的: 例如: 0x11 则表示十进制的 17

分别使用 bin,oct,hex 可输出数字的二进制,八进制,十六进制形式
'''
a = 0b111100
print ( a, bin(a) )             # 60 0b111100
print ( oct(a), hex(a) )        # 0o74 0x3c
国央企创新负责人如何通过平台实现科研成果的快速识别与转化?.docx 科易网基于AI模型+行业大数据,在技术转移、成果转化、技术经纪、知识产权、产业创新、科技招商等垂直领域的多样化应用场景,推出科技创新领域的AI+工具与数智化解决方案,推动科技创新与产业创新智能化发展。 立即下载

相关推荐

PotPlayer自用皮肤

自用 PotPlayer 皮肤,仅微调了字体大小与颜色,是按个人习惯调整,未做适配性调整。

Python|运算符

本文是笔者在学习李立宗老师的课程后的笔记整理,希望能帮助到有需要的人,侵删。

LEOnpy1的博客 862

2-shell及常用命令-续.pdf

2-shell及常用命令-续.pdf

Python3 学习笔记6_字符串_20180224

#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 学习网站:www.runoob.com #**************************************************** # Python3 字符串 * #*************************...

BugLiu 502

ROS探索篇(一)在Gazebo中实现移动机器人仿真与环境搭建

$x+y=z$

weixin_52029211的博客 4621

保姆级教程:手把手带你玩转英飞凌TC397开发板的板载资源(CAN FD、LCD、SD卡)

本文提供英飞凌TC397开发板的全面开发指南,涵盖CAN FD通信、LCD显示、SD卡文件系统和以太网通信等核心功能。通过详细的代码示例和硬件连接说明,帮助开发者快速上手并充分利用开发板的丰富资源,实现高效嵌入式系统开发。

weixin_33726313的博客 241

Python3 学习笔记20_函数式编程-高阶函数-map/reduce_20180312

#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 学习网站:www.liaoxuefeng.com #**************************************************** # Python3 函数式编程-高阶函数-map/reduce * #************************...

BugLiu 436

APO的全面进化之路(2):走向IBP、建设端到端供应链计划体系

前一篇记录阐述了在供应链计划(Supply Chain Planning)领域里SAP的关键产品APO的不断进化之路,即部分产品从APO进化到S/4HANA,本篇将继续阐述进化之路上的另一大中坚产品力量SAP-IBP(Integrated Business Planning)。作为SAP数字化供应链(Digital Supply Chain)中供应链计划SCP的左膀右臂,S/4HANA与IBP共同完善了计划域的完整闭环。本篇作为收尾,在先谈对IBP产品的个人认知之前,特别是在当今这个IT产品迭代多、技术革新

ChampaignWolf的专栏 5229

Python3 学习笔记5_数字(Number)_20180223

#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 学习网站:www.runoob.com #**************************************************** # Python3 数字(Number) * #***********************...

BugLiu 418

Windows11下QGIS 3.34.4安装Geo-SAM插件全流程(附RTX3060 CUDA12.0配置技巧)

本文详细介绍了在Windows 11系统中为QGIS 3.34.4安装和配置Geo-SAM插件的完整流程,特别针对RTX 3060显卡用户提供了CUDA 12.0与PyTorch环境的精准搭建方案。通过预编码与交互式分割两大核心步骤,该插件能显著提升遥感图像半自动标注的效率,降低硬件门槛,是地理信息处理领域融合AI技术的实用指南。

weixin_29089057的博客 296

SAP ERP销售应收&成本科目确定

ERP作为业财一体软件,其中最核心的就是业务与财务模块的自动集成,无需财务进行手工做账,提高工作效率的同时降低人工操作产生的误差。今天浅浅的分享一下SD模块生成会计凭证时,借贷项确定的系统配置。一般项目上借贷项、科目都有FICO提供,但是具体的集成配置是在SD这边。

weixin_43657667的博客 1569

Python3 学习笔记8_元组_20180227

#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 学习网站:www.runoob.com #**************************************************** # Python3 元组 * #*************************...

BugLiu 386

MAX30102心率血氧传感器原理图设计,已量产(e-Health传感器)

在最近的便携健康监测设备项目中,我们采用了集成算法的 MAX30102 心率血氧模块 —— 这类带内置 MCU 算法的传感器能直接输出心率 / 血氧数值,大幅降低了主控资源占用。但硬件电路的稳定性直接决定了 PPG 信号的采集精度,下面结合实际项目里的原理图,拆解下这个模块的设计细节。

不脱发的程序猿 1278

Python3 学习笔记14_递归函数_20180305

#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 学习网站:www.liaoxuefeng.com #**************************************************** # Python3 函数 * #************************...

BugLiu 376

3.2 直流无刷电机(BLDC):状态空间模型与传递函数

状态空间模型和传递函数是分析BLDC电机动态特性的重要工具。状态空间模型通过微分方程描述系统内部状态与输入输出关系,适用于多变量系统分析;传递函数则在频域表征系统特性,便于控制器设计。本文详细推导了三相坐标系和dq坐标系下的BLDC电机状态空间模型,讨论了线性化方法,并介绍了从状态空间模型到传递函数的转换过程。这些模型为BLDC电机的控制系统设计提供了理论基础。

技术工作者 244

2、探索谷歌云平台(GCP):入门指南

本文全面介绍了谷歌云平台(GCP)的入门知识,涵盖其全球基础设施、核心服务和使用方法。内容包括GCP区域与可用区结构、创建免费账户、配置计算资源(如GCE虚拟机)、存储类型(PD、Filestore、GCS)、网络架构(VPC)、组织与项目管理、身份访问控制(IAM),以及计算、存储、数据库、大数据和人工智能等各类云服务。文章还提供了资源规划、安全管理和成本控制等实用建议,帮助用户快速上手并高效利用GCP构建可扩展的云解决方案。

uber9的博客 255

Python3 学习笔记21_函数式编程-高阶函数-filter/sorted_20180312

#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 学习网站:www.liaoxuefeng.com #**************************************************** # Python3 函数式编程-高阶函数-filter/sorted * #*************************...

BugLiu 337

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

Python3 学习笔记13_函数的参数_20180305

#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 学习网站:www.liaoxuefeng.com #**************************************************** # Python3 函数 * #************************...

BugLiu 336

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain&#39;s apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath(&#39;DeepLearnToolbox&#39;));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand(&#39;state&#39;,0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W&#39;); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand(&#39;state&#39;,0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = &#39;sigm&#39;;%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, &#39;Too big error&#39;);```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand(&#39;state&#39;,0)sae = saesetup([784 100]);sae.ae{1}.activation_function = &#39;sigm&#39;;sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)&#39;)% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;;nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, &#39;Too big error&#39;);```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x&#39;,28,28,60000))/255;test_x = double(reshape(test_x&#39;,28,28,10000))/255;train_y = double(train_y&#39;);test_y = double(test_y&#39;);%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you&#39;ll get around 1.2% errorrand(&#39;state&#39;,0)cnn.layers = { struct(&#39;type&#39;, &#39;i&#39;) %input layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 6, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %sub sampling layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 12, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, &#39;Too big error&#39;);```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, &#39;Too big error&#39;);%% ex2 neural net with L2 weight decayrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex3 neural net with dropoutrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex4 neural net with sigmoid activation functionrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex5 plotting functionalityrand(&#39;state&#39;,0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = &#39;softmax&#39;; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand(&#39;state&#39;,0)nn = nnsetup([784 20 10]); nn.output = &#39;softmax&#39;; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Python3 学习笔记23_函数式编程-匿名函数_20180314

#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 学习网站:www.liaoxuefeng.com #**************************************************** # Python3 函数式编程-匿名函数 * #************************...

BugLiu 333

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

Python3 学习笔记11_条件语句_20180301

#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 学习网站:www.runoob.com #**************************************************** # Python3 循环语句 * #*************************...

BugLiu 331

Python3 学习笔记9_字典_20180228

#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 学习网站:www.runoob.com #**************************************************** # Python3 字典 * #*************************...

BugLiu 322

Python3 学习笔记1_基础语法_20180209

#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 学习网站:www.runoob.com #**************************************************** # Python3 教程 * #*********************...

BugLiu 321

Python3 学习笔记10_条件语句_20180228

#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 学习网站:www.runoob.com #**************************************************** # Python3 条件语句 * #*************************...

BugLiu 320

Python3 学习笔记25_函数式编程-偏函数_20180315

#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 学习网站:www.liaoxuefeng.com #**************************************************** # Python3 函数式编程-偏函数 * #************************...

BugLiu 315

Python3 学习笔记3_基本数据类型_20180222

#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 学习网站:www.runoob.com #**************************************************** # Python3 基本数据类型 * #***************************...

BugLiu 314
上一篇: Python中is和==的区别
下一篇: Python3 学习笔记5_数字(Number)_20180223
metears
博客等级 码龄19年 15粉丝 33原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值