【牛客】OJ在线编程常见输入输出练习 C++

python-ACM模式输入输出 【代码】python-ACM模式输入输出。 阅读详情

刚开始接触ACM吃过的亏😭😭😭

OJ在线编程常见输入输出练习

在这里插入图片描述

ACM的时候才知道自己连基本的输入都难以搞定!!!耻辱柱定死了~~~😭😭😭

如果大家有更好的方法一定给我分享一下,我太菜了👤

题目

A+B(1)||A+B(2)||A+B(3)||A+B(4)||A+B(5)||A+B(6)||A+B(7)||字符串排序(1)||字符串排序(2)||字符串排序(3)

A+B(1)

链接:https://ac.nowcoder.com/acm/contest/5650/A
来源:牛客网

题目描述

计算a+b

输入描述:

输入包括两个正整数a,b(1 <= a, b <= 10^9),输入数据包括多组。

输出描述:

输出a+b的结果

示例1

输入

1 5
10 20

输出

6
30

代码

#include <iostream>
#include <vector>
using namespace std;
int main() {
	vector<int> a;
	int ta;
	cin >> ta;
	while (cin) {
		a.push_back(ta);
		cin >> ta;
	}
	for (int i = 0; i < a.size(); i+=2)
		cout << a[i] + a[i+1] << endl;
	return 0;
}

A+B(2)

链接:https://ac.nowcoder.com/acm/contest/5650/B
来源:牛客网

题目描述

计算a+b

输入描述:

输入第一行包括一个数据组数t(1 <= t <= 100)
接下来每行包括两个正整数a,b(1 <= a, b <= 10^9)

输出描述:

输出a+b的结果

示例1

输入

2
1 5
10 20

输出

6
30

代码

#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int t;
	cin >> t;
	vector<int> nums;
	while (t-- && cin) {
		int a,b;
		cin >> a >> b;
		nums.push_back(a+b);
	}
	for (auto it : nums)
		cout << it << endl;
	system("pause");
	return 0;
}

A+B(3)

链接:https://ac.nowcoder.com/acm/contest/5650/C
来源:牛客网

题目描述

计算a+b

输入描述:

输入包括两个正整数a,b(1 <= a, b <= 10^9),输入数据有多组, 如果输入为0 0则结束输入

输出描述:

输出a+b的结果

示例1

输入

1 5
10 20
0 0

输出

6
30

代码

#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	vector<int> nums;
	while (cin && a != 0 && b != 0) {
		nums.push_back(a + b);
		cin >> a >> b;
	}
	for (auto it : nums)
		cout << it << endl;
	system("pause");
	return 0;
}

A+B(4)

链接:https://ac.nowcoder.com/acm/contest/5650/D
来源:牛客网

题目描述

计算一系列数的和

输入描述:

输入数据包括多组。
每组数据一行,每行的第一个整数为整数的个数n(1 <= n <= 100), n为0的时候结束输入。
接下来n个正整数,即需要求和的每个正整数。

输出描述:

每组数据输出求和的结果

示例1

输入

4 1 2 3 4
5 1 2 3 4 5
0

输出

10
15

代码

#include <iostream>
#include <vector>
using namespace std;
int main()
{		
	vector<int> nums;
	int length;
	cin >> length;
	while (length != 0) {
		int ans = 0;
		for (int i = 0; i < length; ++i) {
				int temp;
				cin >> temp;
				ans += temp;
		}
		nums.push_back(ans);
		cin >> length;
	}
	for (auto it : nums)
			cout << it << endl;
	system("pause");
	return 0;
}

A+b(5)

链接:https://ac.nowcoder.com/acm/contest/5650/E
来源:牛客网

题目描述

计算一系列数的和

输入描述:

输入的第一行包括一个正整数t(1 <= t <= 100), 表示数据组数。
接下来t行, 每行一组数据。
每行的第一个整数为整数的个数n(1 <= n <= 100)。
接下来n个正整数, 即需要求和的每个正整数。

输出描述:

每组数据输出求和的结果

示例1

输入

2
4 1 2 3 4
5 1 2 3 4 5

输出

10
15

代码

#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int row;
	cin >> row;
	vector<int> res;
	while (row--) {
		int length = 0, ans = 0;
		cin >> length;
		for (int i = 0; i < length; ++i) {
			int temp = 0;
			cin >> temp;
			ans += temp;
		}
		res.push_back(ans);
	}
	for (auto i : res)
		cout << i << endl;
	system("pause");
	return 0;
}

A+B(6)

链接:https://ac.nowcoder.com/acm/contest/5650/F
来源:牛客网

题目描述

计算一系列数的和

输入描述:

输入数据有多组, 每行表示一组输入数据。
每行的第一个整数为整数的个数n(1 <= n <= 100)。
接下来n个正整数, 即需要求和的每个正整数。

输出描述:

每组数据输出求和的结果

示例1

输入

4 1 2 3 4
5 1 2 3 4 5

输出

10
15

代码

#include <iostream>
#include <vector>
using namespace std;
int main()
{
	vector<int> nums;
	int length;
	cin >> length;
	while (cin) {
		int ans = 0;
		for (int i = 0; i < length; ++i) {
			int temp;
			cin >> temp;
			ans += temp;
		}
		nums.push_back(ans);
		cin >> length;
	}
	for (auto it : nums)
		cout << it << endl;
	system("pause");
	return 0;
}

A+B(7)

链接:https://ac.nowcoder.com/acm/contest/5650/G
来源:牛客网

题目描述

计算一系列数的和

输入描述:

输入数据有多组, 每行表示一组输入数据。

每行不定有n个整数,空格隔开。(1 <= n <= 100)。

输出描述:

每组数据输出求和的结果

示例1

输入

1 2 3
4 5
0 0 0 0 0

输出

6
9
0

代码

#include <iostream>
#include <vector>
using namespace std;
int main()
{
	vector<int> sum;
	vector<vector<int>> res;
	while (!cin.eof()) {
		vector<int> nums;
		int ans = 0;
		int temp = 0;
		while(cin){
			cin >> temp;
			ans += temp;		
			//	nums.push_back(temp); //把结果保存在nums中
			if (getchar() == '\n') break;
		}
	//	res.push_back(nums); //把nums保存在res中
		sum.push_back(ans);
	}
	for (int i = 0; i < sum.size()-1; ++i)
		cout << sum[i] << endl;
	system("pause");
	return 0;
}

字符串排序(1)

链接:https://ac.nowcoder.com/acm/contest/5650/H
来源:牛客网

题目描述

对输入的字符串进行排序后输出

输入描述:

输入有两行,第一行n

第二行是n个空格隔开的字符串

输出描述:

输出一行排序后的字符串,空格隔开,无结尾空格

示例1

输入

5
c d a bb e

输出

a bb c d e

代码

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	vector<string> vstr;
	int length;
	cin >> length;
	for (int i = 0; i < length; ++i) {
		string str;
		cin >> str;
		vstr.push_back(str);
	}
	sort(vstr.begin(), vstr.end());
	for (auto it : vstr)
		cout << it << " ";


	system("pause");
	return 0;
}

字符串排序(2)

链接:https://ac.nowcoder.com/acm/contest/5650/I
来源:牛客网

题目描述

对输入的字符串进行排序后输出

输入描述:

多个测试用例,每个测试用例一行。

每行通过空格隔开,有n个字符,n<100

输出描述:

对于每组测试用例,输出一行排序过的字符串,每个字符串通过空格隔开

示例1

输入

a c bb
f dddd
nowcoder

输出

a bb c
dddd f
nowcode

代码

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	vector<vector<string> > res;
	while (!cin.eof()) {
		vector<string> vstr;
		while (cin) {
			string str;
			cin >> str;
			vstr.push_back(str);
			if (getchar() == '\n') {
				sort(vstr.begin(), vstr.end());
				break;
			}
		}
		res.push_back(vstr);
	}
	//输出
	for (int i = 0; i < res.size(); ++i) {
		cout << res[i][0];
		for (auto j = 1;j < res[i].size(); ++j)
			cout << " " << res[i][j];
		cout << endl;
	}
	system("pause");
	return 0;
}

字符串排序(3)

链接:https://ac.nowcoder.com/acm/contest/5650/J
来源:牛客网

题目描述

对输入的字符串进行排序后输出

输入描述:

多个测试用例,每个测试用例一行。
每行通过,隔开,有n个字符,n<100

输出描述:

对于每组用例输出一行排序后的字符串,用','隔开,无结尾空格

示例1

输入

a,c,bb
f,dddd
nowcoder

输出

a,bb,c
dddd,f
nowcoder

代码

#include<iostream>
#include<string>
#include<vector>
#include <sstream>
#include<algorithm>
using namespace std;

int main() {
    string s;
    vector<string> vec;
    while (cin >> s) {
        istringstream input(s);
        string t;
        while (getline(input, t, ','))
            vec.push_back(t);
        if (cin.get() == '\n') {
            sort(vec.begin(), vec.end());
            for (int i = 0; i < vec.size(); i++) {
                if (i) cout << "," << vec[i];
                else cout << vec[i];
            }
            cout << endl;
            vec.clear();
        }
    }
    
    return 0;
}
python3在线编程输入输出总结 目录A+B类型一:多组输入,组数未知类型二:多组输入,组数t已知类型三:多组输入,有终止条件类型四:多组输入,有终止条件,每行个数已知类别五:多组输入,有组数t,求一系列和类型六:多组输入,每行个数已知,一系列和类型六:多组输入,一系列和字符串排序类型一:一行字符串个数n,一行字符串类型二:多行字符串,空格分隔类型三:多行字符串,逗号分隔 A+B 类型一:多组输入,组数未知 输入:输入包括两个正整... 阅读详情

相关推荐

OJ在线编程常见输入输出练习

自测本地通过提交为0。

qq_51314662的博客 458

ACM模式,Python

在ACM模式,我们需要执行:1、读取输入数据,通过input()函数或sys.stdin.readline()来实现。2、处理输入数据,根据题目要求进行对数据的处理,例如进行排序、计算等操作。3、输出结果,通过print()函数或sys.stdout.write()来实现。

Kayla_Smith的博客 4036

C++ OJ在线编程常见输入输出技巧与示例

一直在leetcode上刷题,发现牛客上答题都需要自己解决输入问题。这里记一下遇到的一些方式。 纯记录,有点乱。 1.下面这个注意输入是负数 vector<int> s; string str; getline(cin, str); int temp = 0; for (int i = 0; i != str.size(); ++i) { if (isdigit(str[i])) { temp =temp* 10 + (str[i] - 48)

qq_41687938的博客 3649

python输入输出练习

https://ac.nowcoder.com/acm/contest/320#submit/{%22problemIdFilter%22%3A18204%2C%22statusTypeFilter%22%3A5%2C%22languageFilter%22%3A%2211%22}

qq_turn 3186

C++项目——负载均衡在线OJ系统

本项目旨在模仿牛客、力扣等在线OJ平台,通过前后端结合的方式,前端构建出一个在线OJ题目练习网页,通过读取远端数据库的方式构建出题库(题库包含文件版和MySQL版本两个版本),点击题目,可以跳转至代码输入页面,用户输入代码完毕,点击网页“运行”按钮,代码会交由后端CentOS 7云服务器,负载均衡地挑选主机进行编译运行代码,并将结果返回前端页面。构建出一个简易的负载均衡式的在线OJ系统。

m0_73682725的博客 5万+

牛客OJ在线编程常见输入输出练习(一)

计算a+b数据范围: 数据组数 1≤t≤100 , 数据大小满足 1≤t≤1000输入描述:输入包括两个正整数a,b(1 <= a, b <= 1000),输入数据包括多组。输出描述:输出a+b的结果示例1输入例子:1 510 20输出例子:630。

向北先生的博客 1585

C++ > 牛客OJ在线编程常见输入输出练习场

本文展示了C++处理各种输入输出场景的代码实现,包括A+B求和问题的7种变体(不同输入格式处理)和3种字符串排序问题。主要使用了iostream和sstream库,通过getline读取整行输入,配合istringstream进行解析。对于字符串排序,使用vector存储并调用sort函数。特别处理了逗号分隔的字符串分割问题。文章最后总结了C++输入输出的常用写法,包括头文件引入、命名空间使用、整行读取和字符串流创建等核心操作。这些代码片段涵盖了在线编程中常见的输入输出处理模式。

qq_33067925的博客 341

牛客C++笔试ACM模式输入输出练习

平时用力扣刷题,换成牛客这种需要打印输出结果对比判定的OJ不是很习惯,所以特别练习一下。尤其是对于8、9、10部分关于字符串的。”纸上得来终觉浅,绝知此事要躬行“

今天写代码了吗 5199

C++笔试面试常用IO (牛客OJ在线编程常见输入输出练习场)

【代码】C++常用IO (牛客OJ在线编程常见输入输出练习场)

m0_46215008的博客 1058

OJ在线编程常见输入输出练习场--牛客

题目描述 计算a+b 输入描述: 输入包括两个正整数a,b(1 <= a, b <= 10^9),输入数据包括多组。 输出描述: 输出a+b的结果 示例1 输入 1 5 10 20 输出 6 30 解答: #include<iostream> using namespace std; int main(){ int a, b; while(cin&...

qq_30182357的博客 2031

基于Codex/Claude Code的学术技能包:13个Skill实现科研全流程自动化

写论文最头疼的是什么?是面对海量文献无从下手,还是实验数据一团乱麻,或者是好不容易有了结果,却卡在写作和格式调整上?如果你也经历过从选题到投稿的完整科研周期,就会明白每个环节都可能消耗大量时间精力。今天要分享的这套工具链,正是为了解决这些痛点而生——基于 Codex 和 Claude Code 平台的学术技能包(Academic Skills),它通过 13 个精心设计的 Skill,将一篇论文从 0 到 1 的全流程自动化、标准化,让你能更专注于研究本身。 这套技能包并非单一工具,而是一个覆盖文献阅读、数

weixin_33979203的博客 541

在线编程常见输入输出练习

输入包括两个正整数a,b(1 <= a, b <= 10^9),输入数据有多组, 如果输入为0 0则结束输入。每组数据一行,每行的第一个整数为整数的个数n(1 <= n <= 100), n为0的时候结束输入。输入包括两个正整数a,b(1 <= a, b <= 1000),输入数据包括多组。输入的第一行包括一个正整数t(1 <= t <= 100), 表示数据组数。每行的第一个整数为整数的个数n(1 <= n <= 100)。每行的第一个整数为整数的个数n(1 <= n <= 100)。

weixin_48703074的博客 582

IC版图设计之OASIS文件格式详解

OASIS(Open Artwork System Interchange Standard)是继GDSII之后新一代的集成电路版图数据交换标准,由SEMI在2004年正式发布(SEMI标准号:SEMI P39)。高压缩率:相比GDSII可减少3-10倍文件体积扩展性强:支持纳米级工艺的复杂图形描述跨平台兼容:独立于EDA工具和操作系统安全增强:内置校验和与加密支持。

ZZcppc的博客 2440

牛客OJ笔试 C++ 输入输出

背景 最近以及春招做笔试的时候发现,很多公司都用牛客网作为在线编程的OJ,这里需要自己做输入输出。因为牛客判题使用的方式是:不管输入,只将你程序的输出,和正确答案进行对比,有点像文本比对,有一点不一样,就会是不通过。比如 输出结尾不能/必须有空格,空行,逗号等特殊要求。今天根据牛客官网给出的练习做一下C++的输入输出总结。 大家也可以去练下下~ 传送门:https://ac.nowcoder.com/acm/contest/5647 8-9-10是实战中经常用到的方式,比如输入数组,有多组,以逗号/空格分隔

haiki66的博客 9444

港口集装箱码头运营FlexSim仿真

列队4中的集装箱会根据不同类型的集装箱会放置在不同的堆场,因此根据前面对集装箱设置的标签Type的数值不同,设置不同的发送端口。集装箱到达列队3后,会有70%的集装箱到达堆场,30%的集装箱运出港口,因此在Queue列队3的Flow界面设置按照百分比发送端口,其中70%发送到端口1,即发送到列队4等待进入堆场,30%发送到端口2,即发送至出闸口。通过上述对比表格可以看出,当集卡数量在10的时候,岸桥和场桥的设备利用率达到了最高,当集卡数量为12的时候场桥1和场桥3的利用率有所下降,因此综合考虑。

m0_72514516的博客 1331

2011-2024年间各省数字普惠金融指数数据(覆盖广度、使用深度和数字化程度)

2、指标:数字金融普惠指数、数字金融覆盖广度指数、数字金融使用深度指数、普惠金融数字化程度指数、数字金融使用深度指数下属的支付、保险、货币基金、信用服务、投资、信贷等分类指数。中国各省的数字普惠金融指数数据,从数字金融覆盖广度、数字金融使用深度和普惠金融数字化程度3个维度来构建数字普惠金融指标体系。数字普惠金融指数一共3个维度、33项具体指标。全套指数包含数字金融覆盖广度指数、数字金融使用深度指数和普惠金融数字化程度指数,以及数字金融使用深度指数下属的支付、保险、货币基金、信用服务、投资、信贷等分类指数。

【优快云】 1万+

牛客网OJ在线编程输入输出练习十一题(C++版)

写在前面 经常在牛客做笔试题,关于输入输出的问题如果总是耽误工夫,则会大大影响考试进度,因而我打算把输入输出的问题专门搞一搞,于是发现了牛客网的专门练习输入输出的练习场,链接如下请点击 牛客网OJ在线编程常见输入输出练习场 就可以开开心心练习了~ 以下是我写的C++版本的题解,可供参考: 牛客网输入输出练习题写在前面第一题:计算多组a+b第二题:告知多少组,计算多组a+b第三题:如果a、b都不为0,计算多组a+b第四题:计算一系列数的和(第一个数为0时结束)第五题:计算一系列数的和(告知一共有几组)第六题:

weixin_41983309的博客 7509

ResNet改进(50):SKConv和CBAM增强的ResNet模型

动态调整感受野大小- 结合通道和空间注意力模型的核心思想是在ResNet的每个残差块后插入这些注意力模块,使网络能够自适应地关注更重要的特征。模型的核心是类,它在标准ResNet34的基础上:替换了初始卷积层,使用更小的核(3×3)和步长(1)在每个残差块后选择性添加SKConv和CBAM模块# 加载预训练ResNet34# 自定义初始层# 添加注意力机制的残差层通过集成SKConv和CBAM,这个改进的ResNet模型能够更有效地捕捉多尺度特征并关注关键信息区域。

2401_82355416的博客 621

牛客 | OJ在线编程常见输入输出练习

专项练习https://www.nowcoder.com/exam/intelligent?公司真题:https://www.nowcoder.com/exam/company?言归正传,本张试卷总共包括18个题目,包括了笔试情况下的各种输入输出。13.多组_带空格的字符串_T组形式。17.单组_spj判断浮点误差。3.多组_A+B_EOF形式。7.多组_一维数组_T组形式。9.多组_二维数组_T组形式。11.多组_字符串_T组形式。4.多组_A+B_T组形式。5.多组_A+B_零尾模式。

yatingliu的博客 999

【2026年华为暑期实习/秋招(AI)-8月5日-第一题- 选择题】(题目+思路+Java&C++&Python解析+在线测试)

摘要: 本文包含20道选择题,涵盖深度学习、数值计算、概率统计、线性代数及机器学习等领域。重点考察了Softmax的数值稳定性实现(减去最大值)、视觉问答任务(图像+问题→答案)、分层强化学习的奖惩计算、欧氏距离与余弦相似度、反向传播梯度计算、SVD降维存储优化、贝叶斯概率推断、插值多项式等。此外,涉及逻辑回归评价指标(不含MSE)、端侧推理内存因素(中间激活)、集中趋势度量(均值)、Householder变换性质、早期停止正则化、梯度矩阵秩与优化、在线学习特性及大模型训练技巧(如学习率预热、梯度裁剪)等知

m0_73659489的博客 191

算法 | A*算法实现最优路径规划

启发式探索是利用问题拥有的启发信息来引导搜索,达到减少探索范围、降低问题复杂度的目的。A*寻路算法是启发式探索的一个典型实践,在寻路搜索的过程中,给每个节点绑定了一个估计值(即启发式),在对节点的遍历过程中采取估计值优先原则,估计值更优的节点会被优先遍历。...

不断学习,不断进步,提高自己 6630

C++ 输入输出函数总结及 OJ 在线编程常见输入输出练习

文章目录C++ 输入std::operator>>std::getlinestd::istream::getlinestd::istream::getstd::istream::ignore总结牛客 OJ 输入输出练习A+B(1)A+B(2)A+B(3)A+B(4)A+B(5)A+B(6)A+B(7)字符串排序(1)字符串排序(2)字符串排序(3)自测本地通过提交为0 C++ 输入 std::operator>> #include <iostream> #include

一个博客 1511

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

OJ —— Online Judge

OJ介绍、OJ网站推荐

Edward2022的博客 7830

深度学习工具包 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'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('DeepLearnToolbox'));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('state',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'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',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 = 'sigm';%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, 'Too big error');```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('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';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)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';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, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% 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'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 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, 'Too big error');```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('state',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, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',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, 'Too big error');%% ex3 neural net with dropoutrand('state',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, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % 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, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % 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, 'Too big error');%% 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('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % 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, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

OJ ACM模式常见输入输出代码(牛客练习)

点击跳转:牛客输入输出练习场 1.输入不定行,每行2个整数 输入描述: 输入包括两个正整数a,b(1 <= a, b <= 10^9),输入数据包括多组。 输出描述: 输出a+b的结果 示例: 输入: 1 5 10 20 输出: 6 30 #include<iostream> using namespace std; int main(){ int a,b; while(cin >> a >> b){

mbytes的博客 3871

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

上一篇: 【数据结构】单链表(基础)
下一篇: 【前端】HTML和Markdown设置下换线
欧恩意
博客等级 码龄7年 677粉丝 138原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

欧恩意

如有帮助,感谢打赏!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值