代码质量审查工具sonarqube安装

sonarqube+jenkins实现持续CodeReview sonarqube+jenkins实现代码持续Review 介绍篇 SonarQube 介绍 SonarQube 是 一个开源的代码质量分析平台,便于管理代码的质量,可检查出项目代码的漏洞和潜在的逻辑问题。同时,它提供了丰富的插件,支持多种语言的检测, 如 Java、Python、Groovy、C、C++等几十种编程语言的检测。它主要的核心价值体现在如下几个方面: 检查代码是否... 阅读详情

简介

SonarQube为静态代码检查工具,采用B/S架构,帮助检查代码缺陷,改善代码质量,提高开发速度,通过插件形式,可以支持Java、C、C++、JavaScripe等等二十几种编程语言的代码质量管理与检测。

通过客户端插件分析源代码,sonar客户端可以采用IDE插件、Sonar-Scanner插件、Ant插件和Maven插件方式,并通过各种不同的分析机制对项目源代码进行分析和扫描,并把分析扫描后的结果上传到sonar的数据库,通过sonar web界面对分析结果进行管理

架构图

在这里插入图片描述

可以从七个维度检测代码质量:

(1)复杂度分布(complexity):代码复杂度过高将难以理解
(2) 重复代码(duplications):程序中包含大量复制、粘贴的代码而导致代码臃肿,sonar可以展示源码中重复严重的地方

(3) 单元测试统计(unit tests):统计并展示单元测试覆盖率,开发或测试可以清楚测试代码的覆盖情况
(4) 代码规则检查(coding rules):通过Findbugs,PMD,CheckStyle等检查代码是否符合规范
(5) 注释率(comments):若代码注释过少,特别是人员变动后,其他人接手比较难接手;若过多,又不利于阅读
(6) 潜在的Bug(potential bugs):通过Findbugs,PMD,CheckStyle等检测潜在的bug

(7) 结构与设计(architecture & design):找出循环,展示包与包、类与类之间的依赖、检查程序之间耦合度

准备工作

JDK1.8需要安装和环境变量
mysql数据库:安装方式如下
https://blog.csdn.net/zjcjava/article/details/78037276

sonar安装

下载安装文件
wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-7.3.zip

创建数据库sonar,和用户密码,并授权

CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci; 
CREATE USER 'sonar' IDENTIFIED BY 'sonar';
GRANT ALL ON sonar.* TO 'sonar'@'%' IDENTIFIED BY 'sonar';
GRANT ALL ON sonar.* TO 'sonar'@'localhost' IDENTIFIED BY 'sonar';
FLUSH PRIVILEGES;

修改配置文件

sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar

sonar.web.port=9000
sonar.search.port=9001

注意这里的端口我修改了,web端口是9000,es的端口是9001

WIN系统启动服务

CMD命令行下执行,初始化创建数据库和启动es等服务
E:\sonarqube-7.3\bin\windows-x86-64>StartSonar.bat

主要端口不要被占用,如果占用请关闭。
cmd查看端口占用

netstat -aon|findstr "9000"

centos利用netstat -tpnl查看的端口开放情况

centos系统启动服务

不能用root用户启动es
创建sonar 用户并赋权

[root@i-vzdytl5t linux-x86-64]# adduser sonar
[root@i-vzdytl5t linux-x86-64]# passwd sonar
[root@i-vzdytl5t sonarqube]# chown -R sonar:sonar  sonarqube-7.3

然后启动服务

[root@i-vzdytl5t linux-x86-64]# su sonarUser
[sonarUser@i-vzdytl5t linux-x86-64]$ ./sonar.sh console
//后台启动
[sonarUser@i-vzdytl5t linux-x86-64]$ ./sonar.sh start
Starting SonarQube...
Started SonarQube.

[sonarUser@i-vzdytl5t linux-x86-64]$ netstat -tlnp 

#./sonar.sh start 启动服务
#./sonar.sh stop 停止服务
#./sonar.sh restart 重启服务

浏览器打开web服务安装插件

http://localhost:9000/projects
默认管理账号和密码都是admin

汉化插件安装
直接访问下面的地址,就可以看到,列表中有Chinese Pack,
点击Install安装,安装完成后菜单栏下方会提示你重启,点击重启即可
http://localhost:9457/admin/marketplace?search=Chinese

Checkstyle 插件安装
admin 登录,点击 配置 -> 系统 -> 更新中心 -> Available -> Search,输入 CheckStyle,在搜素结果中找到 CheckStyle 插件点击 Install,等待下载完成后,按照页面提示点击 Restart 自动重启服务即可完成安装。

代码检测

代码检测需要客户端把检测的报告提交到服务中去
前面已经说了客户端可以通过IDE插件、Sonar-Scanner插件、Ant插件和Maven插件方式进行扫描分析

maven 插件方式

在安装maven后的setting.xml文件的profiles标签下面贴如下配置信息

  <profile>
      <id>sonar</id>
      <activation>
          <activeByDefault>true</activeByDefault>
      </activation>
      <properties>
          <!-- 配置 Sonar Host地址,默认:http://localhost:9000 -->
          <sonar.host.url>
            http://localhost:9000
          </sonar.host.url>
      </properties>
  </profile>

进入该java项目根目录 执行如下命令,最后BUILD SUCCESS则检测成功完成

>mvn clean install sonar:sonar

Scanner安装

参照资料:https://blog.csdn.net/songer_xing/article/details/76687225

下载Scanner
https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner

1.解压后,打开sonar-scanner-2.8目录下的conf目录,找到sonar-scanner.properties文件

#----- Default SonarQube server
sonar.host.url=http://localhost:9000

#----- Default source code encoding
sonar.sourceEncoding=UTF-8

2.命令查看是否可用,配置环境变量
配置环境配量
Windows下新增一个变量SONAR-RUNNER,值为sonar-scanner的解缩地址,
如E:\Program File\sonar-scanner-2.8
然后在PATH变量后面追加%SONAR-RUNNER%\bin;

centos下直接在/etc/profile下参考jdk的方式

sonar-scanner -v

测试源码分析

1、配置sonar-project.properties

在要进行代码质量检测的项目根目录下新建一个名为sonar-project.properties的配置文件

# 项目唯一标识符key
sonar.projectKey=com.demo             
# 项目名称
sonar.projectName=demo          
#  项目版本
sonar.projectVersion=1.0               

# //分析的代码文件目录
sonar.sources=src                          
sonar.sourceEncoding=UTF-8 

2.cd进入你的工作空间,某个工程的代码路径,
3、敲入sonar-scanner,即可进行分析

CICD持续集成和Jenkins的安装配置【SonarQube代码审查】(八)_gitlab cicd 集成 sonarqube chown -R sonar. /opt/sonar 更改sonar目录及文件权限。su sonar ./bin/linux-x86-64/sonar.sh status 查看状态。su sonar ./bin/linux-x86-64/sonar.sh start 启动。su sonar ./bin/linux-x86-64/sonar.sh stop 停止。 阅读详情

相关推荐

代码质量分析利器之SonarQube【史上最全】

写在前面 随着业务的发展,程序员维护的系统会越来越庞大。原本一个简单稳定的功能,可能在迭代几次后复杂度上升,导致潜在的风险随之暴露,最终导致服务不稳定,造成业务价值的损失。因此,各位大佬们一致认为需要从源头抓起,从个人技术成长到工作流程标准化去提供系统稳定性。与此同时,我也在代码质量这个方向进行挖掘,试图通过代码质量分析去反向要求程序员提高代码编程能力,降低错误风险,这才有了今天的主角-SonarQube 文章目录写在前面背景代码质量分析的痛点调研调研结果Sonarqube介绍工作原理功能介绍项目项目-总览

1万+

SonarQube+SonarScanner搭建

SonarQube+SonarScanner搭建

GalaxySpaceX的博客 2619

手把手教你SonarQube入门安装与使用

简介 Sonar (SonarQube)是一个开源平台,用于管理源代码的质量。 Sonar 不只是一个质量数据报告工具,更是代码质量管理平台。 支持Java, C#, C/C++, PL/SQL, Cobol, JavaScrip, Groovy 等等二十几种编程语言的代码质量管理与检测。 Sonar可以从以下七个维度检测代码质量,而作为开发人员至少需要处理前5种代码质量问题。 不遵循代码标准 sonar可以通过PMD,CheckStyle,Findbugs等等代码规则检测工具规范代码编写。 潜在的缺陷

My Blog My Style 1264

sonarqube的安装

sonarqube的安装 一、上传包 1、上传sonarqube压缩包 这里以7.9.2为例: 上传sonarqube-7.9.2.zip到/usr/local下解压 cd /usr/local unzip sonarqube-7.9.2.zip 2、上传jdk 这里以11.0.2为例: 上传openjdk-11.0.2_linux-x64_bin.tar.gz解压到/usr/local/sonarqube-7.9.2 tar -zxvf openjdk-11.0.2_linux-x64_bin.tar.

Thtbs_Z的博客 326

Jenkins集成Sonar进行代码审查

  由于最近客户要求在devops持续集成平台上增加代码审计功能,经过一番对比,决定选用sonar来实现,通过网上的文档艰难的完成了安装,写篇博客记录下。 SonarQube 简介   Sonar是一个用于代码质量管理的开源平台,用于管理Java源代码的质量。通过插件机制,Sonar 可以集成不同的测试工具,代码分析工具,以及持续集成工具,比如pmd-cpd、checkstyle、fi...

skysrc的博客 2772

8、jenkins项目代码审查-SonarQube代码审查

SonarQube是一个用于管理代码质量的开放平台,可以快速的定位代码中潜在的或者明显的错误。目前支持java,C#,C/C++,Python,PL/SQL,Cobol,JavaScrip,Groovy等二十几种编程语言的代码质量管理与检测。

Daniel 628

Sonar安装使用

说明elasticsearch不能在root权限下运行。目录:conf/sonar.propertise。地址:192.168.7.247:9000。账号:admin 密码:admin。账号:admin 密码:admin。重启sonar,登录就会变成中文版。授权完成后切换用户启动sonar。sonarqube-7.6版本。输入项目标识、显示名,点击设置。选择Java、Maven。访问前确保端口已被放行。

qq_43579559的博客 1001

SonarQube与Jenkins集成搭建指南

SonarQube是一个开源的代码质量管理平台,能够持续地扫描项目源代码,提供实时的代码质量反馈。它支持多种编程语言,具备简洁的UI界面,用于识别代码中的bug、代码异味(code smells)和潜在的漏洞。SonarQube通过直观的图表和统计数据,帮助开发团队理解和解决代码质量问题。持续集成/持续部署(CI/CD)是一种软件开发实践,旨在加快软件交付过程。它通过自动化的构建、测试和部署流程来减少开发人员与运维团队之间的沟通障碍。持续集成(CI)是指频繁地(一天多次)将代码集成到共享仓库中。

weixin_36238982的博客 689

sonar内置ES数据查询一

ElasticHD工具安装 https://github.com/360EntSecGroup-Skylar/ElasticHD/releases/tag/1.4 [root@52-118 PRG]# ll 总用量 38632 -rwxrwxrwx. 1 root root 22772813 6月 17 2017 ElasticHD drwxrwxrwx. 9 root root 4096 12月 10 14:26 ElasticHD-1.4 -rw-r--r--. 1 root root 103

Mia专栏 1526

Windows Server 域控搭建:AD DS 规划、部署与排障实战

活动目录(AD DS)是 Windows Server 中用于集中管理账号、计算机与策略的核心目录服务,其底层依赖 DNS、Kerberos 和 LDAP 完成身份认证与资源定位。通过域控制器统一身份、组策略和权限边界,企业可显著降低多机环境下账号维护、权限分配与审计成本。十几到上百台终端、有共享隔离与合规要求的局域网,通常适合部署域控;小规模环境则未必划算。围绕域名规划、DNS 指向、OU 设计、FSMO、备份恢复和常见加域故障,域控搭建与 AD 运维需要兼顾前期规划与长期排障,才能让 Windows S

weixin_33845881的博客 790

Pyinstaller 打包 Pyzbar 时缺失 DLL 文件的排查与修复指南

本文详细解析了使用Pyinstaller打包Pyzbar库时,因缺失关键DLL文件导致程序闪退的常见问题。文章提供了从问题复现、错误诊断到最终修复的完整解决方案,核心在于通过修改.spec配置文件,手动将缺失的libzbar-64.dll等文件添加到打包过程中,确保生成的可执行文件能独立运行。

wdx012345的博客 510

jenkins+sonar+ios 基于object C(object-c-plugin-snapshot免费版)搭建

目录 1、简单介绍原理 2、sonar环境配置 3、sonar-runner环境配置 4、集成执行生成可视化报表 1、介绍原理 开题提过,我之前的oclint是通过jenkins 调度执行在我们配置的几台mac slave上的,oclint生成的报告是pmd格式,通过jenkins的插件Pbulish PMD analysis results解析和展示。

lxlmycsdnfree的博客 2717

永磁同步电机解耦控制实战:从电流反馈到内模解耦的算法演进与选型指南

本文深入探讨了永磁同步电机高性能驱动中的核心挑战——交叉耦合问题,并对比分析了电流反馈解耦和内模解耦两大主流算法的原理、性能与适用场景。文章指出,电流反馈解耦动态响应快但对参数敏感,内模解耦鲁棒性更强但略有滞后,为工程师在不同应用需求下的算法选型提供了清晰的实战指南。

weixin_29039773的博客 268

Mac安装SonarQube教程

一、SonarQube简介 SonarQube是管理代码质量的开放平台,可以快速的定位代码中潜在的或明显的错误。 SonarQube具备的功能: 不遵守代码标准(checkstyle) 潜在缺陷(空指针) 糟糕的复杂度(难以理解) 重复(通用的方法需要归纳封装) 糟糕的注释 糟糕的设计(耦合度检查) SonarQube属于代码检查的server端,并提供可视化界面;Sonar-Scanner属于client端。用于收集检查数据并且发送到server中。也就是传统的C/S关系 二、版本和下载地址 Son

sinat_34241861的博客 3079

39-Halcon-- fit_primitives_object_model_3d函数功能(从3D数据中提取几何基元)

Halcon算子fit_primitives_object_model_3d工业应用精要 该算子专为3D几何特征提取设计,支持平面、球体、圆柱等基元拟合。核心优势: 参数化输出:返回几何元素的数学参数(如平面方程、球心半径) 智能控制:通过max_dist、min_size等参数调节拟合精度 工业场景适配:针对薄壁件、孔系等提供专用优化方案 典型应用流程: 数据预处理(点云降噪/采样) 基元类型与参数设置 多阶段拟合(先平面后圆柱) 几何精度验证 误差控制在0.1%-1.2%范围内(视点云密度而定),适用于

weixin_45590420的博客 1174

AI Agent开发第85课-DeepSeek-OCR 安装全指南:从 Transformers 到 vLLM,手把手教你跑通企业级 OCR

本文系统讲解 DeepSeek-OCR 的两种部署方式——基于 Hugging Face Transformers 的标准推理与基于 vLLM 的高性能加速推理。详细说明 CUDA 与 PyTorch 版本匹配、环境验证、依赖安装等关键细节,并提供可直接运行的完整代码示例。无论你是单卡调试还是高并发服务部署,都能在这里找到清晰路径。

打造全国最全的AI Agent开发知识领域的博客 2553

SonarQube系列一、Linux安装与部署

来源:https://www.cnblogs.com/7tiny/p/11269774.html【前言】随着项目团队规模日益壮大,项目代码量也越来越多。且不说团队成员编码...

dotNET跨平台 388

微信小程序 - 强力解决wx.getLocation定位不准的问题,如何修正微信小程序wx.getLocation获取用户位置信息不准确解决办法(高精度定位还是不够精准,定位不准有偏差,彻底消除误差)

如何解决getLocation定位偏差的问题?微信小程序API—wx.getLocation定位不准的问题,微信小程序wx.getLocation获取用户位置信息不准确解决办法,解决微信小程序wx.getLocation定位不准的问题,定位不准确,实际位置偏差大,相差几公里,微信小程序wx.getLocation获取用户位置信息不准确解决办法,关于微信小程序获取准确定位的方法及解决定位不准确的问题,偏差太多好几百米,wx.getLocation 返回定位精度不准问题,如何消除这个误差,开启高精度定位依旧有误

🏆 前端领域优质创作者 1万+

开源代码审查工具Sonarqube简单使用

Your teammate for Code Quality and Code Security

Braycep的博客 7007

将Keil中的变量数组导出

首先,写好导出数据的函数。

小柚子的博客 1962

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

【Jenkins持续集成(一)】SonarQube 入门安装使用教程

一、前言 持续集成管理平台不只是CI服务器,是一系列软件开发管理工具的组合。 源码版本管理:svn、git 项目构建工具:Maven、Ant 代码质量管理:Sonar(Checkstyle、PMD、FindBugs……) 持续集成引擎:Hudson、Jenkins、Apache Continuum 应用持续部署:操作系统、JDK、Tomcat、JBoss… 注:实现持续集成过程中还要用到其他各种工...

郑清 1985

数学建模模型总结

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

Jenkins+SonarQube代码审查

Jenkins+SonarQube代码审查安装SonarQube安装MySQL安装SonarQube实现代码审查环境配置在项目添加SonaQube代码审查(非流水线项目)在项目添加SonaQube代码审查(流水线项目) SonarQube是一个用于管理代码质量的开放平台,可以快速的定位代码中潜在的或者明显的错误。 目前支持java,C#,C/C++,Python,PL/SQL,Cobol,JavaScrip,Groovy等二十几种编程语言的代码质量管理与检测 官网:https://www.sonarqu

611 - 菜鸟运维逆袭架构师之路 2282

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

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

【深度踩坑】手把手教你最高版本Sonarqube9安装!(多图预警)

【深度踩坑】手把手教你最高版本Sonarqube9安装!(多图预警) 去发现同类优质开源项目:https://gitcode.com/ 项目介绍 在软件开发的世界里,代码质量是确保项目成功的关键因素之一。Sonarqube 9作为一款强大的代码质量分析工具,能够帮助开发者识别代码中的潜在问题,提升代码的可维护性和稳定性。然而,安装和配置Sonarqube 9可能会遇到各种挑战。为了帮助开发者顺利完...

gitblog_06565的博客 426

SonarQube代码质量管理平台搭建手册(集成jenkins进行自动化代码审查)

SonarQube代码质量管理平台搭建手册(集成jenkins进行自动化代码审查)1.安装SonarQube1.1 步骤1 准备好java环境(本次测试系统为windows,linux环境下可参照windows步骤) 1.2 步骤2 进入官网下载SonarQube,解压到目录D:\sonar\sonar5.4(可解压到任意目录) 1.3 步骤3 修改D:\sonar\sonar

lubing36的博客 3621
上一篇: http长连接
下一篇: SpringBoot自动配置的原理及实现以及SpringBoot3.0的变化
牧竹子
博客等级 码龄17年 573粉丝 235原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址