nexus3.15安装与使用

超详细 | 使用Nexus搭建私服 (带代码演示) 在企业开发的过程中,不是所有公司都能直接访问外网。在这种情况下,就需要在局域网内找一台有外网访问权限的服务器,搭建Nexus私服仓库,开发人员连接到这台私服上,通过搭建的Nexus私服访问远程仓库。并且,我们要知道,内网的速度,是不同于外网,外网可能会受到公开网络的攻击,并且传输速度也远低于内网。其次,我们需要上传第三方Jar包到maven仓库,若上传至公网,数据会有泄露的风险,若在私服,数据安全性会大大提高!Nexus简介Nexus是Sonatype公司的一款用于搭建私服的产品,使用非常广泛。 阅读详情

一、nexus3.15安装

1.1 下载

下载地址
https://www.sonatype.com/products/repository-oss-download?hsLang=en-us
我试了下载不下来,网上找了一个,在百度网盘

1.2 安装

1.2.1 jdk和maven安装

JDK安装链接:https://blog.youkuaiyun.com/martinlinux/article/details/115161249

maven安装链接:https://blog.youkuaiyun.com/martinlinux/article/details/120539512

1.2.2 nexus安装

tar xvfz nexus-3.15.2-01-unix.tar.gz
mkdir /data/nexus-3.15
mv nexus-3.15.2-01 sonatype-work /data/nexus-3.15

1.2.3 创建用户

useradd nexus -s /sbin/nologin
chown -R nexus /data/nexus-3.15

1.2.4 修改配置

1.2.4.1 修改端口
cd /data/nexus-3.15/nexus-3.15.2-01/etc
cp nexus-default.properties nexus-default.properties-bak
vim nexus-default.properties

## DO NOT EDIT - CUSTOMIZATIONS BELONG IN $data-dir/etc/nexus.properties
##
# Jetty section
application-port=9090		##Nexus服务监听的端口  默认是8081
application-host=0.0.0.0	##Nexus服务监听的主机
nexus-args=${jetty.etc}/jetty.xml,${jetty.etc}/jetty-http.xml,${jetty.etc}/jetty-requestlog.xml
nexus-context-path=/		##Nexus服务的上下文路径,这个路径跟访问的时候有关系,如果修改错之后会访问不到

# Nexus section
nexus-edition=nexus-pro-edition
nexus-features=\
 nexus-pro-feature
1.2.4.2 设置系统内核,这个是根据日志报警自己设置的
加入以下配置,注意这是设置的nexus用户的
vim /etc/security/limits.conf
nexus    soft   nproc 2047
nexus    hard   nproc 1638423
nexus    soft   nofile 1024
nexus    hard   nofile 65536
1.2.4.3 设置运行用户
cd /data/nexus-3.15/nexus-3.15.2-01/bin
vim nexus.rc
#默认是root用户启动
run_as_user="nexus"
1.2.4.4 数据存储路径

这个配置文件可修改占用内存,存储,日志的位置

cd /data/nexus-3.15/nexus-3.15.2-01/bin
vim nexus.vmoptions 

-Xms1200M			##可根据自己服务器设置
-Xmx1200M
-XX:MaxDirectMemorySize=2G
-XX:+UnlockDiagnosticVMOptions
-XX:+UnsyncloadClass
-XX:+LogVMOutput
-XX:LogFile=../sonatype-work/nexus3/log/jvm.log
-XX:-OmitStackTraceInFastThrow
-Djava.net.preferIPv4Stack=true
-Dkaraf.home=.
-Dkaraf.base=.
-Dkaraf.etc=etc/karaf
-Djava.util.logging.config.file=etc/karaf/java.util.logging.properties
-Dkaraf.data=../sonatype-work/nexus3			##存储位置(根据自己的需求改,我测试的时候,这个相对路径是bin的上一层目录,不知道是否跟上下文路径有关系)
-Djava.io.tmpdir=../sonatype-work/nexus3/tmp
-Dkaraf.startLocalConsole=false

1.2.5 设置开启启动

cat << eof > /lib/systemd/system/nexus.service
[Unit]
Description=nexus
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
LimitNOFILE=65536
ExecStart=/data/nexus-3.15/nexus-3.15.2-01/bin/nexus start
ExecReload=/data/nexus-3.15/nexus-3.15.2-01/bin/nexus restart
ExecStop=/data/nexus-3.15/nexus-3.15.2-01/bin/nexus stop
Restart=on-failure
User=nexus
[Install]
WantedBy=multi-user.target
eof

systemctl daemon-reload 
systemctl enable nexus.service
systemctl status nexus.sevice

1.2.6 访问

nexus3.X的默认端口是:8081
nexus3.X的默认账号是:admin
nexus3.X的默认密码是:admin123
从3.17版本开始默认密码不再是admin123,密码是随机生成。首次登录页面会显示admin用户的密码在/nexus-data/admin.password

二、说明

2.1 仓库说明

默认仓库/data/nexus/sonatype-work/nexus
apache-snapshots central central-m1 public releases snapshots thirdparty

1) public Repositories:类型为group,这个可以理解为仓库的集合,可以把其他仓库加入到这个组里对外展示。
大部分的终端用户,只需要配置上面这一个单独的组合后的URL,而不是单独配置多个仓库。用户也不需要知道某个jar包具体来源于maven中央仓库,或者是Apache Snapshots,或者是我们自己添加的其他仓库。
这样的好处在于:如果我们要新增某个仓库(如开源中国、阿里云),客户端不需要做任何更改,只需要在nexus上将要新增的仓库加入到对外提供服务的仓库group中就可以了。

2) 3rd party与 Releases和Snapshots一样,类型为hosted,意思是由nexus本机管理的仓库。该仓库用于商业化的,第三方提供的非开源的依赖仓库,如oracle jdbc driver。

3) Release 用于存放开发团队内部用的正式版的依赖。

4) Snapshots= 用于存放开发团队内部日常构建的频率更新较快的依赖包。

5) Apache Snapshots 和 Central 类型都是proxy,意思是远端仓库的代理。前者包含了Apache Software Foundation发布的快照版本,后者为Maven中央仓库,我们平时maven默认就是连接的该仓库。

6) Central M1 Shadow类型为virtual,意思是只是已有仓库的一个不同呈现方式的映射。

三、Nexus 使用

3.1 创建docker Repositories

3.1.1 创建镜像存储目录

点击齿轮 - Repositorie - Blob Stores - Create blob store
指定用于存储镜像的目录
在这里插入图片描述

3.1.2 创建docker repo

  1. 点击齿轮 - Repositories - Create repository - 选择 docker (hosted)
    在这里插入图片描述
    在这里插入图片描述

Name: 仓库的名称
HTTP: 仓库单独的访问端口
Enable Docker V1 API: 如果需要同时支持 V1 版本请勾选此项(不建议勾选)。
Hosted -> Deployment pollcy: 请选择 Allow redeploy 否则无法上传 Docker 镜像。
其它的仓库创建方法请各位自己摸索,还可以创建一个 docker (proxy) 类型的仓库链接到 DockerHub 上。再创建一个 docker (group) 类型的仓库把刚才的 hosted 与 proxy 添加在一起。主机在访问的时候默认下载私有仓库中的镜像,如果没有将链接到 DockerHub 中下载并缓存到 Nexus 中。
编写信息完成后选择“Create repository”按钮。
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

3.1.3 创建用于上传的账号

  1. 创建角色和账号
    点击security - 点击Realms菜单 - 把 Docker Bearer Token Realm 移到右边的框中点击Save保存。
    在这里插入图片描述

  2. 添加用户规则:菜单 Security->Roles->Create role 在 Privlleges 选项搜索 docker 把相应的规则移动到右边的框中然后保存
    在这里插入图片描述
    在这里插入图片描述

  3. 添加用户:菜单 Security->Users->Create local user 在 Roles 选项中选中刚才创建的规则移动到右边的窗口保存
    在这里插入图片描述
    在这里插入图片描述

3.1.4 docker配置私服

  1. 更改docker配置添加docker私服
vim /etc/docker/daemon.json
加入以下配置
"insecure-registries":["192.168.8.20:9091"]

systemctl restart docker
以下命令可以查看是否添加成功
docker info
  1. 登录
docker 默认的仓库不是咱们添加的这个所以登录需要注明仓库地址
docker login -u docker_images_user01 -p 123456 192.168.8.20:9091
或docker login 192.168.8.20:9091

退出:docker logout 192.168.8.20:9091
  1. 上传
4. 查看本地镜像
[root@node02 ~]# docker images
REPOSITORY                                                       TAG                 IMAGE ID            CREATED             SIZE
nginx                                                            1.16                dfcfd8e9a5d3        23 months ago       127MB

5. 将本地镜像修改
docker tag nginx:1.16 192.168.8.20:9091/nginx/nginx:1.16

6. 查看是否成功
[root@node02 ~]# docker images
REPOSITORY                                                       TAG                 IMAGE ID            CREATED             SIZE
192.168.8.20:9091/nginx/nginx                                    1.16                dfcfd8e9a5d3        23 months ago       127MB
nginx                                                            1.16                dfcfd8e9a5d3        23 months ago       127MB

7. 上传
规划好自己上传的镜像目录
docker push 192.168.8.20:9091/nginx/nginx:1.16

在这里插入图片描述

Sonatype Nexus2 升级Nexus3 迁移和升级完整过程 停用操作系统为CentOs6 的服务器,迁移到UOS操作系统的服务器CentOs6 服务器 根据官方说明 2.x 系列在2025.6.30 停止维护,且不能直接升级到3.x。升级思路:新服务器安装2.x系列最新版本,迁移旧服务器2.5版本仓库数据到新服务器2.15。再升级到3.76版本,迁移2.15的数据到3.76。 阅读详情

相关推荐

Nexus Repository Manager OSS 3.x - Windows 安装配置

1、私服简介 私服是架设在局域网的一种特殊的远程仓库,目的是代理远程仓库及部署第三方构件。有了私服之后,当Maven需要下载构件时,直接请求私服,私服上存在则下载到本地仓库;否则,私服请求外部的远程仓库,将构件下载到私服,再提供给本地仓库下载。 我们可以使用专门的Maven仓库管理软件来搭建私服,比如:Apache Archiva,Artifactory,Sonatype Nexus。...

一一丁点的博客 4166

maven私有仓库nexus3.5搭建与使用

maven私有仓库nexus3.5搭建与使用参考网址: http://blog.csdn.net/clj198606061111/article/details/52200928 http://www.cnblogs.com/jingmoxukong/p/6050172.html http://blog.csdn.net/north_eagle/article/details/42428219

wenwenxiong的专栏 4666

nexus-3.15.2-01-unix.tar.gz.zip

官方原版nexus下载: nexus-3.15.2-01-unix.tar.gz 因nexus官网无法下载、csdn上的下载积故而上传一个。希望帮到大家~ 注意:要先解压

nexus 的安装使用以及

文章目录CentOS7 下安装 nexusjava环境安装nexusnexus 使用Maven 配置上传到nexus从nexus下载 CentOS7 下安装 nexus java环境 检查java环境 java -version 注意: java的版本必须为1.8 查看yum源中是否有相关套件 yum -y list java* 安装java8 yum -y install java-1.8.0-openjdk-devel.x86_64 安装nexus 下载地址 https://help.son

weixin_42555971的博客 1162

nexus-3.15.2-win64.rar

nexus-3.15.2-win64.rar官网对应的最新版nexus私服包用于配置私服。要在局域网里找一台有外网权限的机器,搭建nexus私服,然后开发人员连到这台私服上,这样的话就可以通过这台搭建了nexus私服的电脑访问maven的远程仓库。

nexus-3.15.2-01-linux.zip

官方原版nexus下载: nexus-3.15.2-01-unix.tar.gz 因nexus官网无法下载,希望帮助大家,先用unzip进行解压

maven私服nexus的安装和配置

知识点概要: 私服的使用场景 nexus 下载安装 nexus 仓库介绍 本地远程仓库配置 发布项目至nexus 远程仓库 关于SNAPSHOT(快照)与RELEASE(释放) 版本说明 1、私服使用场景 私服使用场景如下: 1、公司不能连接公网,可以用一个私服务来统一连接 2、公司内部jar 组件的共享 2、nexus 下载安装 nexus 下载地址: nexus-...

Marlon康 690

nexus-3.15.2-01.rar

官方原版nexus下载: nexus-3.15.2-01-unix.tar.gz 因nexus官网无法下载、csdn上的下载积分贼鸡贵 故而上传一个。希望帮到大家~ 注意:要先解压

Nexus下载、安装与使用

初识Nexus

lovelife000的博客 3万+

nexus-3.5.0-02-unix.tar.gz.zip

使用:将下载的压缩包解压到当前目录,然后进入文件夹即可看到 nexus-3.18.0-01-mac.tgz nexus-3.18.0-01-win64.zip nexus-3.18.0-01-unix.tar.gz nexus-2.14.5-02.war nexus-2.14.13-01-bundle.zip nexus-2.14.13-01-bundle.tar nexus-3.15.2-01-win64.zip nexus-3.15.2-01-unix.tar.gz nexus-3.15.2-01-mac.tgz nexus-3.5.0-02-mac.tgz nexus-3.5.0-02-unix.tar.gz nexus-3.5.0-02-win64.zip 等我都有,可以看我发布的下载

nexus-3.59.0-01-win64.zip

nexus-3.59.0-01-win64.zip,Nexus Repository Manager OSS 3.x for Windows系统

Nexus下载与安装详解

目前 Nexus 分为 Nexus 2.x 和 Nexus 3.x 两个大版本,在以往框架,有了3.x一定不会再更新2.x了,会继续向上延续3.x,4.x,而Nexus对于这两个版本是并行的关系。也就是2.x在更新迭代,3.x也在更新迭代,两个大的版本互不影响!两个版本连ui界面都不一样,但是其功能是一样的。

怪咖@的博客 4万+

字节跳动程序媛教你如何刷算法题:面试手撕代码我就没怕过

本人上一次刷题还是大一的C语言期末考试……但是面试中算法考核截止上岸前一直保持着100%正确率的光辉记录。 本文将给你指明一条刷题的决胜指南。并从算法的重要性、题库的选择以及刷题的三大步骤分别进行讲解,彻底解决你所有关于面试算法所有的困扰。

Stay Hungry Stay Foolish 求知若饥 虚心若愚 2万+

Nexus()下载与安装详解

目前 Nexus 分为 Nexus 2.x 和 Nexus 3.x 两个大版本,在以往框架,有了3.x一定不会再更新2.x了,会继续向上延续3.x,4.x,而Nexus对于这两个版本是并行的关系。也就是2.x在更新迭代,3.x也在更新迭代,两个大的版本互不影响!两个版本连ui界面都不一样,但是其功能是一样的。Nexus 分为了pro和版本,其中oss是开源免费的,pro是收费的。

weixin_65644655的博客 1万+

基于Codex Skill的抖音爆款分析与带货视频自动化生成实战

这次我们来看一个基于 Codex 的自动化内容创作项目。核心是利用 Codex 平台的能力,通过自定义的 Skill(技能)来拆解抖音爆款博主的视频模式,并自动生成自己的带货视频。对于内容创作者、电商运营或对短视频自动化感兴趣的技术开发者来说,这是一个将大语言模型(LLM)能力与具体业务场景深度结合的实战案例。 项目的核心价值在于流程自动化。它试图解决一个常见痛点:分析爆款视频的脚本结构、话术、节奏需要大量人工,而模仿创作又耗时费力。通过 Codex 的 Skill 机制,可以将“分析”和“生成”这两个环节

weixin_30420305的博客 380

JLINK/SWD/STLINK下载选项区别

摘要: 本文对比了JLINK/SWD/STLINK的6种下载模式:Normal(硬件复位)、Hot plug(无复位)、Under reset(持续复位后连接)、Software reset(软件复位)、Hardware reset(全复位)和Core reset(内核复位)。重点分析了各模式的操作逻辑、适用场景及注意事项,其中Under reset模式是解决SWD禁用/程序异常的首选方案。通过对比表归纳了复位范围、NRST操作等核心差异,并给出场景选择建议:排查连接问题优先选Under reset,常规调

亚洲程序员盟主得博客 394

【免费下载】 Nexus下载与安装详解

Nexus下载与安装详解 【下载地址】Nexus下载与安装详解 本资源文件提供了Nexus的下载与安装详解,涵盖了Nexus 2.x和Nexus 3.x两个主要版本的下载、安装步骤以及在Windows系统下的使用方法。Nexus是一个流行的Maven仓库管理工具,用于存储和获取软件包、库文件和其他项目相关的资源 ...

gitblog_06590的博客 2083

解放双手,摆脱自建库的繁琐,立创EDA元件库转cadence原理图封装库实战技巧

解放双手,摆脱自建库的繁琐,立创EDA元件库转cadence原理图封装库实战技巧

u012790770的博客 3612

Nexus3.x批量导入本地库

Nexus2.x批量导入本地库是十分容易的,将库文件夹复制到对应nexus库下面,去网页刷新一下索引就OK了,这里不做赘述。在nexus3.x中,我们不可以这么操作,但是我们可以使用shell脚本,批量导入nexus3.x。 我们从下载安装一步步来说明,如果你已经安装好nexus3.x,只想知道批量导入本地库的方法,请移步文章第四部分 1.环境说明       主机:Win10    虚拟机...

u014468095的博客 2万+

Fluent基于低氧舱气体交换仿真(氮气与空气混合)

一、背景概述 模拟低氧舱充氮气和排除混合气体的过程,假设注入95%的氮气,舱内原有气体为空气,压力为标准大气压,温度为300K。观察气体注入过程中,舱内平均氮气和氧气浓度的变化。 二、Fluent设置 Setup 1、General type选择压力基 绝对速度 瞬态 重力勾选 2、Model 能量方程开启 组分运输开启,设置方法如下: 选择后OK,view就会变成Edit,点击Edit。然后再次点击Edit。 将组分中的非氮气氧气和空气的气体移除,右边选项需要将空气放在最后一位。 3、Materi

qq_35535616的博客 1万+

ROS小车定位实战:如何用rf2o_laser_odometry和robot_localization实现精准里程计(附避坑指南)

本文详细介绍了如何利用rf2o_laser_odometry和robot_localization在ROS中实现高精度小车定位。通过激光里程计与状态估计的黄金组合,解决室内移动机器人的定位难题,包括环境搭建、算法配置、多传感器融合策略及实战避坑指南,帮助开发者快速部署稳定可靠的定位系统。

weixin_29081703的博客 285

linux nexus端口配置,Linux下安装Nexus-3.15私服

1、切换到root用户创建nexus用户:useradd nexus设置nexus用户密码:passwd nexus2、创建文件夹并进入该目录linux中,软件包一般放在opt目录下,安装时,一般放到usr/local 这个目录下,类似于windows的 program files,所以在/usr/local下创建nexus目录cd /root/usr/local && mkdir...

weixin_42397141的博客 1200

Ubuntu零基础教学-史上最详Ubuntu20.04安装教程,超级详细,强烈建议收藏!

官网地址:https://www.vmware.com/ 1、VMware Workstation Pro 15.5.1在Windows 10的安装不再介绍了,一路下一步即可。 2、下面详细介绍在VMware 虚拟机里安装Ubuntu 20.04 LTS的步骤

**My Coding Family** 2万+

Linux下安装Nexus-3.15私服

1、切换到root用户   创建nexus用户:useradd nexus   设置nexus用户密码:passwd nexus 2、创建文件夹并进入该目录 linux中,软件包一般放在opt目录下,安装时,一般放到usr/local 这个目录下,类似于windows的 program files,所以在/usr/local下创建nexus目录cd /root/usr/local &a...

weixin_33910137的博客 493

把 ABAP SQL 窗口函数讲透:从 OVER 到 LEAD、RANK 与累计分析

ABAP SQL窗口函数在不丢失明细记录的前提下,为每行数据提供组内统计和排名功能。它通过OVER子句定义计算窗口,支持三类函数:聚合型(AVG/SUM等)、排名型(ROW_NUMBER/RANK等)和取值型(LEAD/LAG)。相比GROUP BY会合并多行数据,窗口函数保留原始记录同时附加计算结果,特别适合需要保留明细又要展示统计信息的业务场景,如销售排名、客户分层分析等。语法核心是OVER子句,通过PARTITION BY分组,ORDER BY排序,可灵活定义计算范围。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 1272

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

上一篇: MySQL5.7安装及主从复制
下一篇: nexus-2.14安装使用备份迁移
TimeRovers
博客等级 码龄8年 11粉丝 43原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值