黑马程序员之交通灯管理系统

JAVA交通信号灯大作业(源码+报告+视频演示) 此资料包含上交的JAVA课程大作业源码+报告+视频演示,具体大作业为交通信号灯。 阅读详情

------- android培训、java培训、期待与您交流! ----------

由于路只有12个方向,所以需要12个方向的灯来分别控制每一条路:
南北灯(直行),南西灯(左转),南东灯(右转)
北南灯(直行),北东灯(左转),北西灯(右转)
东西灯(直行), 东南灯(左转),东北灯(右转)
西东灯(直行), 西北灯(左转), 西南灯(右转)

1,Road类
   Road类有两个成员变量,一个是路名name,一个是车辆集合vehicles
   在Road类的构造方法中,利用线程实现随机增加车辆的方法,并且启动定时器,随时判断能够通过路口。
2,Lamp类
   利用枚举实现Lamp类,因为路只有12个方向,所以Lamp类的对象只有12个,分别对应12条路。
   Lamp类的构造方法,要传入3个参数,分别为对面的灯opposite,下一个要变绿的灯next,还有一个用于判断当前灯红绿的变量lighted。
   Lamp类要有判断当前灯是绿还是红的方法isLighted
   Lamp类要有设置当前和对面灯为绿灯的方法light
   Lamp类要有设置当前和对象灯为红灯的方法lightOut,并且设为红灯后,要把下一个要变绿的灯next变为绿灯,并且把下一个变绿灯的对面的灯也设置为绿灯。
3,LampController类
   LampController类是控制系统,控制多长时间变绿或者变红,所以LampController类要有一个定时器进行定时,固定时间使得不同方向的灯交替变绿

学习心得:通过这个小系统,应该学会面向对象的设计方法,即谁拥有数据,谁就对外提供操作这些数据的方法。

典型案例:
    ①人在黑板上画圆,可以抽象为几个对象:人,黑板,圆?那么画圆的动作是哪个对象的方法?画圆需要圆心和半径,那么圆心和半径是谁的数据?是圆,所以画圆的方法应该由圆来提供。
    ②列车司机紧急刹车:有两个对象列车和司机,刹车的方法是谁提供?很明显是列车,因为列车拥有速度、发动机等数据。
    ③售票员正在统计售货小票的金额:统计金额的方法由售货小票提供。人只是调用了售货小票的方法。
    ④人把门关上了:关门的方法由门提供。人只是调用了门的关门方法。
    ⑤路上有很多汽车,路上还要增加新的汽车,还要随时减少汽车:减少汽车的方法由谁提供?由路提供。
    ⑥两块石头磨成一把石刀,石刀可以砍树,砍成木材,木材做成椅子:对象:石头,石刀,树,木材,椅子。石头可以磨成石刀,那么是石头要提供方法把自己变成石刀?错,把自己变成刀,自己都没了。石头并没有石刀的属性,所以不能提供变成石刀的方法。所以定义一个石刀加工厂,KnifeFactory提供生成石刀的方法。石刀又有砍树的方法,返回木材。同理,椅子加工厂chairFactory提供方法,把木材变成椅子。
    ⑦球从一根绳子的一端移到了另一端:两个对象:小球、绳子。绳子的本质是为球的移动提供了方向,提供球要滚动到哪一点,所以绳子要提供一个方法nextPoint,返回小球要移动的下一个点。小球的构造方法中,把开始的点和绳子对象传给小球,小球还有移动的方法,调用绳子的方法nextPoint。

 交通灯的源代码:

Lamp类:

package traffic;

public enum Lamp {
	//南北,南西,东西,东南
	S2N("N2S","S2W",false),S2W("N2E","E2W",false),E2W("W2E","E2S",false),E2S("W2N","S2N",false),
	N2S(null,null,false),N2E(null,null,false),W2E(null,null,false),W2N(null,null,false),
	S2E(null,null,true),E2N(null,null,true),N2W(null,null,true),W2S(null,null,true);
	
	private boolean lighted;//存储每个Lamp对象中的亮黑状态
	private String opposite;//对面的灯
	private String next;//下一个要变绿的灯
	
//	private Lamp(){}
	
	private Lamp(String opposite,String next,boolean lighted){
		System.out.println("对面的灯:"+opposite+" 下一个绿灯:"+next+" 亮灭:"+lighted);
		this.opposite = opposite;
		this.lighted = lighted;
		this.next = next;
	}
	
	//现在的灯是不是亮的
	public boolean isLighted(){
		System.out.println(toString()+"是否是绿灯:"+lighted);
		return lighted;
	}
	//亮灯,绿灯
	public void light(){
		this.lighted=true;
		System.out.println(toString() + " lamp is green.下面有6个方向的车通过");
		//不进行判断会死循环
		if(opposite != null){
			//获取对面的灯的对象,使其也变亮
			Lamp.valueOf(opposite).light();
		}
	}
	//把当前灯变为红灯,并返回要变绿的灯
	public Lamp lightOut(){
		this.lighted =false;
		if(opposite!=null){
			Lamp.valueOf(opposite).lightOut();
		}
		Lamp nextlamp = null;
		if(next!=null){
			nextlamp=Lamp.valueOf(next);
			nextlamp.light();
			System.out.println("绿灯从"+ name()+"---->切换为"+ next);
		}
		return nextlamp;
	}
}


灯控制器:LampController

package traffic;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class LampController {

	private Lamp currentLamp;
	public LampController(){
		currentLamp = Lamp.S2N;//最初的绿灯为南北方向
		currentLamp.light();
		//每隔10秒当前灯变黑
		ScheduledExecutorService timer= Executors.newScheduledThreadPool(1);
		timer.scheduleAtFixedRate(
				new Runnable(){
					public void run() {
						System.out.println(currentLamp+"即将变为红灯");
						currentLamp = currentLamp.lightOut();
					}
					
				}, 
				10, 
				10, 
				TimeUnit.SECONDS);
	}

}

路:Road

package traffic;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class Road {
	//每个Road对象都有一个name成员变量来代表方向,有一个vehicles成员变量来代表方向上的车辆集合
	private List<String> vehicles = new ArrayList<String>();	
	private String name = null;
	
	public Road(String name){
		this.name = name;
		//jdk1.5的线程库Executors
		ExecutorService pool = Executors.newSingleThreadExecutor();
		//在Road对象的构造方法中启动一个线程每隔一个随机的时间向vehicles集合中增加一辆车
		//Runalbe是接口不能直接new,所以这里new了个接口实现类的对象
		pool.execute(new Runnable(){
			public void run() {
				for(int i= 1;i<1000;i++){
					try {
						//产生1-10之间的随机整数
						Thread.sleep((new Random().nextInt(10)+1)*1000);
						System.out.println(Road.this.name+"线程到底是个什么东西");
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
					//内部类想要访问外部类的局部变量,外部类的局部变量要加上final修饰
					//这里也可以访问外部类的成员变量来实现
					//访问外部类的成员变量本来可以直接写外部类的成员变量名,
					//但是如果这个变量与自己类里的变量名冲突了,要加上类名.this.变量名
					vehicles.add(Road.this.name + "_" + i);
					System.out.println("牌照为"+Road.this.name + "_" + i + "的车来了");
				}
				
			}
			
		});
		
		//在Road对象的构造方法中启动一个定时器,每隔一秒检查该方向上的灯是否为绿,是则将集合中的第一辆车移除掉
		ScheduledExecutorService  timer = Executors.newScheduledThreadPool(1);
		timer.scheduleAtFixedRate(
				new Runnable(){

					public void run() {
						if(vehicles.size() > 0){
							boolean lighted = Lamp.valueOf(Road.this.name).isLighted();
							//布尔型的变量直接用,不用和true去比较了lighted==true
							if(lighted){
								System.out.println(vehicles.remove(0)+"开走了!");
							}
						}
					}
					
				}, 
				1, 
				1, 
				TimeUnit.SECONDS);

	}
}


主程序:

package traffic;

public class MainClass {

	public static void main(String[] args) {
		//创建12条路的对象
		String[] directions = new String[]{
				"S2N","S2W","E2W","E2S","N2S","N2E","W2E","W2N","S2E","E2N","N2W","W2S"
		};
		for(int i=0;i<directions.length;i++){
			new Road(directions[i]);
		}
		//创建控制器对象
		new LampController(); 
		
	}

}



 

excel 利用SUBTOTAL函数计算筛选后数列总和、均值、最大、最小值 表里有三个人,咱们需要筛选出三个人,并分别计算他们的总和值。 先看一下数据范围(A1:B27) 通过筛选找张三。 按照上图所示输入函数,选择9,求和。 然后按照函数输入即可。 就能计算出结果。 筛选项选择王五,就会自动计算王五的总和。 筛选到李四就会自动计算李四的总和。 如果把9改成1,就是自动计算筛选出来的均值结果,如下图所示。 如果改成4就是取筛选项的最大值,选择5就是取最小值。 ... 阅读详情

相关推荐

【飞腾平台安装windows arm 11系统】

本文提供国内的百度网盘链接供下载使用:链接: https://pan.baidu.com/s/1_cftVdoX40k0M6zVTmFq8Q?3)快速迁移虚拟机技巧:如果是迁移已经安装好的虚拟机的使用场景,除了导出镜像外,也可直接复制安装好虚拟机的整个文件夹到指定的存储目录,选定好其中的任意qcow2文件后即可快速启动。可在飞腾软件平台点击网盘链接获取对应系统的deb包(麒麟和统信)以及phyvirt·app,下载地址:https://www.phytium.com.cn/developer/

firefly_cv的博客 8924

sumo之模拟十字路口转弯

文章介绍了使用sumo仿真十字路口转弯的方法,最后通过例子实现进行仿真。

weixin_43797015的博客 3488

MPC-CBF 控制原理详解

假设系统满足如下离散时间动力学模型xt1fxtutxt∈Xut∈Uxt1​fxt​ut​xt​∈Xut​∈Uxtx_txt​:状态变量,定义域为可行状态集X⊆RnX⊆Rnutu_tut​:控制输入,定义域为控制约束集U⊆RmU⊆Rm系统需满足安全约束,由如下控制障碍函数(CBF)hX→RhX→RCx∈X∣hx≥0C:=x∈X∣hx≥。

m0_54691290的博客 1178

黑马程序员--交通灯管理系统(二十)

---------------------- ASP.Net+Android+IOS开发、.Net培训、期待与您交流! ----------------------    一、需求分析 交通灯管理系统 模拟实现十字路口的交通灯管理系统逻辑,具体需求如下: 异步随机生成按照各个路线行驶的车辆。 例如: 由南向而来去往北向的车辆 ---- 直行车辆 由西向而来去往南向的车辆

u013117140的专栏 497

IP白名单校验

支持格式: 1、127.0.0.1 // 指定固定IP 2、127.0.0.1-127.0.0.128 // 可使用“-”来表示一个IP区间,支持跨IP段(一般不会出现这种情况,跨IP段则配置多个规则) 3、127.0.* // 2~4位IP段可...

2199

从DC到DCG:手把手教你搭建物理感知综合流程(含DEF文件处理避坑指南)

本文详细介绍了从Design Compiler(DC)过渡到DC Topographical(DCT)和DC Graphical(DCG)的完整操作框架,特别针对DEF文件处理提供避坑方案。通过环境准备、工具升级、DEF文件处理、DCG综合配置等步骤,帮助开发者高效应对28nm以下工艺节点的物理感知综合挑战,显著提升时序收敛效率。

weixin_27966471的博客 377

黑马程序员——交通灯管理系统

------- android培训、java培训、期待与您交流! ----------   该“交通灯管理系统”,实现起来比较复杂,为了变量理解,这里分章节讲解。由浅入深,先分析项目的需求,其次分析项目中涉及到的面向对象原理,最后一步步通过代码实现该系统。为了便于阅读,博客前面加入了目录。 1. 交通灯管理系统项目需求 模拟十字路口的交通灯管理系统逻辑,具体需求如下 1. 异步

LanceDream的专栏 840

无线图像传输新突破:深度JSCC算法在低带宽环境下的性能实测

本文深入探讨了基于深度学习的信源信道联合编码(JSCC)算法在低带宽无线图像传输中的突破性表现。通过实测数据对比,深度JSCC在低信噪比环境下展现出卓越的鲁棒性,有效对抗传统方案的“悬崖效应”,实现图像质量的平滑下降,为远程医疗、工业巡检等严苛场景提供了新的解决方案。

weixin_29090089的博客 504

黑马程序员 交通灯管理系统

---------------------- ASP.Net+Unity开发、.Net培训、期待与您交流! ---------------------- 交通灯管理系统 模拟一个狮子路口的交通灯管理系统,逻辑,具体需求如下: 异步随机生成按照各个路线行驶的车辆。信号灯忽略黄灯,只考虑红灯和绿灯。应考虑左转车辆控制信号灯,右转车辆不受信号等控制。具体信号灯控制逻辑与现实生活中普通交通灯

FengLu369的专栏 676

rk3399 hdmi HDCP key烧录

1.key转换 使用 hdcp\ProvisioningTool_20170526\KeyConverterV2.02 目录下的KeyConvertor.exe工具将1.4key进行转换 转换后得到 TX00000001.skf 文件,将 TX00000001.skf 文件烧录到开发板上,烧录方式: 打开文件 hdcp\ProvisioningTool_20170526\ProvisioningTool20170526\ProvisioningTool.exe 选择烧录方式与烧录路...

qq_32645109的博客 3856

主题035:计算流体力学(CFD)

计算流体力学(Computational Fluid Dynamics, CFD)是利用数值方法求解流体流动、传热传质等问题的学科。CFD已成为化学反应工程中反应器设计和优化的重要工具。∂ρ∂t+∇⋅(ρu)=0 \frac{\partial \rho}{\partial t} + \nabla \cdot (\rho \mathbf{u}) = 0 ∂t∂ρ​+∇⋅(ρu)=0对于不可压缩流动:∇⋅u=0 \nabla \cdot \mathbf{u} = 0 ∇⋅u=0动量方程:∂(ρu)∂t+∇⋅(ρ

kkchenjj的博客 266

黑马程序员 — 交通灯管理系统

交通灯管理系统

INT_INIT的专栏 831

K8s(二十一):在 Kubernetes 集群中部署 MySQL8.0 高可用集群(1主2从)

🔴 K8s(二十一):在 Kubernetes 集群中部署 MySQL8.0 高可用集群(1主2从)

✨ 欢迎来到【Seal ^_^ 的优快云博客】!✨ 3万+

黑马程序员——————交通灯管理系统

------- android培训、java培训、期待与您交流! ---------- 模拟实现十字路口的交通灯管理系统逻辑,具体需求如下:   Ø        异步随机生成按照各个路线行驶的车辆。 例如:        由南向而来去往北向的车辆 ---- 直行车辆        由西向而来去往南向的车辆 ---- 右转车辆        由东向而来去往南向的车辆 ---- 左

u010408616的专栏 543

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

黑马程序员_交通灯管理系统

 交通灯管理系统

黑马程序员_安卓的专栏 522

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

黑马程序员 交通灯管理系统

-----------android培训、java培训、java学习型技术博客、期待与您交流! ----------- 交通灯管理系统 前提: 现假设交通灯系统只有红灯和绿灯,忽略黄灯。 随机产生车辆,绿灯时,每隔一秒,路上的车行驶过去。 思路 1,定义路灯: 十字路口车辆运行方向有12个,其中4个右拐可以认为一直是绿灯,其它8个两两对应。 因此只需要对S2N(南向北),S

541

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

黑马程序员:交通灯管理系统

----------- android培训、java培训、java学习型技术博客、期待与您交流! ------------ 面向对象设计把握一个重要的经验:谁拥有数据,谁就对外提供操作这些数据的方法。 本项目中用到的新知识: 1,JDK1.5使用线程的新方法——线程池 线程池的基本思想是一种对象池的思想,开辟一块内存空间,里面存放了众多(未死亡)的线程,池中线程执行调度由池管理器来

伊斯之深の生死簿 1067

【黑马程序员】交通灯管理系统

------- android培训、java培训、期待与您交流! ---------- I一、需求分析 1,模拟实现十字路口的交通灯管理系统逻辑,异步随机生成按照各个路线行驶的车辆。 例如:        由南向而来去往北向的车辆 ---- 直行车辆        由西向而来去往南向的车辆 ---- 右转车辆        由东向而来去往南向的车辆 ---- 左

u010036063的专栏 777
上一篇: 学习笔记之枚举
下一篇: 黑马程序员之银行业务调度系统
wangpanbaoding
博客等级 码龄18年 42粉丝 122原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值