ANT构建脚本

Ant构建与打包实践指南 本文还有配套的精品资源,点击获取 简介:Apache Ant是一个功能强大的Java构建自动化工具,它通过XML文件来定义和执行构建任务。本文详细介绍Ant在Java项目中的应用,包括编写构建脚本、源代码编译、JAR文件打包,以及代码混淆等关键步骤。此外,还探讨了Ant的集成使用和在现代项目管理工具中的地位。 1. Ant构建工具概述 Apache Ant是... 阅读详情
ANT构建脚本 1.3.0
 
张经纬 2006-10-29
 
ANT官方站: http://ant.apache.org/
 
  我们的项目中有一个主项目和几个小项目,主项目有几个人同时开发,小项目通常是由一个人开发。在开发过程中,除了最终的发布版本,还需要对小版本进行管理。
  小版本的管理有些麻烦,因为在打包时,开发人员通常也只是打包源代码。作为开发人员不会每天晚上完成工作后,把项目所需要的东西完整的打包在一起,不现实且效率也低。但从管理的角度来看,这是有用的,除了浪费一些存储空间,这种方式有助于项目经理了解项目的进展情况,对风险控制也是有益的。
 
  我们项目使用subversion做版本控制,每个项目都有下面的结构:
    Project
    ├─debug
    │  ├─bin
    │  ├─conf
    │  ├─classes
    │  ├─doc
    │  ├─lib
    │  └─src
    └─release
        ├─project-1.0.0
        │   ├─bin
        │   ├─conf
        │   ├─doc
        │   ├─lib
        │   └─src
        ├─project-1.0.1
        │   ├─bin
        │   ├─conf
        │   ├─doc
        │   ├─lib
        │   └─src
        └─project-1.2.0
             ├─bin
             ├─conf
             ├─doc
             ├─lib
             └─src
  开发人员从debug上checkout出来要开发的项目,完成后commit,在需要更新版本时,使用ant的构建脚本自动构建出完整的分发包,再从本地import到版本库中。当本地workcopy很干净时,也可以直接创建一个分技到新的带有版本号的目录中(例:./release/project-1.2.1/)。我们通常使用第一种做法,打包后import到版本库中。
 
  分发包使用ANT的构建文件(build.xml)自动构建。ANT的使用并不难,内容也不多。关键是在构建时的目的,和要遵循的原则。
  1. 在开发时构建。
    在unix下面工作时,经常没有IDE。用ant来构建比用命令行方便。当然也可以写脚本,但脚本的移植性不好。
  2. 为了分发构建。
    构建的目的是构建用户最终使用的版本(可以不包括源代码)。
  3. 为了开发构建。
    在开源社区里,代码是共享的。这时构建的目的,一方面是分发,给最终用户使用,另一方面是提供给用户能够再次开发的版本。
 
  我们现在使用的构建文件是参考了几个开源包里的build.xml文件后,自己做的,现在是的版本1.3.0。编写时的思路是用户能够使用发构建出来的分发包,再次构建分发包,不修改或少修改构建文件。可以理解为嵌套。
 
  这个配置文件在使用时,只需要修改几个主要参数:
    项目名称:别的不用说,只是在构建jar包时也会用到;
    版本号:分为主版本、次版本和修改版本;
    主要项目路径:源代码(src.dir)、库目录(lib.dir)、文档目录(doc.dir)等;
    主要构建路径:源代码(dist.src.dir)、库目录(dist.lib.dir)、文档目录(doc.dir)等。
 
  另外,如果项目有需要,如有测试用例,可以打开构建选项:
  <property name="switch.copytestcase" value="">
  这个选项,默认是被注释掉的。
 
  需要注意一点,如果希望构建出来的分发包可以使用包中的build.xml不加修改的再次构建,就需要在设置路径时,都以项目路径为根目录来设置。如果使用绝对地址,多数情况构建出来的分发包再构建时要出错了。
  这个脚本现在仍在改进中,有兴趣的朋友可以一起讨论。
 
  下面的配置文件,也可以下载: build.xml。
 

<?xml version="1.0"  encoding="GB2312"?>
<!-- ======================================== -->
<!-- 标准构建文件 v1.3.0                      -->
<!-- 使用前请修改:                           -->
<!--     项目名称                             -->
<!-- ======================================== -->

<!-- ======================================== -->
<!-- [project_name] 构建文件                  -->
<!-- auther:                                  -->
<!-- date  : @build_date@                     -->
<!-- ======================================== -->

<project name="[project_name]" basedir="./" default="build">

 <!-- 记录构建时间 -->
 <tstamp>
  <format property="exedate" pattern="yyyy-MM-dd" />
  <format property="exetime" pattern="hh:mm:ss" />
 </tstamp>

 <!-- ================================================= -->

 <!-- 项目名称、版本,用于创建文件名 -->
 <property name="Name" value="[big_project_name]" />
 <property name="name" value="[small_project_name]" />
 <property name="name2" value="[short_project_name]" />

 <!-- 版本号:[主版本-次版本-修订号] -->
 <property name="version.major" value="1" />
 <property name="version.minor" value="0" />
 <property name="version.patch" value="0" />

 <!-- 版本号: 无修订号 -->
 <property name="version.sansPatchLevel" value="${version.major}.${version.minor}" />
 <!-- 版本号:完整版本号 -->
 <property name="version.full" value="${version.sansPatchLevel}.${version.patch}" />
 <!-- 完整名称 -->
 <property name="fullname" value="${name}-${version.full}" />

 <!-- ant构建文件名 -->
 <property name="buildfile" value="build.xml" />

 <!-- jar包名 -->
 <property name="jar.file" value="${fullname}.jar" />

 <!-- ================================================= -->

 <!-- 源代码目录 -->
 <property name="src.dir" value="src" />
 <property name="etc.dir" value="conf" />
 <property name="bin.dir" value="bin" />
 <property name="lib.dir" value="lib" />
 <property name="jdbc.dir" value="${lib.dir}" />
 <property name="class.dir" value="classes" />

 <!-- 文档目录 -->
 <property name="doc.dir" value="doc" />
 <property name="doc.api.dir" value="${doc.dir}/api" />
 <property name="doc.ref.dir" value="${doc.dir}/reference" />

 <!-- 示例路径源代码目录 -->
 <property name="example.dir" value="examples" />

 <!-- 测试用例源代码目录 -->
 <property name="testcase.dir" value="test" />
 
 <!-- ====================================== -->

 <!-- 目标根目录 -->
 <property name="dist.root" value="dist" />
 <property name="dist.dir" value="${dist.root}/${fullname}" />

 <!-- 目标目录 -->
 <property name="dist.src.dir" value="${dist.dir}/src" />
 <property name="dist.etc.dir" value="${dist.dir}/conf" />
 <property name="dist.bin.dir" value="${dist.dir}/bin" />
 <property name="dist.lib.dir" value="${dist.dir}/lib" />
 <property name="dist.jdbc.dir" value="${dist.dir}/lib" />
 <property name="dist.class.dir" value="${dist.dir}/classes" />

 <!-- 目标文档目录 -->
 <property name="dist.doc.dir" value="${dist.dir}/doc" />
 <property name="dist.api.dir" value="${dist.dir}/doc/api" />
 <property name="dist.ref.dir" value="${dist.dir}/doc/reference" />

 <!-- 示例目标目录 -->
 <property name="dist.example.dir" value="${dist.dir}/examples" />

 <!-- 测试用例源代码目录 -->
 <property name="dist.testcase.dir" value="${dist.dir}/test" />

 <!-- ===================================== -->

 <!-- 配置选项:如果构建时不需要,请注释掉 -->

 <!-- 复制jar包开关 -->
 <property name="switch.copyjar" value="" />

 <!-- 复制bin开关 -->
 <property name="switch.copybin" value="" />

 <!-- 复制etc配置文件开关 -->
 <property name="switch.copyetc" value="" />

 <!-- 复制jdbc驱动开关 -->
 <property name="switch.copyjdbc" value="" />

 <!-- 复制库文件开关 -->
 <property name="switch.copylib" value="" />

 <!-- 复制示例文件开关 -->
 <property name="switch.copyexample" value="" />

 <!-- 复制测试用例开关 -->
 <!--property name="switch.copytestcase" value="" /-->

 <!-- ======================================== -->

 <!-- JDBC驱动列表 -->
 <fileset id="jdbc.list" dir="${lib.dir}">
  <include name="**/*.jar" />
 </fileset>

 <!-- 外部库列表 -->
 <fileset id="lib.list" dir="${lib.dir}">
  <include name="**/*.jar" />
 </fileset>

 <!-- CLASSPATH -->
 <path id="classpath">
  <fileset dir="${lib.dir}">
   <include name="**/*.jar" />
  </fileset>
 </path>

 <!-- ========================================== -->

 <!-- java编译配置 -->
 <property name="javadoc" value="
http://java.sun.com/j2se/1.4/docs/api" />
 <property name="javac.debug" value="on" />
 <property name="javac.optimize" value="off" />
 <property name="javac.target" value="1.4" />
 <property name="javac.source" value="1.4" />
 <property name="javac.deprecation" value="on" />
 <property name="javac.compiler" value="modern" />

 <!-- ========================================= -->
 <!-- ====                                      -->
 <!-- ========================================= -->

 <filter token="year" value="${year}" />
 <filter token="version.full" value="${version.full}" />
 <filter token="date" value="${TODAY}" />
 <filter token="log" value="true" />
 <filter token="verbose" value="true" />

 <patternset id="jar.files">
  <include name="**/*.dtd" />
  <include name="**/*.xml" />
  <include name="**/*.xslt" />
 </patternset>

 <patternset id="src.files">
  <!-- include everything we want in the src directory
    that we didn't want in the jar itself -->
  <include name="**/*.java" />
 </patternset>

 <patternset id="refdoc.files">
  <include name="**/*.css" />
  <include name="**/*.jpg" />
  <include name="**/*.gif" />
  <include name="**/*.png" />
 </patternset>
 <!-- =============================================== -->
 <!-- ==== 使用帮助                                    -->
 <!-- =============================================== -->
 <target name="usage">
  <echo>${Name} Build file
-------------------------------------------------------------
available targets are:

jar  - generates the ${Name}.jar file

build - compiles the source code

javadoc - generates the API documentation

clean - cleans up the directory

dist - will create a complete distribution in dist
    Setting the env variable NO_JAVADOC will build the
    distribution without running the javadoc target.
   
release - will create a complete distribution in dist
    using stricter settings for public distribution.
   
Please rename build.properties.default to build.properties
and edit build.properties to specify JSDK 2.3 classpath.
  
See the comments inside the build.xml file for more details.
-------------------------------------------------------------</echo>
 </target>


 <!-- ============================================ -->
 <!-- ==== 构建                                    -->
 <!-- ============================================ -->

 <!-- ==== 创建API文档 ===========================  -->
 <target name="javadoc">
  <mkdir dir="${src.dir}" />
  <mkdir dir="${doc.api.dir}" />
  <javadoc sourcepath="${src.dir}" destdir="${doc.api.dir}" author="true" version="true" use="true" splitindex="true" windowtitle="${Name} API" doctitle="${Name}">
   <!-- link="${javadoc}"-->
   <classpath refid="classpath" />
   <packageset dir="${src.dir}" defaultexcludes="yes">
    <include name="**" />
   </packageset>
   <group title="Core API" packages="com.zjw.*" />
  </javadoc>
 </target>

 <!-- ==== 编译源代码 =============================  -->
 <target name="build">
  <mkdir dir="${src.dir}" />
  <mkdir dir="${class.dir}" />
  <javac srcdir="${src.dir}" destdir="${class.dir}" debug="${javac.debug}" optimize="${javac.optimize}">
   <classpath refid="classpath" />
  </javac>
 </target>

 <!-- ==== 创建jar包 ==============================  -->
 <target name="jar" depends="build">
  <mkdir dir="${lib.dir}" />
  <jar jarfile="${lib.dir}/${jar.file}" basedir="${class.dir}" includes="**" />
 </target>

 <!-- ==== 清理目标 ===============================  -->
 <target name="clean">
  <delete dir="${dist.dir}" />
 </target>

 <!-- ==== 清理全部目标 ===========================  -->
 <target name="clean-all">
  <delete dir="${class.dir}" />
  <delete dir="${doc.api.dir}" />
  <delete dir="${dist.root}" />
 </target>

 <!-- =========================================== -->
 <!-- ==== 构建发行版本                            -->
 <!-- =========================================== -->

 <!-- ==== 创建源代码 =======================  -->
 <target name="build-src">
  <mkdir dir="${dist.src.dir}" />
  <copy todir="${dist.src.dir}">
   <fileset dir="${src.dir}" />
  </copy>
 </target>

 <!-- ==== 创建项目文档 ==================  -->
 <target name="build-doc" depends="javadoc">
  <mkdir dir="${dist.doc.dir}" />
  <copy todir="${dist.doc.dir}">
   <fileset dir="${doc.dir}" />
  </copy>
 </target>

 <!-- ==== 创建jar包 =======================  -->
 <target name="build-jar" depends="jar" if="switch.copyjar">
  <mkdir dir="${dist.lib.dir}" />
  <copy file="${lib.dir}/${jar.file}" todir="${dist.lib.dir}" />
 </target>

 <!-- ==== 复制etc目录中配置文件 ============  -->
 <target name="build-etc" if="switch.copyetc">
  <mkdir dir="${etc.dir}" />
  <mkdir dir="${dist.etc.dir}" />
  <copy todir="${dist.etc.dir}">
   <fileset dir="${etc.dir}" />
  </copy>
 </target>

 <!-- ==== 复制bin目录中执行文件 ============  -->
 <target name="build-bin" if="switch.copybin">
  <mkdir dir="${bin.dir}" />
  <mkdir dir="${dist.bin.dir}" />
  <copy todir="${dist.bin.dir}">
   <fileset dir="${bin.dir}" />
  </copy>
 </target>

 <!-- ==== 复制jdbc驱动 ====================  -->
 <target name="build-jdbc" if="switch.copyjdbc">
  <mkdir dir="${jdbc.dir}" />
  <mkdir dir="${dist.jdbc.dir}" />
  <copy todir="${dist.jdbc.dir}">
   <fileset refid="jdbc.list" />
  </copy>
 </target>

 <!-- ==== 复制lib库文件 ====================  -->
 <target name="build-lib" if="switch.copylib">
  <mkdir dir="${lib.dir}" />
  <mkdir dir="${dist.lib.dir}" />
  <copy todir="${dist.lib.dir}">
   <fileset refid="lib.list" />
  </copy>
 </target>

 <!-- ==== 复制示例 ========================  -->
 <target name="build-example" if="switch.copyexample">
  <mkdir dir="${example.dir}" />
  <mkdir dir="${dist.example.dir}" />
  <copy todir="${dist.example.dir}">
   <fileset dir="${example.dir}" />
  </copy>
 </target>

 <!-- ==== 复制测试用例 ====================  -->
 <target name="build-testcase" if="switch.copytestcase">
  <mkdir dir="${testcase.dir}" />
  <mkdir dir="${dist.testcase.dir}" />
  <copy todir="${dist.testcase.dir}">
   <fileset dir="${testcase.dir}" />
  </copy>
 </target>

 <!-- ==== 构建发行版本 - 无javadoc ==========  -->
 <target name="dist" depends="build-src,build-jar,build-etc,build-bin,build-jdbc,build-lib,build-example,build-testcase">
  <echo message="${exedate} ${exetime}" />
  <!-- 复制ANT配置文件 -->
  <copy file="${buildfile}" todir="${dist.dir}" />
 </target>
 <!-- ==== 构建发行版本 ======================  -->
 <target name="release" depends="build-src,build-doc,build-jar,build-etc,build-bin,build-jdbc,build-lib,build-example,build-testcase">
  <echo message="${exedate} ${exetime}" />
  <!-- 复制ANT配置文件 -->
  <copy file="${buildfile}" todir="${dist.dir}" />
 </target>

 <!-- =========================================== -->
 <!-- ==== 扩展任务                                -->
 <!-- =========================================== -->

 <!-- ==== extension ==================  -->
 <target name="extension_task" />

</project>

阅读(1195) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~
评论热议
ant的build构建脚本 ant脚本构建工具,有详细的注释、用于构建程序war包,执行编译、修改、拷贝、远程上传程序war包、远程发布程序、远程重启服务器(tomcat) 立即下载

相关推荐

医药领域知识图谱快速及医药问答项目(项目全过程)

该项目是中科院软件所刘焕勇老师在github上的开源项目,基于知识图谱的医药领域问答项目 Github项目地址:mirrors / liuhuanyong / qasystemonmedicalkg · GitCode 一、项目环境搭建 该部分要十分注意,由于版本升级的问题,一些用法及格式已经不兼容了。 python3.8 下载地址:Python Release Python 3.8.10 | Python.orght...

qq_52062182的博客 9932

如何使用Ant构建Java应用程序

Apache Ant是一款开源的Java构建工具,它可以帮助我们自动化构建、测试和部署Java应用程序。Ant基于Java语言,使用XML作为构建文件的格式,具有简单易学、功能强大、可扩展性好等优点,被广泛应用于软件开发领域。首先,我们需要定义一些属性来存放Java编译器和源代码的路径信息。这些属性可以被后续的任务和目标所引用,以避免硬编码路径信息导致的不可移植问题。具体的属性定义如下所示:

随缘同学的博客 1599

避坑指南:ANSYS流固耦合计算中System Coupling数据传递设置与常见报错解决

本文深入解析ANSYS Workbench中System Coupling模块在双向流固耦合(FSI)计算中的应用,详细讲解数据传递机制、典型报错解决方案及高阶调试技巧。通过实际案例展示如何优化耦合步长、处理大变形问题,并提升并行计算效率,帮助工程师有效规避常见技术陷阱。

weixin_29213525的博客 750

代码构建(三)——ANT脚本在实际项目中的应用场景

在进行文件时区偏移的计算时,不同的ZIP工具处理时间戳的方式不同,一些ZIP库从文件系统中读取时间戳并保存,而其他库在读和写文件时会修改时间戳,以使所有的时间戳有相同的时区。本地程序主要是指系统程序,一般指操作系统级的程序,例如在unix的shell命令,windows的系统程序如taskmgr,ping等系统程序,exec能够运行的好像一般都是exe程序,其他程序例如services.msc好像不能运行,批处理文件.bat也不能运行。值得注意的时,如果这个属性被指定,那么fork属性必须设定为true。

weixin_40130409的博客 905

深入解析DDR5 SDRAM的ODT模式:时序图与状态表实战指南

本文深入解析了DDR5 SDRAM的ODT模式,详细阐述了其五种工作状态及其在读写操作中的动态切换逻辑。通过解读JESD79-5标准中的时序图与状态表,并结合模式寄存器配置实战,为硬件工程师和爱好者提供了优化信号完整性、提升系统稳定性的关键指南。

gpu4optimizer的博客 714

Comsol 弧形声学换能器声聚焦仿真

1. 弧度和曲率半径:弧形声学换能器的形状和曲率半径对声聚焦效果有重要影响。通常,较小的曲率半径和较大的弧度可以实现更强的声聚焦效果。弧形声学换能器声聚焦是指将声波能量集中在弧形声学换能器的特定区域内,以实现更强的声场强度和分辨率。4. 数值仿真和优化:使用声学仿真软件进行数值仿真可以帮助设计和优化弧形声学换能器的声聚焦效果。通过调整几何参数、材料特性和激励信号等参数,可以模拟和优化声聚焦效果。2. 激励信号:通过调整激励信号的频率和幅值,可以实现声波在弧形声学换能器中的聚焦效果。

声学黑洞仿真工作室 1625

Ant部署Web工程

 下面的xml是ant 的构建脚本, 功能包括:  编译,部署到tomcat, 启动tomcat,停止tomcat, 重新载入。  使用前必须安装 jdk 和 ant , 然后运行ant init,初始化工程目录,  就可以进行开发了。(题外话:在这个ide工具傻瓜式开发的时代里,ant依旧显示它的优秀之处,它能完成比ide更灵活的任务, 从设计的角度说,操作越复杂的工具应是是越灵活滴 ^_^

Maxwell的专栏 805

Cadence OrCAD常见引脚错误排查指南:从原理图到封装的完整解决方案

本文详细解析Cadence OrCAD设计中常见的引脚错误问题,提供从原理图到封装的系统化解决方案。涵盖错误诊断、元件库修复、封装管理及自动化处理技巧,帮助工程师高效解决ORCAP-36022等典型错误,确保设计流程顺畅。

weixin_29294975的博客 263

用Ant构建脚本(1)

 用Ant构建脚本(1)首先声明,本文基于Apache Ant官方网站http://ant.apache.org/manual/的《Apache Ant 1.7.0Beta2 Manual》翻译而得。一、Apache Ant简介1、Ant是Java开源组织Apache的一个项目,是一个基于Java的build工具。其构建脚本有4个不同的实现:(1)Sun Microsystems公司的参考实现

chszs的专栏 4576

ADAS系统架构与核心功能解析:从感知到执行的智能驾驶方案

高级驾驶员辅助系统(ADAS)是现代汽车智能化的核心技术,其本质是通过传感器融合、算法决策与车辆控制,构建一个“感知-决策-执行”的闭环系统。在技术原理上,ADAS依赖摄像头、毫米波雷达、激光雷达等多源传感器进行环境感知,并通过深度学习模型与融合算法(如卡尔曼滤波)构建精准的环境模型。其技术价值在于提供主动安全冗余与驾驶舒适性,核心应用场景包括自动紧急制动(AEB)、自适应巡航(ACC)及车道保持辅助(LKA)等。随着传感器成本下降与域控制器算力提升,ADAS正从高端配置向主流车型快速普及,并逐步向高阶导航

weixin_31062533的博客 427

PHM2010刀具磨损预测完整实现

本文介绍了PHM2010刀具磨损预测项目的完整实现方案。项目采用PHM2010公开数据集,包含6个子数据集,记录了铣削加工过程中7个通道的传感器数据(切削力、振动和声发射信号)。技术路线包括数据预处理(截取中间10万点、小波降噪)、特征提取(时域9个、频域4个特征)、特征融合和皮尔逊相关系数筛选,最终使用BiLSTM模型进行训练和评估。环境配置基于Python 3.9,依赖NumPy、Pandas、PyTorch等库。数据加载和预处理阶段重点处理了传感器信号分段和磨损标签对齐问题,为后续建模奠定基础。

huanghm88的专栏 451

构建脚本ivy、ant的使用

构建脚本ivy、ant的使用 1、准备软件 资源名称 用途 获取方法 ant 构建项目 http://ant.apache.org/ ivy 配合ant构建项目 http://ant.apache.org/ivy/ 2、配置构建环境 2.1 Ant 的安装与配

huangbailong的专栏 1647

PMP--工件

合同是指对双方都有约束力的协议,强制卖方提供规定的产品、服务或结果,以及强制买方支付相应的费用。它还可能包括处于中间状态的特性,例如已设计但尚未构建的特性、质量保证中的特性或测试中的特性。RACI 矩阵是一种常见的方法,用于显示执行、担责、咨询或知情,且与项目活动、决策和可交付物有关的干系人。计划是提议的实现某种目标的方式。在项目开始前或开始时创建的文件,涉及与项目有关的战略、商业或高层级的信息。或 © 它们是用特定方法创建的结果,例如,虽然成本估算结果是一个重要工件,它们是用不同估算方法得出的结果。

stqer的博客 1672

ant 的构建脚本0

<br />下面的xml是ant 的构建脚本, 功能包括:  编译,部署到tomcat, 启动tomcat,停止tomcat, 重新载入。  使用前必须安装 jdk 和 ant , 然后运行ant init,初始化工程目录,  就可以进行开发了。(题外话:在这个ide工具傻瓜式开发的时代里,ant依旧显示它的优秀之处,它能完成比ide更灵活的任务, 从设计的角度说,操作越复杂的工具应是是越灵活滴 ^_^ <br />Java代码 <?xml version="1.0" encoding="UTF-8"?>

Thomastang2012的专栏 923

全球国家地区城市数据

MySQL全球国家地区城市数据报。。。。。。。。。。。。

WINCC7.3破解文件

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

ANT构建war包脚本,Ant编译java

话不多说,直接上代码 ANT构建war包脚本~ show the code!   每个步骤及参数都已配上说明 <?xml version="1.0" encoding="UTF-8" ?> <!-- default,指定默认跑哪个流程,一个target代表一个流程 --> <project name="ajbphtms" default="publish...

懒懒的树懒熊 362

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

Ant构建脚本:创建ZIP文件

Ant构建脚本:创建ZIP文件

Leon_Jinhai_Sun的博客 916

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

Ant自动构建脚本!

这是我业余写的一个Ant自动构建脚本.回头有时间再写个WebSphere的脚本.                                                                                                 dest="${back.dir}/${DSTAMP}/${cvs.project}"               inc

Jason的专栏 761

Java中ant构建脚本学习

ANT是一个基于Java的自动化脚本引擎,脚本格式为XML。除了做Java编译相关任务外,ANT还可以通过插件实现很多应用的调用。 1)ANT的基本概念: 2)ANT的安装:解包,设置路径 3)ANT的使用:最好的学习只不过是一个简单实用的例子起步…… ANT的基本概念:Java的Makefile 当一个代码项目大了以后,每次重新编译,打包,测试等都会变得非常复杂而且重...

山高水深 170

ant脚本 变量赋值_如何使用ant构建jmeter

1.什么antant:构建工具ant好处:跨平台,使用java实现,功能强大步骤:首先确保测试机器中已经按照jdk1.6以上版本,如果没有,那就上官网下载吧。 mac环境变量配置(window自己百度脑补):open -t ~/.bash_profileexport ANT_HOME=/xxxx/apache-ant-1.10.3export PATH=$ANT_HOME/bin:$PATHsou...

weixin_39885412的博客 227

Ant构建中使用JS脚本方法

Ant的构建脚本中可以嵌入脚本,包括JS、Groovy、Ruby等。以集成平台3.0发布的构建脚本为例,说明一下Ant构建嵌入JS的方法。一、引入依赖包        ant-contrib-1.0b3.jar        bsf-2.4.0.jar        js.jar二、语法 &lt;script language="javascript"&gt;       &lt;cla...

zl19861225的专栏 936

用Ant构建脚本(5)

 用Ant构建脚本(5)六、Ant相关问题指南如果你的Ant不能工作,首先可能是Ant的版本问题,其次就是你的配置有问题。可以从以下方面来解决:1、检查你的环境变量。Ant_HOME和JAVA_HOME设置是否正确?2、未设置CLASSPATH?Ant不需要定义CLASSPATH来工作。3、确认你的JRE/ext中没有那些不可用的jar文件或者其它的XML解析器。4、你的路径设置是否正确?包含

chszs的专栏 2643

idea配置ant版本_结合Ant+Jenkins持续构建Jmeter脚本

01Tips问题驱动学习:1.选一个合适的测试工具???--------掌握Jmeter基础2.如何不启动Jmeter即可运行脚本???--------通过ant命令运行脚本并定义测试报告3.如何持续构建脚本???----通过Jenkins持续构建执行脚本本文所使用的是Jenkins+Ant+Jmeter组合成一个完整的自动化框架。本文所使用的是Jenkins+Ant+Jmeter组合成...

weixin_30847543的博客 210

Ant构建脚本解析:创建可运行JAR文件指南

Ant构建脚本解析:创建可运行JAR文件指南

Leon_Jinhai_Sun的博客 874
上一篇: sizeof的使用方法(转载)
下一篇: Quartx相关文章连接
basecn
博客等级 码龄17年 8粉丝 51原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址