Spring Boot 2.0 运行状态监控使用 Actuator /actuator/refresh

Spring Boot Actuator 核心端点配置与生产安全实践 Spring Boot Actuator 是面向生产环境的运行时观测与控制框架,其本质是将 JVM、线程、内存、HTTP、数据源等底层状态抽象为标准化 REST 端点(Endpoints)。它基于 Micrometer 指标门面实现可扩展监控,支持 Prometheus 抓取与 Grafana 可视化,并深度集成 Spring Security 实现细粒度鉴权。技术价值在于让 Java 应用从‘能跑’升级为‘可知、可控、可演进’——通过 /actuator/health 实现服务健康探针,/actuator 阅读详情

springboot的Actuator提供了运行状态监控的功能,可以通过REST、远程Shell和JMX方式来查看。 
   
  使用时倒入spring-boot-starter-actuator的依赖即可。 
  这里说下springboot2.0的配置方法,因为springboot2开始配置项与之前有了些差别: 
  这里写图片描述 
  之前的配置项为: 
  

management.port=9001
management.security.enabled=false
  • 1
  • 2

这两个属性可以发现已经改变了。

springboot2.0 的配置项为:

#actuator端口 
management.server.port=9001
#修改访问路径  2.0之前默认是/   2.0默认是 /actuator  可以通过这个属性值修改  
management.endpoints.web.base-path=/monitor
#开放所有页面节点  默认只开启了health、info两个节点
management.endpoints.web.exposure.include=*
#显示健康具体信息  默认不会显示详细信息  
management.endpoint.health.show-details=always

配置完成启动项目后就可以通过postman或者直接在预览器输入路径等方式来查看应用的运行状态了。

例如使用postman发送 localhost:9001/monitor/health GET请求 (除了shutdown请求为post,其他的皆为GET请求) 
这里写图片描述
可以看到redis没有连接成功。

Actuator的api接口: 
actuator API这里写图片描述

health的健康指示器: 
这里写图片描述

官方文档地址:https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html

Spring Boot内核深度解析:自动配置、Starter与Actuator原理 Spring Boot作为Java微服务开发的事实标准,其核心价值在于‘约定优于配置’的工程化实现。它通过条件化自动配置(@Conditional系列注解)动态装配Bean,依托Starter机制封装标准化依赖契约,并借助Actuator暴露生产级运行时指标。这些能力并非黑盒魔法,而是基于Spring容器生命周期、Environment属性绑定、ConditionEvaluator评估链等底层机制协同工作。理解自动配置的加载顺序、Starter的三层结构(契约/实现/适配)、Actuator端点的安全暴露策 阅读详情

相关推荐

Spring Boot四大核心组件深度解析:Starters、AutoConfigurator、CLI与Actuator

Spring Boot并非黑盒魔法,其本质是一套基于约定与条件化装配的工程化框架。理解其底层机制,需从自动配置原理出发——通过条件注解(@ConditionalOnClass/Bean/Property)实现精准装配,依托Starter作为声明式契约统一依赖、配置与激活逻辑,再由AutoConfigurator按确定性顺序调度执行。这种设计赋予框架开箱即用的能力,同时保留完全可覆盖的控制权;CLI提供轻量级原生调试入口,支持Groovy动态实验与秒级热重载;Actuator则构建运行时数字孪生体,暴露env

weixin_33726313的博客 348

SpringBoot的actuator无法执行/refresh,报错404

微服务从配置中心获取配置,当远程仓库git的参数修改时,需要以post方式执行/actuator/refresh刷新配置。但是执行失败。报错404. { "timestamp": "2022-02-21T02:46:35.030+00:00", "status": 404, "error": "Not Found", "message": "No message available", "path": "/actuator/refresh" } 查看spring

MieMieFly的专栏 4031

Spring Boot Admin实战:微服务监控仪表盘搭建与生产级优化

在微服务架构中,应用性能监控是保障系统稳定性的基石。其核心原理在于通过暴露标准化的健康与度量端点,实现对服务运行状态的实时采集与聚合。这项技术的价值在于将分散的运维数据可视化、集中化,从而显著提升问题发现与诊断的效率。典型的应用场景包括监控服务健康状态、追踪性能指标、动态管理日志级别以及接收实时告警。本文聚焦于Spring Boot Admin这一轻量级监控解决方案,它构建在Spring Boot Actuator之上,通过Admin Server与Client的协作,为开发者提供了一个开箱即用的集中式监控

weixin_34265814的博客 386

SpringBoot/SpringCloud: 应用配置项热加载与动态刷新

springcloud的上下文参数刷新的功能,接口/actuator/refresh的端点,实现应用属性的实时刷新。方法1:@ConfigurationProperties + /actuator/refresh,方法2:@Value + @RefreshScope + /actuator/refresh

c_zyer的博客 3210

Spring Boot Admin安全攻防实战:从Actuator端点渗透到微服务集群加固

Spring Boot Actuator作为应用监控的核心组件,为微服务提供了丰富的运行时信息端点。其工作原理是通过HTTP暴露应用的内部状态,包括健康检查、环境变量、日志和度量指标等。这一设计在提升运维效率的同时,也带来了显著的安全风险:不当暴露的端点可能成为攻击者获取敏感信息甚至实现横向移动的入口。在微服务架构中,Spring Boot Admin作为集中式监控面板,会聚合多个服务的Actuator端点,一旦其自身存在未授权访问或弱认证问题,攻击者便能通过它获取整个服务集群的“地图”,直接定位并攻击各个

aodanchui1057的博客 428

Spring Boot安全攻防:从Actuator端点利用到反序列化漏洞实战解析

在微服务架构中,应用监控与管理是保障系统稳定性的关键环节,其核心原理是通过暴露特定的HTTP端点来实现健康检查、性能指标收集和运行时配置管理。Spring Boot Actuator模块正是这一理念的典型实现,它通过自动化配置极大地简化了监控功能的集成。然而,这种“约定大于配置”的便利性若缺乏安全管控,会引发严重的技术风险,例如敏感信息泄露和远程代码执行。在工程实践中,**Actuator端点暴露**和**反序列化漏洞**成为高频出现的安全敞口,攻击者常利用未授权访问的/env端点获取数据库凭证等配置信息,

weixin_30608503的博客 344

springcloud中结合actuator不支持/actuator/refresh

起因 因为springcloud config 里面需要获取刷新配置时,在访问浏览器http://localhost:13000/actuator/refresh时,发现出错。 排查 Whitelabel Error Page This application has no configured error view, so you are seeing this as a fallback. ...

huskyui 2470

基于Spring Boot的校园二手交易平台:从架构设计到部署上线的Java实战

在Web应用开发领域,Java凭借其成熟的生态和稳定的性能,成为构建企业级应用的主流选择。其核心原理在于通过Spring Boot等框架提供快速开发能力,结合MVC分层架构实现业务逻辑的解耦与复用。这一技术栈的价值在于能够高效、可靠地支撑复杂业务系统,尤其适用于需要处理高并发、保证数据一致性的场景,例如电商平台、社交应用等。本文聚焦于一个典型的应用场景——校园二手交易平台,深入探讨如何利用Spring Boot、MyBatis-Plus、Redis和JWT等技术栈,从零开始搭建一个具备商品发布、搜索、订单管

weixin_33768481的博客 488

Springboot之Actuator信息泄露漏洞利用

Spring Boot Actuator 模块提供了健康检查,审计,指标收集,HTTP 跟踪等,是帮助我们监控和管理Spring Boot 应用的模块。这个模块采集应用的内部信息,展现给外部模块,可以查看应用配置的详细信息,例如自动化配置信息、创建的Spring beans信息、系统环境变量的配置信息以及Web请求的详细信息等。如果没有正确使用Actuator,可能造成信息泄露等严重的安全隐患(外部人员非授权访问Actuator端点)。...

JHIII的博客 4万+

JVM Prometheus Monitor - 轻量级 JVM 监控面板

JVM Prometheus Monitor - 轻量级 JVM 监控面板 内容概要: 一款纯前端静态页面的 JVM 监控工具,采用 Grafana 风格暗色主题,支持 Prometheus 指标格式。单文件部署,无需后端服务,打开即用。提供堆内存(Eden/Old Gen/Survivor)、非堆内存(Metaspace/Code Cache/Class Space)、GC 暂停与频率、CPU、线程、HTTP 请求等全方位实时监控,内置 JVM 健康智能分析功能。 适用人群: Java 后端开发者、运

CN_BLUE_L的博客 357

【gcc】跨版本兼容实战:高版本编译程序在低版本glibc环境下的部署方案

本文针对高版本gcc编译的程序在低版本glibc环境下部署的兼容性问题,提供了四种实战解决方案:静态编译的局限性、容器化部署的优雅方案、使用Devtoolset工具链的官方支持,以及最通用灵活的打包依赖SO发布方案。重点剖析了通过设置RPATH和Interpreter或使用patchelf工具,实现程序与自带库的独立部署,有效解决glibc版本鸿沟。

weixin_29237635的博客 362

spring boot之actuator健康检查

什么是actuator SpringBoot自带监控功能Actuator,可以帮助实现对程序内部运行情况监控,比如监控状况、Bean加载情况、环境变量、日志信息、线程信息等。 官翻文档:https://blog.csdn.net/alinyua/article/details/80009435 快速使用教程:https://blog.csdn.net/pengjunlee/article/details/80235390 进阶使用:https://blog.csdn.net/alinyua/article/

weixin_44504392的博客 4134

Lumerical官方案例、FDTD时域有限差分法仿真学习(十四)——超透镜(Metalens)

这个例子的目的是设计一个由圆柱形纳米棒组成的衍射超透镜。 纳米棒的半径和排列经过调整以在超透镜表面上产生所需的相位分布。 该设计通过近场和远场分析在 Ansys FDTD、RCWA(严格耦合波分析)和 OpticStudio 中得到验证。...

weixin_45719141的博客 3万+

Spring Boot 核心原理解析与实践(含代码示例)

Spring Boot是一个基于Spring框架的快速开发工具,通过自动配置、起步依赖和嵌入式服务器等机制简化应用开发。其核心原理包括:1)通过@EnableAutoConfiguration触发自动配置,加载预定义的配置类;2)使用条件化注解控制Bean装配;3)提供Starter聚合依赖,实现开箱即用。Spring Boot启动流程包括环境准备、上下文创建、自动配置和服务器启动等阶段。开发建议包括合理项目结构、继承父工程管理依赖、配置类型安全绑定以及集成Actuator监控。此外,Spring Boot

csdn_silent的博客 2103

EDEM基础操作指南

EDEM(Enhanced Discrete Element Method)是一种用于模拟颗粒物料行为的软件工具。它可以模拟颗粒的碰撞、流动、堆积等过程,广泛应用于颗粒物料工程、振动筛分、堆垛机械、矿山开采等领域。本文将介绍EDEM的基础操作步骤,并提供相应的源代码示例。以上是EDEM的基础操作步骤。通过创建EDEM项目、定义颗粒材料、导入几何模型、设置边界条件、创建颗粒流场和运行模拟,您可以开始模拟颗粒物料的行为并进行相应的分析和优化。请根据您的具体需求和场景进行相应的参数设置和功能调用。

TrDelphi的博客 5293

海鸥派OpenEuler开发板实战:从烧写到SSH连接的完整指南

本文提供海鸥派OpenEuler开发板从开箱到SSH远程连接的完整实战指南。详细介绍了基于海思SD3403/SS928芯片的算力开发板系统烧写、存储扩容、网络配置等关键步骤,帮助开发者快速上手这款AI边缘计算设备,并实现高效的远程开发与管理。

ruby5的博客 1121

Spring Boot面试核心:从自动装配原理到项目部署实战

Spring Boot作为现代Java企业级开发的事实标准,其核心价值在于通过‘约定大于配置’和‘自动装配’两大设计哲学,极大地简化了应用开发与部署流程。自动装配机制基于条件注解实现按需加载,而Starter机制则通过依赖聚合解决了版本冲突与依赖冗余问题,共同构成了Spring Boot高效开发的基石。在工程实践中,这些特性使得开发者能够快速构建独立运行、生产就绪的微服务应用,广泛应用于从初创项目到大型分布式系统的后端服务搭建。本文聚焦于Spring Boot面试中的核心考察点,深入剖析自动装配原理与Sta

aizexi2652的博客 319

深入浅出:UE4类型系统完整构建过程详解

UE4的类型系统是一个复杂但设计精巧的架构,它通过静态代码生成和运行时构建的完美配合,实现了强大的反射功能。理解这个过程不仅有助于解决开发中的问题,也能让你更好地利用UE4的各种高级特性。就像建造一栋大楼需要经过设计、备料、框架、装修、验收等多个阶段,UE4类型系统的构建也是一个多阶段、精细化的过程。每个阶段都有其特定的职责,共同协作完成从源代码到运行时对象的转换。

m0_45371381的博客 911

Spring之SpringBoot

Spring Boot 是基于 Spring 框架的快速开发脚手架,旨在简化 Spring 应用的初始搭建和开发过程。它通过"约定优于配置"的理念,让开发者以最少的配置快速创建生产级别的应用。 1.4 快速开始 二、启动流程源码分析(SpringApplication.run) 2.1 启动入口 2.2 SpringApplication 构造阶段 WebApplicationType 推断逻辑: 2.3 run() 方法主流程 2.4 refreshContext 核心流程 2.5 启动事件

萧瑟余晖的博客 950

【Unity】 预制体Prefab使用说明

在 Unity 中,Prefab 是一个可以预先制作并重复使用的 GameObject 或组件集合,Prefab 中的 GameObject 可以有子对象和其他组件。

灵境引路人 2850

嵌入式工程师成长之路(3)——PCB设计

带有目的的学:要知道,PCB板子做出来需要我们给厂家哪些东西,我们设计板子的时候,需要遵循哪些设计规范,防止画好也是块废板子。然后再逐步开始学习画板。

云轩阁 8万+

Nacos Spring Boot Project配置属性全解析:自定义配置与高级特性指南

想要在Spring Boot项目中轻松实现配置管理和服务发现吗?😊 Nacos Spring Boot Project为你提供了完整的解决方案!作为Alibaba Nacos的Spring Boot生态项目,它让开发者能够快速构建云原生应用,实现动态配置管理和服务注册发现功能。 ## 🚀 什么是Nacos Spring Boot Project? Nacos Spring Boot Pro

gitblog_00930的博客 999

【网络安全】浅谈数据库攻击复现及相关安全优化

4、准备数据库服务器为了安全正式环境应该把数据库单独放一台服务器,只允许让应用服务器 IP 来访问数据库服务器,通过独立两者,就算其中一台发生问题,另一台也是好的,进一步降低了危险性。5、定时备份数据库开发定时备份功能,可以使用 Crontab,或者其他框架,设定周期备份数据,哪怕是数据丢失或被删除也可以快速恢复。

2401_88545587的博客 221

【springboot】万字操作指南 Spring Boot 2.x 升级到 3.x:微服务项目实战

摘要: 本文提供Spring Boot 2.x升级到3.x的实战指南,重点针对微服务项目。升级涉及JDK 17、Spring Framework 6、Jakarta EE等连锁变化,需系统规划版本矩阵(如Spring Boot 3.5.x + Spring Cloud 2025.0.x)。建议升级路线:先统一JDK 17环境,再处理依赖迁移(javax→jakarta)、Spring Security 6适配、OAuth2授权服务器改造等关键步骤。

Cjh20pan的博客 977

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

go-jmespath 实战指南:在 Go 中查询与转换 JSON 数据的 JMESPath 实现

go-jmespath 是 JMESPath 查询语言在 Go 语言下的官方实现,它接收一个 JSON 文档和一条 JMESPath 表达式,把前者"变换"成后者所描述的结果文档。本文以本仓库 vendored 的 [go-jmespath README](https://link.gitcode.com/i/9fe16bd67afcf46f56b9ea2230f8160f) 为骨架,结合其源码(

gitblog_01184的博客 229

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

Spring Boot在农业B2B电商平台中的实践与优化

Spring Boot作为现代Java开发的主流框架,通过自动配置和起步依赖显著提升了开发效率。其内嵌容器和默认配置能有效应对高并发场景,配合MyBatis-Plus等ORM工具可快速构建数据访问层。在电商领域,Spring Boot常用于实现商品管理、订单处理等核心模块,特别是在垂直行业电商系统中,需要结合领域驱动设计(DDD)构建精准的业务模型。本文以农业机械设备B2B平台为例,展示了如何利用Spring Boot处理设备推荐、在线融资等特色功能,并通过三级锁机制解决春耕季的高并发订单问题。项目中采用的

weixin_34007906的博客 722

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

上一篇: gradle安装使用及基本操作
下一篇: Spring Boot2.0.4+Spring Cloud搭建配置中心Spring Cloud Config
LuckyJiang.2021
博客等级 码龄15年 217粉丝 199原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值