学习笔记(05-01):轻松搞定Spring全家桶(初识篇)-面向切片编程AOP:使用Spring通知类型创建Spring AOP

一文学会Spring,Spring最简单的入门教程(万字好文) spring教程 阅读详情

一、使用环绕通知(MethodInterceptor)做日志管理:
在目标方法执行的前后均有需要自动执行的操作,可应用于日志、事务管理

  1. 创建项目,导入jar包:学习笔记(04)系列中的jar包外加AOP的jar包。所导入的jar
  2. ( 使用jdk动态代理的方式)创建一个接口:/AOPProject/src/com/aop/UserDao.java
package com.aop;

public interface UserDao {
	public void addUser(String id, String name);
}
  1. 创建接口的实现类:/AOPProject/src/com/aop/UserDaoImpl.java
package com.aop;

public class UserDaoImpl implements UserDao {

	@Override
	public void addUser(String id, String name) {
		// TODO Auto-generated method stub
		System.out.println("======="+name+"的id是"+id);
	}

}
  1. 创建一个切面类:/AOPProject/src/com/aop/LogAspect.java
package com.aop;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

public class LogAspect implements MethodInterceptor {

	@Override
	public Object invoke(MethodInvocation arg0) throws Throwable {
		// TODO Auto-generated method stub
		//通过arg0可以获取目标对象的类和方法
		System.out.println(arg0.getMethod());
		//执行正常逻辑之前输出的内容,假装这就是日志
		System.out.println("----------环绕通知开始---");
		//执行逻辑
		//启动目标方法执行
		Object object = arg0.proceed();
		
		//执行逻辑后输出的内容
		System.out.println("----------环绕通知结束---");
		return object;
	}

}
  1. 进行配置:/AOPProject/resource/applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
	 http://www.springframework.org/schema/beans/spring-beans-4.3.xsd">
	 <!-- target object -->
	 <bean id="userDao1" class="com.aop.UserDaoImpl"></bean>
	 
	 <!-- 切面 -->
	 <bean id="logAspect1" class="com.aop.LogAspect"></bean>
	 
	 <!-- 使用AOP代理设置关联 -->
	 <bean id="userDaoproxy" class="org.springframework.aop.framework.ProxyFactoryBean">
	 	<!-- 代理接口 -->
	 	<property name="proxyInterfaces" value="com.aop.UserDao"/>
	 	<!-- 目标对象 -->
	 	<property name="target" ref="userDao1"></property>
	 	<!-- 切面 -->
	 	<property name="interceptorNames" value="logAspect1"></property>
	 	<!-- 判断目标是否为类 -->
	 	<property name="proxyTargetClass" value="false"></property>
	 </bean>
</beans>
  1. 测试:/AOPProject/src/com/aop/TestUserDao.java
package com.aop;

import static org.junit.jupiter.api.Assertions.*;

import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

class TestUserDao {

	@Test
	void testAddUser() {
		ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
		UserDao userDao = context.getBean("userDaoproxy",UserDao.class);
		userDao.addUser("csdn", "Fan_zm");
	}

}

二、前置通知(MethodBeforeAdvice)和后置通知(AfterReturningAdvice):
前置通知(MethodBeforeAdvice)是在目标方法执行前自动执行的操作
后置通知(AfterReturningAdvice)是在目标方法执行后自动执行的操作
对上述一、中的例子执行增添和修改:(相关要点在注释中)

  1. 前置通知切面类:/AOPProject/src/com/aop/LogBeforeAspect.java
package com.aop;

import java.lang.reflect.Method;

import org.springframework.aop.MethodBeforeAdvice;

public class LogBeforeAspect implements MethodBeforeAdvice{

	@Override
	public void before(Method arg0, Object[] arg1, Object arg2) throws Throwable {
		// TODO Auto-generated method stub
		//arg1是目标对象接口的方法
		//arg2是目标对象接口的方法的参数
		//arg3是目标对象实现类
		System.out.println("-----前置通知");
		System.out.println("arg0:"+arg0);
		System.out.println("arg2:"+arg2);
	}

}
  1. 后置通知切面类:/AOPProject/src/com/aop/LogAfterAspect.java
package com.aop;

import java.lang.reflect.Method;

import org.springframework.aop.AfterReturningAdvice;

public class LogAfterAspect implements AfterReturningAdvice {

	@Override
	public void afterReturning(Object arg0, Method arg1, Object[] arg2, Object arg3) throws Throwable {
		// TODO Auto-generated method stub
		//arg0是目标对象接口的方法的返回类型
		//arg1是目标对象接口的方法
		//arg2是目标对象接口的方法的参数
		//arg3是目标对象实现类
		System.out.println("----后置通知执行。。。");
	}

}
  1. 修改配置文件:/AOPProject/resource/applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
	 http://www.springframework.org/schema/beans/spring-beans-4.3.xsd">
	 <!-- target object -->
	 <bean id="userDao1" class="com.aop.UserDaoImpl"></bean>
	 
	 <!-- 切面 -->
	 <bean id="logAspect1" class="com.aop.LogAspect"></bean>
	 <bean id="logBeforeAspect" class="com.aop.LogBeforeAspect"></bean>
	 <bean id="logAfterAspect2" class="com.aop.LogAfterAspect"></bean>
	 
	 <!-- 使用AOP代理设置关联 -->
	 <bean id="userDaoproxy" class="org.springframework.aop.framework.ProxyFactoryBean">
	 	<!-- 代理接口 -->
	 	<property name="proxyInterfaces" value="com.aop.UserDao"/>
	 	<!-- 目标对象 -->
	 	<property name="target" ref="userDao1"></property>
	 	<!-- 切面 -->
	 	<!-- <property name="interceptorNames" value="logAspect1"></property> -->
	 	<property name="interceptorNames">
	 		<list>
	 			<value>logBeforeAspect</value>
	 			<value>logAfterAspect2</value>
	 			<value>logAspect1</value>
	 		</list>
	 	</property>
	 	<!-- 判断目标是否为类 -->
	 	<property name="proxyTargetClass" value="false"></property>
	 </bean>
</beans>

三、异常通知(ThrowsAdvice):在目标方法执行异常时自动执行的操作
依旧对前例进行补充和修改

  1. 异常通知切面类:/AOPProject/src/com/aop/LogThrowingAspect.java
package com.aop;

import java.lang.reflect.Method;

import org.springframework.aop.ThrowsAdvice;

public class LogThrowingAspect implements ThrowsAdvice {
	//没有需要具体实现的方法,需要自己写处理方法
	//但是对方法的写法有规定
	public void afterThrowing(Method arg0, Object[] arg1, Object arg2,Throwable error) {
		System.out.println("---异常通知");
		System.out.println(error);
	}
}
  1. 修改执行逻辑,人为制造一个异常:/AOPProject/src/com/aop/UserDaoImpl.java
package com.aop;

public class UserDaoImpl implements UserDao {

	@Override
	public void addUser(String id, String name) {
		// TODO Auto-generated method stub
		//制造一个异常,为了测试异常通知
		String er = null;
		System.out.println("==执行逻辑"+name+"的id是"+id+er.charAt(0));

	}

}
  1. 进行配置修改:/AOPProject/resource/applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
	 http://www.springframework.org/schema/beans/spring-beans-4.3.xsd">
	 <!-- target object -->
	 <bean id="userDao1" class="com.aop.UserDaoImpl"></bean>
	 
	 <!-- 切面 -->
	 <bean id="logAspect1" class="com.aop.LogAspect"></bean>
	 <bean id="logBeforeAspect" class="com.aop.LogBeforeAspect"></bean>
	 <bean id="logAfterAspect2" class="com.aop.LogAfterAspect"></bean>
	 <bean id="logThrowingAspect" class="com.aop.LogThrowingAspect"></bean>
	 
	 <!-- 使用AOP代理设置关联 -->
	 <bean id="userDaoproxy" class="org.springframework.aop.framework.ProxyFactoryBean">
	 	<!-- 代理接口 -->
	 	<property name="proxyInterfaces" value="com.aop.UserDao"/>
	 	<!-- 目标对象 -->
	 	<property name="target" ref="userDao1"></property>
	 	<!-- 切面 -->
	 	<!-- <property name="interceptorNames" value="logAspect1"></property> -->
	 	<property name="interceptorNames">
	 		<list>
	 			<value>logBeforeAspect</value>
	 			<value>logAfterAspect2</value>
	 			<value>logAspect1</value>
	 			<value>logThrowingAspect</value>
	 		</list>
	 	</property>
	 	<!-- 判断目标是否为类 -->
	 	<property name="proxyTargetClass" value="false"></property>
	 </bean>
</beans>
  1. 测试结果:异常通知测试结果
    四、引介通知(IntroductionInterceptor):不同于前四种通知类型,引介通知是在目标类中添加一些新的方法和属性,可应用于修改旧版本程序,增强类功能。
    实现过程请看:学习笔记(05-01-B):轻松搞定Spring全家桶(初识篇)-面向切片编程AOP:使用Spring通知类型创建Spring AOP-2
树莓派c语言串口通讯程序 在网上搜了很多关于树莓派串口通讯的例子,但是都是用python写的,虽然python很有名,而且最近也在学习这门语言, 但是还是想用c语言实现一下,因为需要用到整套系统里,其他内容都是用c语言写的。但是网上没有找打现成的。 还好,之前做过天嵌2440开发板的串口程序(参照天嵌工程师提供的代码),发现串口程序其实是通用的, 驱动层屏蔽了硬件细节,个人猜测,几乎所有移植好的系统的串口,都可以用一 阅读详情

相关推荐

抖音直播小风车跳转企业微信全攻略:企业号申请+落地页配置详解

本文详细解析了抖音直播小风车跳转企业微信的全流程,包括企业号申请、小风车配置和落地页优化。通过实战指南,帮助企业高效实现私域流量沉淀,提升直播转化率,特别适合电商和营销从业者参考。

weixin_29289821的博客 613

Docker进阶篇

容器数据卷 什么是容器数据卷 docker的理念回顾 将应用和环境打包成一个镜像! 数据?如果数据都在容器中,那么我们容器删除,数据就会丢失!需求:数据可以持久化 MySQL,容器删除了,删库跑路!需求:MySQL数据可以存储在本地! 容器之间可以有一个数据共享的技术!Docker容器中产生的数据,同步到本地! 这就是卷技术!目录的挂载,将我们容器内的目录,挂载到Linux上面! 总结一句话:容器的持久化和同步操作!容器间也是可以数据共享的! 使用数据卷 方式一:直接使用命令来挂载 docker run -

lll423的博客 3万+

工业场景落地:Java+PaddleOCR实现高性能OCR文字识别的终极方案

本文深度解析基于Java的高性能工业级OCR实现方案,集成PP-OCRv5深度学习模型,提供: ✅ 多场景支持:手写体、竖排文本、票据表格的精准识别 ✅ 工业级性能:毫秒级响应,支持GPU加速与高并发处理 ✅ 开箱即用:通过Maven快速集成,5行代码完成文字识别 ✅ 完整技术栈:覆盖文本检测、方向校正、识别后处理全流程 附可运行示例代码,助您快速构建企业级OCR系统!

deng775747758的博客 3611

Spring AOP项目应用——方法入参校验 & 日志横切

应用一:方法入参校验由于系统多个方法入参均对外封装了统一的Dto,其中Dto中几个必传参数在每个方法中都会进行相同的校验逻辑。笔者考虑采用Spring AOP进行优化,拦截方法进行参数校验。测试case实现如下:Before/** * 被代理的目标类 */ @Service public class PayOrderTarget { @Autowired private Pay...

Think In JAVA—Max 2105

RDMA性能调优实战:如何用ib_*命令榨干你的Mellanox网卡带宽?

本文深入探讨了如何利用ib_*命令工具集对RDMA网络进行深度性能调优,以充分释放Mellanox网卡的带宽潜力。文章从理解Send/Write/Read三种核心通信原语的差异入手,逐步指导读者通过调整消息大小、队列深度、内联数据等关键参数,并结合系统级的NUMA绑定、中断亲和性等优化策略,实现从基准测试到逼近硬件极限的性能提升。

weixin_29306011的博客 88

习题6-3 使用函数输出指定范围内的完数

其中函数factorsum须返回int number的因子和;函数PrintPN要逐行输出给定范围[mn]内每个完数的因子累加形式的分解式,每个完数占一行,格式为“完数 = 因子1 + 因子2 + ... + 因子k”,其中完数和因子均按递增顺序给出。如果给定区间内没有完数,则输出一行“No perfect number”。

cutto的博客 862

Spring Boot 开发最佳实践

点击▲关注 “爪哇笔记” 给公众号标星置顶更多精彩 第一时间直达Spring Boot 是最流行的用于开发微服务的 Java 框架。在本文中,我将与你分享自 2016 年以来我在专业...

不是太高的手的专栏 508

DFT知识点扫盲——DFT scan chain

实际在项目中synccell一般直接上ULVT,既然是SDF,就是带Scan接口的DFF,SN (set negtive)是低置位,RP(reset positive)是高复位,既没有SN也没有RP的就是无复位寄存器。1:定义:满足可测试性设计(DFT),将设计中所有的触发器连接到一条或者若干条链上,称为scan chain,将一个复杂的时序电路转换为简单的组合电路进行测试,这一步是在逻辑综合(DC)中实现。当SE=1当SI=1时,电路进入scan状态,当SI=0时,电路工作在normal状态。

笨蛋大乌龟的博客 4936

学习笔记(05-02):轻松搞定Spring全家桶(初识篇)-面向切片编程AOP:使用AspectJ基于XML开发AOP

注:与前面的笔记有一点地方不一样,无伤大雅,笔记要点在代码中 AOP的一丁点基础:学习笔记(05):轻松搞定Spring全家桶(初识篇)-面向切片编程AOP 使用AspectJ基于XML开发AOP: 一、创建项目,导入相关jar包:(点击下载) spring项目所需基础jar包 使用AspectJ基于XML开发AOP额外需要的jar包 二、创建一个接口:/AOPProjectByAspectJXml/src/com/aop/UserDao.java package com.aop; public in

Fan_zm的博客 259

用户画像标签维度_搭建电商平台用户画像标签体系

01 整体思路电商平台连接了卖家和买家两端,最终目的都是促进交易,从而追求更高的销售额。提高人货匹配度是促进交易的关键,而提高人货匹配度的关键就是“让买家找到想要的货物”。本文结合“人、货、场”理论模型,尝试建立电商平台的用户画像标签体系。02 三类标签用户在平台购物的整体流程可以概括为:进入平台、选择商品、下单付款。可以将该过程抽象为“人、货、场”。即用户通过什么途径进入什么商品的页面...

weixin_31668621的博客 1642

基于深度学习的火焰检测系统:YOLOv8 + UI界面 + 数据集详解

YOLO(You Only Look Once)是一种端到端的目标检测算法,其最大优势在于将目标检测任务转化为一个回归问题,可以在一次前向传播中同时完成目标定位和分类。YOLOv8是YOLO系列中的最新版本,相比之前的版本,YOLOv8在精度和推理速度上都做了显著提升,特别是在小物体检测方面表现更加优秀。实时性:YOLOv8具有较高的推理速度,适用于实时火焰检测。高精度:相较于YOLOv7,YOLOv8在精度和小物体检测上有所改进。简单易用:YOLOv8的API简单直观,易于集成和使用。

YOLO 660

学习笔记(05-01-B):轻松搞定Spring全家桶(初识篇)-面向切片编程AOP:使用Spring通知类型创建Spring AOP-2

前置通知、后置通知、环绕通知和异常通知的实现:学习笔记(05-01):轻松搞定Spring全家桶(初识篇)-面向切片编程AOP:使用Spring通知类型创建Spring AOP。以下是第五种通知类型——引介通知的实现 5.IntroductionInterceptor(引介通知):不同于前四种通知类型,前四种通知类型是在目标方法前后或者目标方法执行过程中出现异常所进行的一些操作;而引介通知实在目标类中添加一些新的方法和属性,应用于修改旧版本程序,增强类功能。 ...

Fan_zm的博客 224

Xilinx差分原语-IBUFGDS与OBUFGDS FPGA

它将差分信号转换为单端信号,并将其输入到FPGA的逻辑片上。它将单端信号转换为差分信号,并将其输出到FPGA的引脚。在FPGA设计中,差分信号是一种常见的信号传输方式,用于提高抗噪性和抑制共模噪声。Xilinx是一家知名的FPGA供应商,提供了许多差分原语,其中包括IBUFGDS和OBUFGDS。通过使用Xilinx的差分原语,如IBUFGDS和OBUFGDS,可以实现差分信号的输入和输出。这些差分原语提供了方便且可靠的接口,使得在FPGA设计中处理差分信号变得更加简单和高效。是差分输入信号的端口,

git_database727的博客 2096

视频教程-轻松搞定Spring全家桶(初识篇)-Java

轻松搞定Spring全家桶(初识篇) 毕业于清华大学软件学院软件工程专业,曾...

weixin_34079807的博客 1022

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

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

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

学习笔记(01):轻松搞定Spring全家桶(初识篇)-全家桶概述

主要以案例进行讲解,通过案例讲解各技术如何使用,同时在Spring MVC及Spring Boot的最后一部分都是从前端页面、到逻辑层、到持久层的整体的产品的增删改查的实战案例。 【我们保证你能收获到以下几点】 1、掌握Spring全家桶主要部分的开发、实现 2、可以使用Spring MVC、Spring Boot、Sprin...

Fan_zm的博客 403

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

Spring全家桶笔记:Spring+Spring Boot+Spring Cloud+Spring MVC

Spring:出现在2002年左右,降低企业级开发难度。帮助进行模块之间、类与类之间的管理,帮助开发人员创建对象,管理对象之间的关系。2003年传入国内,被大量使用。2017出现新的流行框架SpringBoot,核心思想与Spring相同。核心技术:IoC、AOP,能使模块之间、类之间解耦合。依赖:class A使用class B的属性或方法,称之为class A依赖class B。官网:spring.io2.Spring框架的特点。

老男孩的架构路 221

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

Spring全家桶笔记,这是真的强!

Spring出现在2002年左右,降低企业级开发难度。帮助进行模块之间、类与类之间的管理,帮助开发人员创建对象,管理对象之间的关系。2003年传入国内,被大量使用。2017出现新的流行框架SpringBoot,核心思想与Spring相同。核心技术IoC、AOP,能使模块之间、类之间解耦合。依赖classA使用classB的属性或方法,称之为classA依赖classB。官网spring.io2.Spring框架的特点轻量。...

老男孩的架构路 304

【Spring全家桶系列】深入学习各模块综合链接

????????????欢迎来到我的博客 ! 亲爱的朋友们,欢迎您们莅临我的博客!这是一个分享知识、交流想法、记录生活的温馨角落。在这里,您可以找到我对世界独特视角的诠释,也可以与我一起探讨各种话题,共享知识的乐趣。文章推荐:Cherry的首页,持续更新,不断总结,共同进步,活到老学到老视频推荐:Cherry的Spring教学视频,系列课程...

weixin_36910725的博客 88

Spring-学习笔记01【Spring框架简介】

Spring-学习笔记01【Spring框架简介】

upward 633

01. Spring编程思想

01 Spring编程思想 Pt1 Spring设计初衷 我基本算是从Struts2时代开始软件开发的,虽然周围接触的还有很多Struts1时代遗留的产物,但是Struts2 + Hibernate已经成为了主流的搭配,后来没过多久Spring开始流行,MVC大行其道,SSH组合成为风靡一时的Java开发框架。那时候要在SSH框架中集成各种组件,都要自己进行装配,也没有JdbcTemplate,每个项目要自己写很多模板代码,更不用说用Servlet开发的年代了。 程序员不只要考虑业务代码的实现,...

Java是世界上最好的语言 423

SSM框架01:Spring的IoC和DI,以及手把手带你创建Spring核心配置文件

↑↑Java语法基础 —> 小型项目练习 —> MySQL 更多学习内容均更新在专栏了,记得关注专栏哦 ↑↑ 🍬JDBC:从CRUD开始,理解JDBC中的各个对象作用,掌握Druid的使用 🍬Maven从安装到手把手教学进行项目管理 🍬MyBatis完成代理方式查询数据以及核心文件配置、 🍬Mybatis:使用映射配置文件实现CRUD操作,能够使用注解实现CRUD操作 🍬Git学习第一天:了解Git基本概念 🍬Git第二天:Git安装与常用命令 🍬Git第三天:搭建Git远程

黑马程序员官方博客 1753

01.初识Spring Boot

一.什么是Spring Boot? Spring Boot是基于Spring框架开发的全新框架,是Spring家族的一个子项目,其设计目的是简化Spring配置,从而可以轻松构建独立运行的程序并极大的提高开发效率。 Spring Boot整合了许多框架和第三方库配置。几乎可以达到“开箱即用”。 二.Spring Boot的优点: 可快速构建独立的Spring应用 直接嵌入Tomcat/Jet...

C_leng的博客 1547

spring学习笔记

思维导图:https://www.processon.com/mindmap/5f9faae607912948e6e72f5a spring全家桶:spring,springMVC,spring boot,spring cloud spring:出现在2002年左右,解决企业开发的难度。减轻对项目模块之间的管理,类和类之间的管理,帮助开发人员创建对象,管理对象之间的关系。 spring核心技术:ioc,aop。能实现模块之间,类之间的解耦合。 依赖:class A中使用class B的属性或者方法,叫做cl

qq_44989208的博客 680

第21~22周Java主流框架入门-Spring 2.SpringAOP面向切面编程

本节课程将通过实际项目配置,带领大家一步一步理解Spring AOP(面向切面编程)的功能。我们将基于 XML 配置的形式来实现 AOP,并通过演示了解 AOP 如何对现有系统进行功能扩展,而无需修改源代码。本次演示基于s01工程,其中包含了两个主要部分:DAO 层:包括和UserDao,分别用于对员工表和用户表的数据增删改查。Service 层:包括和,分别提供了员工相关的业务逻辑和用户管理的业务逻辑。:提供entry方法,模拟员工入职操作。:提供createUser方法(创建用户)和。

Sweeping_Robot的博客 1210

史上最全系列!Spring+SpringBoot+SpringCloud全攻略,助你一站通关,拿下大厂offer

前几天,有幸从朋友那里得到了一份Alibaba内部的墙裂推荐的“玩转Spring全家桶的PDF”,我也不是个吝啬的人,好的东西当然要一起分享。那今天我就秀一把,带你一站通关Spring、Spring Boot与Spring Cloud,让你轻松斩获大厂Offer! 这份PDF能得到的收获: 使用 Spring 熟练开发 Web 服务; 搞懂 Spring Boot 核心功能的实现原理; 通过 Spring Cloud 快速构建微服务架构; 掌握 Spring 个性化定制与扩展的进阶方法.

m0_50180963的博客 238
上一篇: 学习笔记(05):轻松搞定Spring全家桶(初识篇)-面向切片编程AOP:
下一篇: 学习笔记(05-01-B):轻松搞定Spring全家桶(初识篇)-面向切片编程AOP:使用Spring通知类型创建Spring AOP-2
Fan_zm
博客等级 码龄9年 1粉丝 27原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值