Codeforces Round #337 (Div. 2) ABCDE

Facebook Hacker Cup 2015 Round 1 解题报告 Homework         求一个区间[A,B]中素因数个数为K的数有多少个。做法是dp。对每个数i,找到它的某一个素因数d,i的结果就由i/d推得。找的方法是修改筛法。 #include #include #include #include #include #include #include #include #include using namespace 阅读详情

A Pasha and Stick

        简单分类讨论。

#include <bits/stdc++.h>

using namespace std;

#define ll long long

int main(){
	int n;
	cin>>n;
	if(n&1){
		cout<<0<<endl;
	}else{
		n>>=1;
		if(n&1){
			cout<<n/2<<endl;
		}else{
			cout<<n/2-1<<endl;
		}
	}
	return 0;	
}

B Vika and Squares

        贪心。就是找最小值之间的最大距离,我实现的时候把数组copy了一份放在后面,这样处理比较简单。

#include <bits/stdc++.h>


using namespace std;

#define ll long long

int a[400010];

int main(){
	int n;
	cin>>n;
	
	int MIN=1e9+10;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		MIN=min(MIN,a[i]);
	}
	
	for(int i=1;i<=n;i++){
		a[i+n]=a[i];
	}
	
	int pre=1;
	int len=0;
	for(int i=1;i<=n*2;i++){
		if(a[i]==MIN){
			len=max(len,i-pre-1);
			pre=i;
		}
	}
	
	ll ans = (ll)n*MIN+len;
	
	cout<<ans<<endl;
	
	return 0;	
}

C Harmony Analysis

        构造题。首先k=1很容易构造出来。k=x+1其实是由4个k=x构成的,用4个k=x拼起来后,把其中一个取反即可。

#include <bits/stdc++.h>


using namespace std;

#define ll long long

int a[1111][1111];

int main(){
	
	int k;
	cin>>k;
	
	int n = 1<<k;
	
	a[1][1]=1;
	a[1][2]=1;
	a[2][1]=1;
	a[2][2]=0;
	
	for(int i=2;i<=9;i++){
		int half = 1<<(i-1);
		for(int j=1;j<=half;j++){
			for(int kk=1;kk<=half;kk++){
				a[j][kk+half]=!a[j][kk];
			}
		}
		//
		for(int j=1;j<=half;j++){
			for(int kk=1;kk<=half;kk++){
				a[j+half][kk]=a[j][kk];
			}
		}
		//
		for(int j=1;j<=half;j++){
			for(int kk=1;kk<=half;kk++){
				a[j+half][kk+half]=a[j][kk];
			}
		}
	}
	
	
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(a[i][j]){
				printf("+");
			}else{
				printf("*");
			}
		}cout<<endl;
	}

	return 0;	
}

D Vika and Segments

        这种题一看就知道是用map乱搞。大体思路是分开横向和纵向,先计算横向的,然后对于每个纵向的,看它穿过了多少个横向的,减去重叠部分即可。

        一步一步来,首先是要把横向和纵向分开,同向的里面也有重叠的,把重叠的合并。然后简单计算一下所有横向的结果。计算完后,从左到右处理纵向的。对于枚举的每个纵向条条,维护有哪些横向的条条的横坐标包含了纵向条条的横坐标(我利用了map和priority_queue维护,具体见代码),然后利用树状数组(当然,事先离散化了Y坐标)计算它穿越了多少横向条条,把重叠部分减去即可。

#include <bits/stdc++.h>


using namespace std;

#define ll long long

int n;

struct hor{
	int x1,x2;
	int y;
	bool ban;
	bool operator<(const hor& other)const{
		if(y!=other.y){
			return y<other.y;
		}
		if(x1!=other.x1){
			return x1<other.x1;
		}
		return x2<other.x2;
	}
}hors[100010];

bool cmpx1(hor a,hor b){
	return a.x1<b.x1;
}

struct cmpx2{	//比较下x2 
	bool operator()(hor a,hor b){
		return a.x2 > b.x2;
	}
};


struct ver{
	int y1,y2;
	int x;
	bool ban;
	bool operator<(const ver& other)const{
		if(x!=other.x){
			return x<other.x;
		}
		if(y1!=other.y1){
			return y1<other.y1;
		}
		return y2<other.y2;
	}
}vers[100010];

int hcnt=0;
int vcnt=0;

map<int,int> ymp;	//用于离散化 

int c[200010];
inline int lowbit(const int &x){
	return x&(-x);
}

void update(int x,int val){
	while(x<200010){
		c[x]+=val;
		x+=lowbit(x);
	}
}

int query(int x){

	int ans = 0;
	while(x){
		ans+=c[x];
		x-=lowbit(x);
	}
	return ans;
}

int main(){
	
	
	cin>>n;
	
	for(int i=1;i<=n;i++){
		int x1,y1,x2,y2;
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		if(x1>x2)swap(x1,x2);
		if(y1>y2)swap(y1,y2);
		
		if(x1==x2){
			vers[vcnt].y1=y1;
			vers[vcnt].y2=y2;
			vers[vcnt].x =x1;
			vcnt++;
		}else{
			hors[hcnt].x1=x1;
			hors[hcnt].x2=x2;
			hors[hcnt].y =y1;
			hcnt++;
		}
		ymp[y1]=0;
		ymp[y2]=0;
	}
	sort(vers,vers+vcnt);
	sort(hors,hors+hcnt);
	
	//离散化
	int kk = 1;
	for(map<int,int>::iterator it = ymp.begin();it!=ymp.end();it++){
		it->second = kk++;
	} 
	
	//同向的合并 
	for(int i=1;i<vcnt;i++){
		if(vers[i].x == vers[i-1].x){
			if(vers[i].y1<=vers[i-1].y2){
				vers[i].y1 = vers[i-1].y1;
				vers[i].y2 = max(vers[i].y2,vers[i-1].y2);
				vers[i-1].ban=1;
			}
		}
	}
	for(int i=1;i<hcnt;i++){
		if(hors[i].y == hors[i-1].y){
			if(hors[i].x1<=hors[i-1].x2){
				hors[i].x1 = hors[i-1].x1;
				hors[i].x2 = max(hors[i].x2,hors[i-1].x2);
				hors[i-1].ban=1;
			}
		}
	}
	
	ll ans = 0;
	
	//计算横向 
	for(int i=0;i<hcnt;i++){
		if(!hors[i].ban){
			ans+=hors[i].x2-hors[i].x1+1;	
		}
	}
	
	//处理纵向 
	sort(hors,hors+hcnt,cmpx1);
	priority_queue<hor,vector<hor>,cmpx2> que;
	int k=0;
	for(int i=0;i<vcnt;i++){
		if(vers[i].ban)continue;
		//左边界符合的加入 
		while(hors[k].x1 <= vers[i].x && k < hcnt){
			if(!hors[k].ban){
				update( ymp[hors[k].y],1);
				que.push(hors[k]);
			}
			k++;
		}
		
		//右边界不符合的移除 
		while(que.size()){
			hor tmp = que.top();
			if(tmp.x2 < vers[i].x){
				que.pop();
				update( ymp[tmp.y],-1);
			}else{
				break;
			}
		}

		int q1 = query( ymp[vers[i].y1] - 1);
		int q2 = query( ymp[vers[i].y2] );
		ans+=(vers[i].y2 - vers[i].y1 + 1);
		ans-=(q2-q1);
		
	}
	
	cout<<ans<<endl;
	
	return 0;	
}


E Alphabet Permutations

        线段树。线段树维护的是每个位置的字符,以及区间上,字符x紧接着字符y的次数(最多10*10组x,y)。对于每次询问,相当于得到了一个“字典序”,在线段树中查询,共有多少组相邻的字符xy,x的字典序小于y,记为sum,答案就是n-sum。因为n-repeat肯定是满足的,出现一次上述情况,可以省去一次。

#include <bits/stdc++.h>


using namespace std;

int n,m,k;
char str[200010];


struct node{
	int l,r;
	int ch;
	int lazy;
	int val[10][10];
}tree[800010];



void push_up(int x){
	if(tree[x].l==tree[x].r)return;
	node& lson = tree[x<<1];
	node& rson = tree[(x<<1)|1];
	for(int i=0;i<k;i++){
		for(int j=0;j<k;j++){
			tree[x].val[i][j] = lson.val[i][j]+rson.val[i][j];
		}
	}
}

int queryCh(int x,int pos){
	if(~tree[x].lazy){
		return tree[x].lazy;
	}
	if(tree[x].l==tree[x].r){
		return tree[x].ch;
	}
	int mid = (tree[x].l+tree[x].r)>>1;
	if(pos<=mid){
		return queryCh(x<<1,pos);
	}else{
		return queryCh((x<<1)|1,pos);
	}
}

void push_down(int x,int ch){
	if(tree[x].l == tree[x].r){
		tree[x].lazy = -1;
		return;
	}
	node& lson = tree[x<<1];
	node& rson = tree[(x<<1)|1];
	lson.lazy = rson.lazy = tree[x].lazy;
	tree[x].lazy = -1;
	lson.ch = tree[x].ch;
	rson.ch = tree[x].ch;
	for(int i=0;i<k;i++){
		for(int j=0;j<k;j++){
			lson.val[i][j] = 0;
			rson.val[i][j] = 0;
		}
	}
}

void updateVal(int x,int pos){
	if(tree[x].l==tree[x].r){
		if(tree[x].l){
			memset(tree[x].val,0,sizeof(tree[x].val));
			int left = queryCh(1,tree[x].l-1);
			int ch = queryCh(1,tree[x].l);
			if(left!=ch){
				tree[x].val[left][ch] = 1;
			}
		}
		return;
	}
	if(~tree[x].lazy){
		push_down(x,tree[x].lazy);
	}
	int mid = (tree[x].l+tree[x].r)>>1;
	if(pos<=mid){
		updateVal(x<<1,pos);
	}else{
		updateVal((x<<1)|1,pos);
	}
	push_up(x);
}

void build_tree(int x,int l,int r){
	tree[x].l = l;
	tree[x].r = r;
	tree[x].lazy = -1;
	if(l==r){
		if(l)tree[x].val[str[l-1]-'a'][str[l]-'a'] = 1;
		tree[x].ch = str[l]-'a';
		return;
	}
	int mid = (l+r)>>1;
	build_tree(x<<1,l,mid);
	build_tree((x<<1)|1,mid+1,r);
	push_up(x);
}



void update(int x,int l,int r,int ch){
	if(l==tree[x].l && r==tree[x].r){
		tree[x].lazy = ch;
		tree[x].ch = ch;
		memset(tree[x].val,0,sizeof(tree[x].val));
		return;
	}
	if(~tree[x].lazy){
		push_down(x,tree[x].lazy);
	}
	int mid = (tree[x].l+tree[x].r)>>1;
	if(mid>=r){
		update(x<<1,l,r,ch);
	}else{
		if(mid<l){
			update((x<<1)|1,l,r,ch);
		}else{
			update(x<<1,l,mid,ch);
			update((x<<1)|1,mid+1,r,ch);
		}
	}
	push_up(x);
}


int ans[11][11];
void query(int x,int l,int r){
	if(l==tree[x].l && r==tree[x].r){
		for(int i=0;i<k;i++){
			for(int j=0;j<k;j++){
				ans[i][j] += tree[x].val[i][j];
			}
		}
		return;
	}
	if(~tree[x].lazy){
		push_down(x,tree[x].ch);
	}
	int mid = (tree[x].l+tree[x].r)>>1;
	if(mid>=r){
		query(x<<1,l,r);
	}else{
		if(mid<l){
			query((x<<1)|1,l,r);
		}else{
			query(x<<1,l,mid);
			query((x<<1)|1,mid+1,r);
		}
	}
}

void Q(int l,int r){
	memset(ans,0,sizeof(ans));
	query(1,l,r);
}

int main(){
	
	cin>>n>>m>>k;
	scanf("%s",str);
	build_tree(1,0,n-1);
	
	while(m--){
		int op;
		scanf("%d",&op);
		if(op==1){	//update
			int l,r;
			char chs[2];
			scanf("%d%d%s",&l,&r,chs);
			update(1,l-1,r-1,chs[0]-'a');
			if(l-1)updateVal(1,l-1);
			updateVal(1,r);
		}else{		//query
			char per[11];
			scanf("%s",per);
			Q(0,n-1);
			
			bool tmp[11][11] = {0};
			for(int i=0;i<k;i++){
				for(int j=i+1;j<k;j++){
					tmp[per[i]-'a'][per[j]-'a']=1;
				}
			}
			int res = n;
			for(int i=0;i<k;i++){
				for(int j=0;j<k;j++){
					if(tmp[i][j]){
						res-=ans[i][j];
					}
				}
			}
			cout<<res<<endl;
		}
	}
	return 0;
}

基于MATLAB的太阳能光伏电力仿真,模拟每日太阳能发电,可视化功率曲线,并通过数值积分计算总能量输出。.zip 1.版本:matlab2014a/2019b/2024b 2.附赠案例数据可直接运行。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。 立即下载

相关推荐

【电力负荷预测】项目介绍 MATLAB实现基于BO-Transformer-LSTM贝叶斯优化算法(BO)优化Transformer-LSTM组合模型进行居民用户多步电力负荷预测(含模型描述及部分示例

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

Codeforces VK Cup 2016 - Round 1 (Div. 2 Edition)

A. Bear and Reverse Radewoosh  按要求计算一下即可。#include <bits/stdc++.h>#define ll long longusing namespace std;int p[111]; int t[111];int main(){ int n,c; cin>>n>>c; for(int i=1;i<=n;i++){

A Cube Master 2万+

国央企创新负责人如何通过平台实现科研成果的快速识别与转化?.docx

科易网基于AI模型+行业大数据,在技术转移、成果转化、技术经纪、知识产权、产业创新、科技招商等垂直领域的多样化应用场景,推出科技创新领域的AI+工具与数智化解决方案,推动科技创新与产业创新智能化发展。

河南省第七届ACM大学生程序设计竞赛 解题报告

这两天把去年省赛的题挂到了OJ上,顺便练手。 A.物资调度 DP,类似01背包。dp(i,j)表示情况数,第一维表示考察到第i种物资,第二维表示总数量为j。显然,如果按照题目给的数据范围,答案会超出64位整型的范围,但是题目并没有要求取模,只能说数据太弱。 B.海岛争霸 Floyd算法,稍微修改一下状态转移方程就可以了。Floyd是求和,这题是取最大。 C.机器人

A Cube Master 3360

PotPlayer自用皮肤

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

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

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

Google Code Jam 2015 Round 1A 解题报告

太弱了,比赛时只出了A的大数据和BC小数据,排到1700+。赛后才把B的小数据过了。 A. Mushroom Monster         就是贪心模拟。第一种吃法,只有当前时刻比10秒前少才去吃减少的量,否则不吃。第二种吃法,计算每十秒的减少量,以减少量最大的作为平均速率去吃。 #include using namespace std; int m[10010];

A Cube Master 2409

别再瞎选了!手把手教你根据车型等级,在CarSim里快速匹配最合适的动力学模型

本文详细介绍了如何在CarSim中根据车型等级快速匹配最合适的动力学模型,提升仿真效率。通过分析CarSim模型库与A/B/C/D级车标准的对应关系,提供四步精准定位方法和不同车型的特殊处理技巧,帮助工程师避免常见错误,显著缩短模型准备时间。

weixin_27015733的博客 262

2015 百度之星初赛1 解题报告

1001 超级赛亚ACMer         贪心。首先击败战斗力不大于m的最强者,每次去找可以增强战斗力,然后能击败的最强者,把自己战斗力增加到和他一样去打。如果能打败最强的对手,就可以了。 1002 找连续数         离散化,离线按k从1~1000递增的顺序,维护以每个位置为起点长度为k的最小值,最大值,以及是否有相同数。如果MAX-MIN=k-1且没有相同数,长度为k的

A Cube Master 1794

GoldenDB 兼容模式冲突场景解析:MySQL 连接模式 vs Oracle 语法兼容

GoldenDB 兼容模式冲突场景解析:MySQL 连接模式 vs Oracle 语法兼容

weixin_45207751的博客 2250

保姆级教程 | MS构建三层石墨后转成LAMMPS的data文件

喜欢的话记得一键三连~

baguette的博客 2951

2015 ICPC 长春网赛 解题报告

只A了几道水题,还好晋级了。 07 The Water Problem         果然是水题,随便模拟一下就好了。为了题解完整性贴出来。 #include #include #include #include #include #include using namespace std; int a[1010]; int main(){

A Cube Master 1463

ArcGIS:根据DEM数据提取区域水系

利用DEM数据提取区域水系是常见的水文分析应用,为了获取区域的矢量水系数据,我们可以通过ArcGIS对高程DEM数据进行水文分析,为地表水流建立模型,进而获取到该地的水系数据,DEM数据精度越高,获取到的水系数据精度也就越高。以下介绍如何用ArcGIS提供的工具提取水系。

Oruizn的博客 9109

福州大学第十二届程序设计竞赛 解题报告

由于这个OJ比较蛋疼,比赛时提交的代码看不到,所以就不附代码了,只说思路。 A 非提的救赎         待补。 B 完美的数字         求一个区间内,所有数的“完美度”的和,完美度定义为数i能分解为多少组i=A*A*B(A         预处理算出每个数的平方、立方。写一个函数fun(x)计算区间1~x的结果,题目的答案就是fun(b)-fun(a-1)。在

A Cube Master 1429

器件物理与工艺:揭秘MOSFET寄生电容Cgd/Cgs的微观结构及演变

本文深入解析MOSFET寄生电容Cgd与Cgs的微观物理结构及其在开关过程中的非线性演变,重点探讨由Cgd反馈效应引发的米勒平台现象。通过分析器件物理机制与先进工艺技术,揭示电容特性对开关性能的影响,并提供工艺优化与设计策略,助力提升高频功率应用的效率与稳定性。

desk3的博客 1083

RK3568平台开发系列讲解:UBOOT详细介绍

U-boot是一款广泛使用的开源引导加载程序,支持多种嵌入式操作系统和处理器架构。其主要功能包括系统上电时的硬件初始化、引导操作系统内核等。U-boot的引导流程通常包括Boot Code、idbloader.img、uboot.img、boot.img和rootfs.img等步骤。启动U-boot时,通过Debug串口连接板卡,按下ctrl+c键可进入U-Boot命令行模式。U-boot启动过程中会执行一系列初始化操作,如打印系统信息、初始化内存、加载内核设备树、初始化I2C、PMIC电源芯片、DRM框架

内核笔记 808

Google Code jam Qualification Round 2015 解题报告

Problem A. Standing Ovation         题目说的是有许多观众,每个观众有一定的羞涩值,只有现场站起来鼓掌的人数达到该值才会站起来鼓掌,问最少添加多少羞涩值任意的人,才能使所有人都站起来鼓掌。         贪心模拟一下就好,添加的人默认让他们羞涩值为0,扫一遍,让加到刚好够就行。 #include #include #include #includ

A Cube Master 1343

Plecs standalone 4.9.5最新版本,赶紧来下载使用吧,需要做并网逆变器及光伏储能变换器的朋友赶紧下载起来

PLECS 4.9.5较4.7.1版实现全面升级:采用自适应求解器切换技术,支持多核CPU/GPU加速,仿真速度提升30-50%;新增模型引用功能,实现模块化设计;强化光伏/风电等新能源组件,支持多物理场耦合分析;优化代码生成功能,兼容多种硬件平台和FMU导入。新版特别适用于复杂电力电子系统、多域联合仿真及硬件在环测试项目,但对硬件配置要求更高。基础教学项目仍可使用4.7.1版本。建议用户根据项目复杂度选择升级方案。

2430

Codeforces Round #291 (Div. 2) 解题报告 (A B C D)

A Chewbaсca and Number         贪心,每一位取t和9-t中较小的。注意首位不能为0。 #include #include #include #include #include #include #include #include #include #include using namespace

A Cube Master 1178

⭐️【2024年新版教程】vmware tools安装步骤(Windows、Linux、MacOS版本)

VMware Tools是VMware提供的一套实用工具,它可以增强虚拟机与宿主机之间的交互性能,如改进显示性能、优化鼠标和键盘性能、提供时间同步功能等。无论是在Windows、Linux还是MacOS虚拟机上,安装VMware Tools都可以提高虚拟机的使用体验。以上就是在不同操作系统上安装VMware Tools的步骤,希望对您有所帮助。

Python老吕的博客 6万+

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

2012 ACM-ICPC 杭州站解题报告(4道签到题)

hdu 4461 The Power of Xiangqi         题意:

A Cube Master 1153

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

Codeforces Round #301 (Div. 2) 解题报告(ABCD)

A Combination Lock         n位0~9密码锁两种状态之间,问最少拨多少次。注意可能越过'0'。直接上代码。。 #include using namespace std; char num1[1010]; char num2[1010]; int main(){ int n; cin>>n; cin>>num1>>num2; int ans=0;

A Cube Master 1096

深度学习工具包 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")

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

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

Codeforces Round #273 (Div. 2) 解题报告 (A B C D)

A. Initial Bet

A Cube Master 1047

Codeforces Bubble Cup 8 - Finals [Online Mirror] 解题报告

D Tablecity         从一头往另一头扫一遍,再逆着回来就好了。因为贼每走一步,横坐标的奇偶性都会改变。 #include #include #include #include using namespace std; int i; int main(){ printf("2000\n"); for (i=1;i<=1000;i++) printf("%d 1

A Cube Master 996

ACdream区域赛指导赛之手速赛系列(5) 解题报告 A C D

problem A

A Cube Master 975

Codeforces Round #281 (Div. 2) 解题报告(A B C D)

这场比赛真是大起大落。。比的时候一度排在rank1,以为从此达到人生巅峰了,结果最后B,C都FST了,都是因为很2的错误,B为了偷懒,居然把数加到string里比较字典序。C漏一个"=",而且有语句写错了位置。         CF题的难度,好像有变水的趋势。。以前前3题没算法,现在前4题都没有,而且还没编程复杂度。。 A. Vasya and Football

A Cube Master 912
上一篇: 第40届ICPC EC-final 总结
下一篇: 2015.12 hdu 校赛简易题解
squee_spoon
博客等级 码龄14年 61粉丝 455原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值