【Maven】使用Maven构建多模块项目(经典)

Maven环境下构建多模块项目 如果没有指定,就会默认使用该依赖范围。使用此依赖范围的Maven依赖, 对于编译,测试,运行都有效。使用此依赖范围的Maven依赖,对于编译和测试有效, 但在运行时无效。使用此依赖范围的Maven依赖,对于测试和运行有效, 但在编译代码时无效。Maven会解析各个直接依赖的POM,将那些必要的间接依赖,以传递性依赖的形式引入到当前项目中。1. groupId, artifactId, version : 依赖的基本坐标, 对于任何一个依赖来说,基本坐标是最重要的, Maven根据坐标才能找到需要的依赖。 阅读详情

来源:https://www.cnblogs.com/h--d/p/6001366.html

https://blog.youkuaiyun.com/dhklsl/article/details/78039224

Maven Build  Goals:

                 clean  清除编译,compile  编译,test  编译并测试,install 打包并发送到本地仓库,package 只是打成jar包,并不会发送到本地仓库

Maven多模块项目

  Maven多模块项目,适用于一些比较大的项目,通过合理的模块拆分,实现代码的复用,便于维护和管理。尤其是一些开源框架,也是采用多模块的方式,提供插件集成,用户可以根据需要配置指定的模块。

  项目结构如下:

      test-hd-parent   (父级)
             ---pom.xml
             ---test-hd-api          (第三方接口层)
                    ----pom.xml    
           ---test-hd-foundation     (基础工具层)
                    ----pom.xml
             ---test-hd-resource     (资源层) 
                    ----pom.xml
             ---test-hd-service       (逻辑业务层)
                    ----pom.xml
           ---test-hd-modules     (web层)
                    ----pom.xml
                ---test-hd-www         (web模块1)
                            ----pom.xml
                ---test-hd-admin        (web模块2)
                            ----pom.xml     

创建一个父maven工程

  •   新建一个maven项目,选择存储位置,并选择创建一个简单的maven工程

    

  •   输入Group Id、Artifact Id、Packaging,packaging选择pom包

    

  •   生成父工程,pom.xml如下

    

  •   删除工程中的src 目录

    

创建子模块

  •   右击父工程名---》New---》Project,然后选择新建一个maven module工程

    

  •   设置子工程名以及父工程,再设置快速创建模式

    

  •   得到子工程(test-hd-api,第三方接口层),设置编译的jdk

    

  •   同理设置,子模块:test-hd-foundation(基础工具层)、test-hd-resource(资源层) 、test-hd-service(逻辑业务层)
  •   新建test-hd-modules (web层),选择创建一个a simple project,输入Group Id、Artifact Id、Packaging,packaging选择pom包

        

创建web子模块

  •   web子模块在建在test-hd-modules (web层)里面,右击test-hd-modules 工程名---》New---》Project,然后选择新建一个maven module工程,设置子工程名以及父工程,选择新建web项目

    

    

 

配置个模块的依赖

  •   在parent项目pom.xml中建立依赖管理(dependencyManagement)

    复制代码

     1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     2     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     3     <modelVersion>4.0.0</modelVersion>
     4     <groupId>com.hd</groupId>
     5     <artifactId>test-hd-parent</artifactId>
     6     <version>0.0.1-SNAPSHOT</version>
     7     <packaging>pom</packaging>
     8     <modules>
     9         <module>test-hd-api</module>
    10         <module>test-hd-service</module>
    11         <module>test-hd-resource</module>
    12         <module>test-hd-foundation</module>
    13         <module>test-hd-modules</module>
    14     </modules>
    15 
    16 
    17     <!-- maven依赖 -->
    18     <dependencyManagement>
    19 
    20         <dependencies>
    21             <!-- hd -->
    22             <dependency>
    23                 <groupId>com.hd</groupId>
    24                 <artifactId>test-hd-api</artifactId>
    25                 <version>0.0.1-SNAPSHOT</version>
    26             </dependency>
    27 
    28             <dependency>
    29                 <groupId>com.hd</groupId>
    30                 <artifactId>test-hd-service</artifactId>
    31                 <version>0.0.1-SNAPSHOT</version>
    32             </dependency>
    33 
    34             <dependency>
    35                 <groupId>com.hd</groupId>
    36                 <artifactId>test-hd-resource</artifactId>
    37                 <version>0.0.1-SNAPSHOT</version>
    38             </dependency>
    39 
    40             <dependency>
    41                 <groupId>com.hd</groupId>
    42                 <artifactId>test-hd-foundation</artifactId>
    43                 <version>0.0.1-SNAPSHOT</version>
    44             </dependency>
    45 
    46             <!-- Servlet -->
    47             <dependency>
    48                 <groupId>javax.servlet</groupId>
    49                 <artifactId>javax.servlet-api</artifactId>
    50                 <version>3.0.1</version>
    51                 <scope>provided</scope>
    52             </dependency>
    53             <dependency>
    54                 <groupId>javax.servlet.jsp</groupId>
    55                 <artifactId>jsp-api</artifactId>
    56                 <version>2.2</version>
    57                 <scope>provided</scope>
    58             </dependency>
    59 
    60             <!-- jstl -->
    61             <dependency>
    62                 <groupId>javax.servlet</groupId>
    63                 <artifactId>jstl</artifactId>
    64                 <version>1.2</version>
    65             </dependency>
    66 
    67             <dependency>
    68                 <groupId>taglibs</groupId>
    69                 <artifactId>standard</artifactId>
    70                 <version>1.1.2</version>
    71             </dependency>
    72 
    73             <dependency>
    74                 <groupId>junit</groupId>
    75                 <artifactId>junit</artifactId>
    76                 <version>3.8.1</version>
    77                 <scope>test</scope>
    78             </dependency>
    79 
    80         </dependencies>
    81     </dependencyManagement>
    82 
    83 </project>

    复制代码

     

  •     test-hd-foundation中的依赖

    复制代码

     1 <?xml version="1.0"?>
     2 <project
     3     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
     4     xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     5     <modelVersion>4.0.0</modelVersion>
     6     <parent>
     7         <groupId>com.hd</groupId>
     8         <artifactId>test-hd-parent</artifactId>
     9         <version>0.0.1-SNAPSHOT</version>
    10     </parent>
    11     <artifactId>test-hd-foundation</artifactId>
    12 
    13     <dependencies>
    14 
    15         <!-- servlet -->
    16         <dependency>
    17             <groupId>javax.servlet</groupId>
    18             <artifactId>jstl</artifactId>
    19         </dependency>
    20 
    21         <dependency>
    22             <groupId>taglibs</groupId>
    23             <artifactId>standard</artifactId>
    24         </dependency>
    25 
    26         <dependency>
    27             <groupId>junit</groupId>
    28             <artifactId>junit</artifactId>
    29         </dependency>
    30     </dependencies>
    31 
    32     <build>
    33         <plugins>
    34             <!-- define the project compile level -->
    35             <plugin>
    36                 <groupId>org.apache.maven.plugins</groupId>
    37                 <artifactId>maven-compiler-plugin</artifactId>
    38                 <version>2.3.2</version>
    39                 <configuration>
    40                     <source>1.7</source>
    41                     <target>1.7</target>
    42                 </configuration>
    43             </plugin>
    44         </plugins>
    45     </build>
    46 </project>

    复制代码

     

  •     test-hd-api中的依赖关系

     View Code

     

  •     test-hd-resource中的依赖关系

     View Code

     

  •     test-hd-service中的依赖关系

     View Code

     

  •   test-hd-module中的依赖关系

    复制代码

     1 <?xml version="1.0" encoding="UTF-8"?>
     2 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     3     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     4     <modelVersion>4.0.0</modelVersion>
     5     <parent>
     6         <groupId>com.hd</groupId>
     7         <artifactId>test-hd-parent</artifactId>
     8         <version>0.0.1-SNAPSHOT</version>
     9     </parent>
    10 
    11     <artifactId>test-hd-modules</artifactId>
    12     <packaging>pom</packaging>
    13 
    14     <modules>
    15         <module>test-hd-www</module>
    16         <module>test-hd-admin</module>
    17     </modules>
    18 
    19     <dependencies>
    20 
    21         <dependency>
    22             <groupId>com.hd</groupId>
    23             <artifactId>test-hd-foundation</artifactId>
    24         </dependency>
    25 
    26         <dependency>
    27             <groupId>com.hd</groupId>
    28             <artifactId>test-hd-service</artifactId>
    29         </dependency>
    30         <dependency>
    31             <groupId>com.hd</groupId>
    32             <artifactId>test-hd-api</artifactId>
    33         </dependency>
    34 
    35         <dependency>
    36             <groupId>com.hd</groupId>
    37             <artifactId>test-hd-resource</artifactId>
    38         </dependency>
    39 
    40         <!-- servlet -->
    41         <dependency>
    42             <groupId>javax.servlet</groupId>
    43             <artifactId>jstl</artifactId>
    44         </dependency>
    45 
    46         <dependency>
    47             <groupId>taglibs</groupId>
    48             <artifactId>standard</artifactId>
    49         </dependency>
    50 
    51         <dependency>
    52             <groupId>junit</groupId>
    53             <artifactId>junit</artifactId>
    54         </dependency>
    55 
    56     </dependencies>
    57 </project>

    复制代码

     

  •     test-hd-www中的依赖关系

    复制代码

     1 <?xml version="1.0"?>
     2 <project
     3     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
     4     xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     5     <modelVersion>4.0.0</modelVersion>
     6     <parent>
     7         <groupId>com.hd</groupId>
     8         <artifactId>test-hd-modules</artifactId>
     9         <version>0.0.1-SNAPSHOT</version>
    10     </parent>
    11     <artifactId>test-hd-www</artifactId>
    12     <packaging>war</packaging>
    13 
    14     <build>
    15         <plugins>
    16             <!-- define the project compile level -->
    17             <plugin>
    18                 <groupId>org.apache.maven.plugins</groupId>
    19                 <artifactId>maven-compiler-plugin</artifactId>
    20                 <version>2.3.2</version>
    21                 <configuration>
    22                     <source>1.7</source>
    23                     <target>1.7</target>
    24                 </configuration>
    25             </plugin>
    26         </plugins>
    27         <finalName>test-hd-www</finalName>
    28     </build>
    29 
    30 </project>

    复制代码

     

  •     最后使用maven-update整个工程,右击父工程名--》Maven--》Update Project

    

打包和发布

  •   打包,右击父工程名 test-hd-parent---->Run As--->Maven Install

   

 

  •   打包web子工程,右击工程名test-hd-www--->Run As ---> Maven Build...---> Goals: clean package--->Run

      

      

 

  •   右击工程名test-hd-www,进行刷新,找到war包,放到tomcat的webapps中,启动tomcat,即可访问工程http://localhost:8080/test-hd-www

    

  •   可以去tomcat下面webapps》test-hd-www》WEB-INF》lib中,看到引用的jar包

    

 

 

 

 

 

     

    

 

Maven多模块项目经验 最近被一个多模块项目搞的头晕眼花,最后经过多次摸索终于发现了如何使用maven来创建多模块的项目。现在把一些经验和教训总结一下供后来人借鉴和指教。 maven的作用 毋庸置疑,maven是用来创建一个项目的基本构架以使得这个工程可以方便的重复构建。 maven的生命周期 谈到项目,不得不提到一个基本项目的生命周期,也就是说在项目被maven打包成jar, war等等不同的包装的时候 阅读详情

相关推荐

eclipse导入SVN上的Maven多模块项目

一、SVN上Maven多模块项目结构 使用eclipse导入SVN上的Maven多模块项目 Maven多模块项目所在SVN目录 二、eclipse通过SVN导入到工作空间 工作空间位于F:/HPCWorkspace 2.1 File->Import,选择从SVN检出项目下载  2.2 选择/新建SVN资源库位置 如果资源库还没创建好,选择创建新的资源库位置,如果已经创

nomoneyhua的博客 1万+

5.Maven环境下构建多模块项目

使用maven提供的多模块构建的特征完成maven环境下多模块的项目的管理和构建 这里以四个模块为例来搭建项目,以达到通俗易懂的初衷 模块 maven_parent -- 基模块,也就是常说的parent (pom) 模块 maven_dao -- 数据库访问层,例如jdbc操作(jar) 模块 maven_service -- 项目的业务逻辑层(jar) 模块 maven_controller -- 用来接收请求,相应数据(war) 1.创建maven_parent项目

qq_51274606的博客 3422

构建多模块Java项目实战:使用Maven工具

Maven Archetype插件是Maven中用于项目模板创建的核心工具,它允许开发者生成项目骨架的初始结构。通过Archetype插件,用户可以定义一组可重用的项目模板,其中包含了项目文件、目录结构、POM文件配置等。这些模板可以被配置为特定类型的应用程序,从而实现快速生成新项目和重用已有的配置和代码片段。Archetype模板可以是自定义的,也可以是官方提供的或者第三方社区贡献的,极大地简化了项目初始化的步骤。

weixin_29317963的博客 786

如何使用Maven创建多模块项目

使⽤maven 提供的多模块构建的特性完成maven 环境下多个模块的项⽬的管理与构建。这⾥以四个模块为例来搭建项⽬,以达到通俗易懂的初衷模块 maven_parent —– 基模块,就是常说的parent (pom)模块 maven_dao —– 数据库的访问层,例如jdbc操作(jar)模 块 maven_service —– 项⽬的业务逻辑层 (jar)模块 maven_controller —– ⽤来接收请求,响应数据 (war)

来都来了 3411

Spring Boot与Maven多模块项目构建精讲

htmltable {th, td {th {pre {简介:本文深入解析了Spring Boot与Maven结合实现多模块项目的方法。通过”springboot-multimodule-maven”项目案例,详细介绍了模块类型、依赖管理、版本控制、模块划分、CI/CD集成以及测试等最佳实践。学习本课程,开发者可以掌握构建和管理大型Java项目的关键技能。

weixin_42348783的博客 1169

创建maven多模块项目的实战演练

本文还有配套的精品资源,点击获取 简介:Maven作为Java开发的构建工具,采用标准目录结构和XML配置文件(pom.xml)管理项目构建。在大型项目中,多模块结构有助于提高模块化、复用性和可维护性。本文实例演示了如何创建一个基于SSM框架的简单maven多模块项目,并详细介绍了模块间关系、继承以及如何通过Maven命令管理项目构建。 1. Maven介绍及构建...

weixin_28939623的博客 895

使用 Maven 构建多模块项目

一、概述 在本教程中,我们将学习如何使用 Maven 构建多模块项目。 首先,我们将讨论什么是多模块项目,并看看遵循这种方法的好处。然后我们将设置我们的示例项目。有关 Maven 的良好介绍,请查看本教程。 2. Maven的多模块项目 多模块项目由管理一组子模块的聚合器 POM 构建。在大多数情况下,聚合器位于项目的根目录中,并且必须具有pom类型的打包。 子模块是常规的 Maven 项目,它们可以单独构建,也可以通过聚合器 POM 构建。 通过聚合器 POM 构建项目,每个具有与p.

allway2的博客 8275

四阶龙格库塔法求解一次常微分方程组(python实现)

之前在博客发布了关于使用四阶龙格库塔方法求解一次常微分方程组的文章,由于代码缺少具体的验证,部分朋友可能存在疑问,因此这里打算再重新写一篇博客来验证一下程序的正确性,另外,这里是使用python语言来实现的。

HelloWorldTM的博客 8541

【Maven】多模块项目的构建

本文详细讲解了Maven多模块项目的构建流程。

m0_46308522的博客 1446

(UE5 5.2)HISM Mobile DrawInstance在渲染层的实现浅分析

在 (UE4 4.27) UHierarchicalInstancedStaticMesh(HISM)原理分析 这篇博客大致介绍HISM组件从游戏线程到渲染线程的重建KD-Tree和剔除并提交DrawCall逻辑,但是没有分析渲染层的大致数据结构和实现. 可以看出FHierarchicalStaticMeshSceneProxy 实际存储Instance数组数据来自于FInstancedStaticMeshSceneProxy FHierarchicalStaticMeshSceneProxy只是以FClu

qq_29523119的博客 2724

Linux下安装FastDFS及生成缩略图

1. 安装编译环境 yum install git gcc gcc-c++ make automake vim wget libevent -y 2. 安装libfastcommon基础库 mkdir /root/fastdfs cd /root/fastdfs git clone https://github.com/happyfish100/libfastcommon.git --depth 1 cd libfastcommon/ ./make.sh && ./make.sh ins

weixin_45234710的博客 1373

Maven - 并行构建 使用-j参数提升多模块项目构建效率

本文介绍了如何利用Maven的-T参数实现多模块项目的并行构建,显著提升构建效率。主要内容包括: 问题背景:默认单线程构建方式在多模块项目中效率低下,浪费硬件资源。 解决方案:Maven自3.0起支持并行构建,通过-T参数可指定线程数(固定值/C/NC/auto)。 核心原理:基于反应式构建模型和拓扑排序实现安全并行。 实战演示: 4线程构建将200秒的串行时间缩短至110秒(↓45%) 1.5倍CPU核心数(12线程)进一步降至95秒(↓52.5%) 可视化分析:通过Mermaid图表展示依赖关系和并行调

千淘万漉虽辛苦,吹尽狂沙始到金 2万+

CDH Hue连接Hbase报错TSocket read 0 bytes

问题描述 安装好CDH集群后,在Hue中查看HBase信息时,Hue界面报错如下: Api 错误:TSocket read 0 bytes Hue日志报错: exceptions_renderable ERROR Potential trace: [('/opt/cloudera/parcels/CDH-6.3.2-1.cdh6.3.2.p0.1605554/lib/hue/apps/hbase/src/hbase/api.py', 46, 'query', 'return getattr(self

邢为栋 3491

Maven多模块项目构建

POM(Project Object Model):POM是Maven项目的基本工作单元,它是一个XML文件,描述了项目的元数据信息,如依赖项、构建插件、目标等。构建生命周期:Maven定义了一系列标准的构建阶段,如编译、测试、打包、部署等,开发者可以通过执行相应的Maven命令来触发这些构建阶段。多模块项目管理:对于复杂的项目结构,Maven支持多模块项目的管理,能够统一管理各个子模块的依赖和构建。项目构建:Maven可以自动化执行项目的构建过程,包括编译、测试、打包等,大大简化了项目构建的流程。

webxxs的博客 1736

你的Wi-Fi总断网?可能是DHCP租约到期惹的祸!手把手教你用Windows/路由器设置永久IP或延长租期

本文深入解析家庭Wi-Fi频繁断网的常见原因——DHCP租约到期问题,并提供Windows和路由器设置永久IP或延长租期的详细教程。通过对比静态IP配置与延长租期两种方案,帮助用户有效解决网络不稳定问题,特别适合游戏玩家和远程工作者优化家庭网络环境。

weixin_29305313的博客 1408

把 ABAP 选择屏幕 Selection Screen 打造成可维护的交互面板:常用屏幕元素与动态控制全解析

本文详细介绍了ABAP报表中Selection Screen的设计技巧,包括空行(SKIP)、横线(ULINE)、注释(COMMENT)等基础元素的使用方法,以及如何通过MODIF ID实现动态界面调整。重点讲解了行内布局(BEGIN OF LINE)、按钮(PUSHBUTTON)和区块(BLOCK)等高级功能,帮助开发者将选择屏幕从"能用"提升到"好用、易扩展、可维护"的水平。文章还分享了项目实践中的命名规范和分组策略,特别适合需要优化ABAP报表用户体验的开发人员

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

Maven多模块项目构建:协调子模块的构建过程

本文介绍了Maven多模块项目的组织与构建方法。多模块项目通过父模块统一管理公共配置,子模块继承父模块配置并实现具体功能。构建顺序由依赖关系决定,可通过<modules>标签手动调整。常见问题包括依赖版本不一致和循环依赖,可通过dependencyManagement统一版本或重构模块结构解决。文章通过电商项目示例展示了父模块与子模块的POM配置,并演示了构建过程,帮助开发者高效管理复杂项目的构建流程。

fykam的博客 1657

Centos 7 Linux 离线安装单机 Kafka:下载、安装、配置、使用

本文详细介绍了在 CentOS 7 系统上离线安装单机版 Apache Kafka 的完整流程,包括环境准备(JDK 安装)、Kafka 安装包上传与解压、关键配置修改(如监听地址)、ZooKeeper 与 Kafka 服务的启动,以及 Topic 的创建、消息的生产和消费等基础操作。适用于无网络环境下的 Kafka 快速部署与学习,为后续开发或测试提供本地消息队列支持。

寒水馨 · 轻量级技术文档 · hanshuixin.org 1319

【 Maven 】花式玩法之多模块项目

Maven 通过使用插件和配置文件来定义项目的发布策略。项目的发布策略包括了构建、版本管理、部署和发布等方面的规则和流程。下面介绍一下Maven中常用的发布策略的定义方式:Maven多模块的发布使得项目的管理、构建和部署更加灵活、高效和可维护。它提供了一种组织和管理复杂应用程序的有效方式,同时也促进了代码的重用和模块的解耦,提高了开发团队的效率和项目的质量。提高了代码结构清晰度、可维护性,加快了部署速度,并促进了代码的复用。希望本文对您有所帮助。如果有任何错误或建议,请随时指正和提出。

2301_79456272的博客 2504

最全面的行人重识别数据集汇总

汇总了一些REID的数据集,几乎涵盖了所有的数据集。如果有缺少的欢迎留言补充。我将能下载到的数据集放在了网盘里,链接如下:链接:https://pan.baidu.com/s/1hQ4PKvtAhAvoZiXbcIu93w 提取码:o3iyQMUL iLIDS基于iLIDS MCTS的数据集,是一个在机场繁忙时候通过监控系统中多个摄像头收集到的数据集。几乎每个ID(identity)都有从两个无重叠(区域)的摄像头拍摄的四幅图像。该数据集具有严重遮挡和姿势差异的场景。

m0_47867638的博客 1万+

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

IDEA中如何使用Maven构建多模块项目?模块间如何相互调用?

在 IntelliJ IDEA 中使用 Maven 构建多模块项目(Multi-Module Project)是一个常见的开发场景,尤其适用于大型项目或需要将代码拆分为多个独立模块的项目。通过合理组织模块结构,可以提高项目的可维护性和扩展性。下文将详细说明如何IDEA 中使用 Maven 构建多模块项目以及模块间是如何相互调用的。通过以上步骤,你可以在 IntelliJ IDEA 中使用 Maven 构建一个多模块项目,并确保模块之间能够正确地相互调用。项目的 pom.xml:定义项目的整体结构和模块列表。

SDTechnology的博客 2986

精雕软件(JDpaint) 5.5 绿色版

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

maven构建项目(多模块项目)

在eclipse下构建maven项目,该项目由多个子模块组成。 1.创建一个父项目 NEW -->project-->maven-->maven Project,点击下一步,进入new maven Project的Select project name and location界面 ,什么也不做,直接下一步到Select an Archetype界面。 在这个界面中选择ma

subuser的专栏 8万+

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

WINCC7.3破解文件

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

maven多模块构建springcloud项目

正经学徒,佛系记录,不搞事情 参考上文:https://blog.youkuaiyun.com/qq_31748587/article/details/84849520 基于maven多模块构建springcloud项目实现简单的服务注册发现,项目最终结构如下: cloud_parent:父工程,统一管理jar包依赖 eureka_server:注册中心服务 eureka_client:服务提供...

toBeMN的博客 6606

Maven之多模块项目管理

随着功能迭代,大型Java项目代码量和依赖关系会变得复杂,将项目拆分为多个模块,通过Maven进行统一管理,能显著提升代码复用性和可维护性。本文我将详细讲解Maven多模块项目的设计原则、创建流程、依赖管理及实战技巧,带你掌握多模块项目的核心管理方式。

aa_hdkf_vg的博客 1637

使用 maven 构建 Java Web 多模块项目

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_34232744的博客 678
上一篇: javaWeb项目的classpath说明
下一篇: eclipse中Maven web项目的目录结构浅析
周末去看海
博客等级 码龄9年 50粉丝 5原创
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值