alter table move跟shrink space的区别

Oracle中使用alter table move命令的方法降低表中的高水位(High Water Mark) 在Oracle数据库中,“高水位”(High Water Mark)是指表中数据的存储位置已经达到的最高位置。在表中插入、更新或删除数据时,数据库会自动管理数据的存储位置,但是删除操作并不会立即释放空间,而是标记为可重用。高水位标记了表中已经被使用的存储位置的最高点,而这些位置之上的空间可以被重新利用,以存储新的数据。当表中有大量的删除操作时,高水位可能会远远超过实际数据的位置,导致表的存储空间浪费。为了减少这种浪费,可以使用命令来重新组织表,将高水位重新设置到实际数据的位置之上。 阅读详情

author:skate

time2010-05-28



alter table move跟shrink space的区别

今天主要从两点说他们的区别:

 

1. 碎片的整理

2.空间的收缩

 

SQL> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production

TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production

SQL>

 

创建测试表
SQL> create table test3 as
  2     select rownum id,
  3     dbms_random.string('a', round(dbms_random.value(0,10))) col1,
  4     trunc(sysdate) - dbms_random.value(1, 365*2) col2
  5     from dual connect by rownum<=10000;

Table created

 

SQL> select count(1) from test3;

  COUNT(1)
----------
     10000


查看表test3的blocks使用情况:

 

SQL> exec show_space_t('TEST3','auto','table','Y');

Total Blocks............................40
Total Bytes.............................327680
Unused Blocks...........................3
Unused Bytes............................24576
Last Used Ext FileId....................31
Last Used Ext BlockId...................481921
Last Used Block.........................5
 *************************************************
0% -- 25% free space blocks.............0
0% -- 25% free space bytes..............0
25% -- 50% free space blocks............0
25% -- 50% free space bytes.............0
50% -- 75% free space blocks............0
50% -- 75% free space bytes.............0
75% -- 100% free space blocks...........0
75% -- 100% free space bytes............0
Unused Blocks...........................0
Unused Bytes............................0
Total Blocks............................32
Total bytes.............................262144

 

PL/SQL procedure successfully completed


制造碎片

 

SQL> DELETE FROM TEST3 WHERE MOD(ID,3)=1;

3334 rows deleted

 

SQL> commit;

Commit complete

 

发现有碎片了

 

SQL> exec show_space_t('TEST3','auto','table','Y');

Total Blocks............................40
Total Bytes.............................327680
Unused Blocks...........................3
Unused Bytes............................24576
Last Used Ext FileId....................31
Last Used Ext BlockId...................481921
Last Used Block.........................5
 *************************************************
0% -- 25% free space blocks.............0
0% -- 25% free space bytes..............0
25% -- 50% free space blocks............31
25% -- 50% free space bytes.............253952
50% -- 75% free space blocks............1
50% -- 75% free space bytes.............8192
75% -- 100% free space blocks...........0
75% -- 100% free space bytes............0
Unused Blocks...........................0
Unused Bytes............................0
Total Blocks............................0
Total bytes.............................0

 

PL/SQL procedure successfully completed

SQL>

 

消除碎片


SQL> alter table test3 move;

Table altered

 

查看碎片消除的效果


SQL> exec show_space_t('TEST3','auto','table','Y');

Total Blocks............................32
Total Bytes.............................262144
Unused Blocks...........................6
Unused Bytes............................49152
Last Used Ext FileId....................31
Last Used Ext BlockId...................485065
Last Used Block.........................2
 *************************************************
0% -- 25% free space blocks.............0
0% -- 25% free space bytes..............0
25% -- 50% free space blocks............0
25% -- 50% free space bytes.............0
50% -- 75% free space blocks............0
50% -- 75% free space bytes.............0
75% -- 100% free space blocks...........0
75% -- 100% free space bytes............0
Unused Blocks...........................0
Unused Bytes............................0
Total Blocks............................22
Total bytes.............................180224

 

PL/SQL procedure successfully completed

SQL>

 

从以上看,碎片整理的效果很好!!!

 

下面在测试用shrink整理碎片

 

重建测试环境


SQL> drop table test3;

Table dropped

 

SQL>
SQL> create table test3 as
  2     select rownum id,
  3     dbms_random.string('a', round(dbms_random.value(0,10))) col1,
  4     trunc(sysdate) - dbms_random.value(1, 365*2) col2
  5     from dual connect by rownum<=10000;

Table created

 

查看test3的blocks的使用


SQL> exec show_space_t('TEST3','auto','table','Y');

Total Blocks............................40
Total Bytes.............................327680
Unused Blocks...........................3
Unused Bytes............................24576
Last Used Ext FileId....................31
Last Used Ext BlockId...................481921
Last Used Block.........................5
 *************************************************
0% -- 25% free space blocks.............0
0% -- 25% free space bytes..............0
25% -- 50% free space blocks............0
25% -- 50% free space bytes.............0
50% -- 75% free space blocks............0
50% -- 75% free space bytes.............0
75% -- 100% free space blocks...........0
75% -- 100% free space bytes............0
Unused Blocks...........................0
Unused Bytes............................0
Total Blocks............................32
Total bytes.............................262144

 

PL/SQL procedure successfully completed

 

制造碎片


SQL> delete from test3 where mod(id,3)=1;

3334 rows deleted

 

SQL> commit;

Commit complete

 

查看碎片情况
SQL> exec show_space_t('TEST3','auto','table','Y');

Total Blocks............................40
Total Bytes.............................327680
Unused Blocks...........................3
Unused Bytes............................24576
Last Used Ext FileId....................31
Last Used Ext BlockId...................481921
Last Used Block.........................5
 *************************************************
0% -- 25% free space blocks.............0
0% -- 25% free space bytes..............0
25% -- 50% free space blocks............31
25% -- 50% free space bytes.............253952
50% -- 75% free space blocks............0
50% -- 75% free space bytes.............0
75% -- 100% free space blocks...........0
75% -- 100% free space bytes............0
Unused Blocks...........................0
Unused Bytes............................0
Total Blocks............................1
Total bytes.............................8192

 

PL/SQL procedure successfully completed

 

用oracle10g新功能整理碎片


SQL> alter table test3 shrink space compact cascade;

alter table test3 shrink space compact cascade

ORA-10636: ROW MOVEMENT is not enabled

 

SQL> alter table test3 enable row movement;

Table altered

 

SQL> alter table test3 shrink space compact cascade;

Table altered

 

再次查看碎片的情况,发现还有一些碎片,整理碎片效果不好


SQL> exec show_space_t('TEST3','auto','table','Y');

Total Blocks............................40
Total Bytes.............................327680
Unused Blocks...........................3
Unused Bytes............................24576
Last Used Ext FileId....................31
Last Used Ext BlockId...................481921
Last Used Block.........................5
 *************************************************
0% -- 25% free space blocks.............1
0% -- 25% free space bytes..............8192
25% -- 50% free space blocks............2
25% -- 50% free space bytes.............16384
50% -- 75% free space blocks............0
50% -- 75% free space bytes.............0
75% -- 100% free space blocks...........12
75% -- 100% free space bytes............98304
Unused Blocks...........................0
Unused Bytes............................0
Total Blocks............................17
Total bytes.............................139264

 

PL/SQL procedure successfully completed

 

上面是没降低HWM,如果载降低HWM,看看效果


SQL> alter table test3 shrink space cascade;

Table altered

SQL> exec show_space_t('TEST3','auto','table','Y');

Total Blocks............................24
Total Bytes.............................196608
Unused Blocks...........................0
Unused Bytes............................0
Last Used Ext FileId....................31
Last Used Ext BlockId...................481897
Last Used Block.........................8
 *************************************************
0% -- 25% free space blocks.............1
0% -- 25% free space bytes..............8192
25% -- 50% free space blocks............2
25% -- 50% free space bytes.............16384
50% -- 75% free space blocks............0
50% -- 75% free space bytes.............0
75% -- 100% free space blocks...........0
75% -- 100% free space bytes............0
Unused Blocks...........................0
Unused Bytes............................0
Total Blocks............................17
Total bytes.............................139264

 

PL/SQL procedure successfully completed

 

看来用shrink space整理碎片不彻底,再来看看move的方式

 

SQL> alter table test3 move;

Table altered

SQL> exec show_space_t('TEST3','auto','table','Y');

Total Blocks............................32
Total Bytes.............................262144
Unused Blocks...........................6
Unused Bytes............................49152
Last Used Ext FileId....................31
Last Used Ext BlockId...................485081
Last Used Block.........................2
 *************************************************
0% -- 25% free space blocks.............0
0% -- 25% free space bytes..............0
25% -- 50% free space blocks............0
25% -- 50% free space bytes.............0
50% -- 75% free space blocks............0
50% -- 75% free space bytes.............0
75% -- 100% free space blocks...........0
75% -- 100% free space bytes............0
Unused Blocks...........................0
Unused Bytes............................0
Total Blocks............................22
Total bytes.............................180224

 

PL/SQL procedure successfully completed

 

效果很明显,整理的很彻底

 

测试结论:

虽然alter table move和shrink space,都是通过物理调整rowid来整理碎片的,但shrink space整理的不彻底,他好像不是重组,而是尽可能的合并,随意会残留一些block无法整理

 

注意:

 

1.再用alter table table_name move时,表相关的索引会失效,所以之后还要执行 alter index index_name rebuild online; 最后重新编译数据库所有失效的对象

 

2. 在用alter table table_name shrink space cascade时,他相当于alter table table_name move和alter index index_name rebuild online. 所以只要编译数据库失效的对象就可以

 

 

alter table move和shrink space除了碎片整理的效果有时不一样外,还有什么其他的不同呢

 


1. Move会移动高水位,但不会释放申请的空间,是在高水位以下(below HWM)的操作。
2. shrink space 同样会移动高水位,但也会释放申请的空间,是在高水位上下(below and above HWM)都有的操作。

 

下面通过实验来验证


SQL> drop table test3;

Table dropped

 

SQL>
SQL> create table test3 as
  2     select rownum id,
  3     dbms_random.string('a', round(dbms_random.value(0,10))) col1,
  4     trunc(sysdate) - dbms_random.value(1, 365*2) col2
  5     from dual connect by rownum<=10000;

Table created

 

SQL> analyze table test3 compute statistics;

Table analyzed

                                                                         

SQL> col segment_name for a10;
SQL> select us.segment_name,us.extents,us.blocks from user_segments us where us.segment_name=upper('test3');

SEGMENT_NA    EXTENTS     BLOCKS
---------- ---------- ----------
TEST3               5         40

 

SQL> col table_name for a10;
SQL> select table_name,blocks,t.empty_blocks  from user_tables t where t.table_name=upper('test3');

TABLE_NAME     BLOCKS EMPTY_BLOCKS
---------- ---------- ------------
TEST3              37            3

SQL>


从以上查询可以看出共分了5个extents,使用了37个blocks,这37也就是test3的HWM

 

 

SQL> delete from test3 where rownum<=5000;

5000 rows deleted

 

SQL> commit;

Commit complete

 

SQL> analyze table test3 compute statistics;

Table analyzed

 

SQL> col segment_name for a10;
SQL> select us.segment_name,us.extents,us.blocks from user_segments us where us.segment_name=upper('test3');

SEGMENT_NA    EXTENTS     BLOCKS
---------- ---------- ----------
TEST3               5         40

 

SQL> col table_name for a10;
SQL>  select table_name,blocks,t.empty_blocks  from user_tables t where t.table_name=upper('test3');

TABLE_NAME     BLOCKS EMPTY_BLOCKS
---------- ---------- ------------
TEST3              37            3

 

SQL> select count(distinct dbms_rowid.rowid_block_number(rowid)) used_blocks from test3;

USED_BLOCKS
-----------
         17


我们从查询中可以发现test3的HWM没有变换还是37blocks,tests总共空间为40blocks。经过删除后test3实际用的块是17个

 


下面我们用move降低下HWM

 

SQL> alter table test3 move;

Table altered

 

SQL> col segment_name for a10;
SQL> select us.segment_name,us.extents,us.blocks from user_segments us where us.segment_name=upper('test3');

SEGMENT_NA    EXTENTS     BLOCKS
---------- ---------- ----------
TEST3               3         24

 

SQL> col table_name for a10;
SQL> select table_name,blocks,t.empty_blocks  from user_tables t where t.table_name=upper('test3');

TABLE_NAME     BLOCKS EMPTY_BLOCKS
---------- ---------- ------------
TEST3              37            3

 

user_tables里的数据没有变化,哦,原来是忘记analyze了,从这里也可以看出user_segments是oracle自动维护的。

 

 

SQL> analyze table test3 compute statistics;

Table analyzed

 

SQL>  select us.segment_name,us.extents,us.blocks from user_segments us where us.segment_name=upper('test3');

SEGMENT_NA    EXTENTS     BLOCKS
---------- ---------- ----------
TEST3               3         24

 

SQL> select table_name,blocks,t.empty_blocks  from user_tables t where t.table_name=upper('test3');

TABLE_NAME     BLOCKS EMPTY_BLOCKS
---------- ---------- ------------
TEST3              20            4

SQL>


现在再来看hwm变为20了,已经降下来了啊,空间也收缩了,从40blocks降到24blocks(注意收缩到initial指定值)。
但shrink space就收缩到存储数据的最小值,下面测试说明

 

创建测试表:


SQL>   create table test5 (id number) storage (initial 1m next 1m);

Table created

 

初始化数据


SQL>
SQL>   begin
  2     for i in 1..100000 loop
  3     insert into test5 values(i);
  4    end loop;
  5    end;
  6  /

PL/SQL procedure successfully completed

 

SQL> analyze table test5 compute statistics;

Table analyzed

 

SQL> select SEGMENT_NAME,EXTENTS,BLOCKS,INITIAL_EXTENT/1024/1024 init from user_segments where SEGMENT_NAME='TEST5';

SEGMENT_NA    EXTENTS     BLOCKS       INIT
---------- ---------- ---------- ----------
TEST5              17        256          1

 

SQL> select TABLE_NAME,BLOCKS,EMPTY_BLOCKS from user_tables where table_name='TEST5';

TABLE_NAME     BLOCKS EMPTY_BLOCKS
---------- ---------- ------------
TEST5             180           76

 

 

可以从查询数据看出,test5初始化1m即128个blocks,但数据比较多,所以又按next参数要求扩展了1m空间,扩展了17个extents。
这里的test5总空间大小为256个blocks,使用空间为180blocks,HWM也是180blocks


SQL> delete from test5 where rownum<=50000;

50000 rows deleted

 

SQL> analyze table test5 compute statistics;

Table analyzed

 

SQL> select SEGMENT_NAME,EXTENTS,BLOCKS,INITIAL_EXTENT/1024/1024 init from user_segments where SEGMENT_NAME='TEST5';

SEGMENT_NA    EXTENTS     BLOCKS       INIT
---------- ---------- ---------- ----------
TEST5              17        256          1

 

SQL> select TABLE_NAME,BLOCKS,EMPTY_BLOCKS from user_tables where table_name='TEST5';

TABLE_NAME     BLOCKS EMPTY_BLOCKS
---------- ---------- ------------
TEST5             180           76

 

整理碎片,降低HWM


SQL>  alter table test5 move;

Table altered


SQL> analyze table test5 compute statistics;

Table analyzed

 

SQL> select SEGMENT_NAME,EXTENTS,BLOCKS,INITIAL_EXTENT/1024/1024 init from user_segments where SEGMENT_NAME='TEST5';

SEGMENT_NA    EXTENTS     BLOCKS       INIT
---------- ---------- ---------- ----------
TEST5              16        128          1

 

SQL> select TABLE_NAME,BLOCKS,EMPTY_BLOCKS from user_tables where table_name='TEST5';

TABLE_NAME     BLOCKS EMPTY_BLOCKS
---------- ---------- ------------
TEST5              85           43

 

从上面的查询数据可以看出HWM已经从180降低到85,test5总大小从256blocks收缩到128个blocks(initial指定大小)。


下面看看用shrink space收缩空间的情况

 

SQL> alter table test5 enable row movement;

Table altered


SQL> alter table test5 shrink space;

Table altered

 

SQL> select SEGMENT_NAME,EXTENTS,BLOCKS,INITIAL_EXTENT/1024/1024 init from user_segments where SEGMENT_NAME='TEST5';

SEGMENT_NA    EXTENTS     BLOCKS       INIT
---------- ---------- ---------- ----------
TEST5              11         88          1

 

SQL> select TABLE_NAME,BLOCKS,EMPTY_BLOCKS from user_tables where table_name='TEST5';

TABLE_NAME     BLOCKS EMPTY_BLOCKS
---------- ---------- ------------
TEST5              85           43

SQL>


从上面的数据可以看到test5进一步从128个blocks降低到88个blocks

 

结论:


shrink space收缩到数据存储的最小值,alter table move(不带参数)收缩到initial指定值,也可以用alter table test5 move storage(initial 500k)指定收缩的大小,这样可以达到shrink space效果

 

 

 

经过以上测试,得出的两个结论,到底用哪一个命令来整理碎片,消除行迁移呢?这就要根据实际业务需要,如果你只是收缩空间,数据增长很慢,那用shrink可以但是如果数据增长很快的话,用move就比较合适,避免再重新分配空间啊

 

 

 

备注:
在10g之后,整理碎片消除行迁移的新增功能shrink space

 

alter table <table_name> shrink space [ <null> | compact | cascade ];

 

compact:这个参数当系统的负载比较大时可以用,不降低HWM。如果系统负载较低时,直接用alter table table_name shrink space就一步到位了


cascade:这个参数是在shrink table的时候自动级联索引,相当于rebulid index。

 

普通表:

shrink必须开启行迁移功能。
alter table table_name enable row movement ;

 

保持HWM,相当于把块中数据打结实了
alter table table_name shrink space compact;

 

回缩表与降低HWM
alter table table_name shrink space;

 

回缩表与相关索引,降低HWM
alter table table_name shrink space cascade;

 

回缩索引与降低HWM
alter index index_name shrink space

 

虽然在10g中可以用shrink ,但也有些限制:

 

1). 对cluster,cluster table,或具有Long,lob类型列的对象 不起作用。
2). 不支持具有function-based indexes 或 bitmap join indexes的表
3). 不支持mapping 表或index-organized表。
4). 不支持compressed 表

 

 

 

 

------end------


转载地址:http://blog.youkuaiyun.com/wyzxg/article/details/5631721

Oracle收缩表,释放占用的存储空间(shrink space) 收缩表(shrink space cascade),整理碎片,降低高水位。 阅读详情

相关推荐

Keil 5安装教程(C51与MDK共存)

目录前言MDK的安装C51的安装安装完成后的验证新建C51工程添加C51程序文件编译测试总结 前言 本篇文章将介绍嵌入式开发工具Keil 5的安装方法,并使MDK(Microcontroller Development Kit,开发stm32时会用到)和C51(51单片机C语言软件开发系统)共存。今后使用Keil 5可同时开发51单片机程序和ARM单片机程序,便于学习与从51到32的过渡。 注: 为防止商业纠纷,本篇文章不涉及文中软件的注册破解,请支持正版。 同时为了便于今后更深入的学习,本文不会介绍软件的

xushu_me的博客 6万+

关于alter table move

alter table move主要有两方面的作用 1.用来移动table到其他表空间 2.用来减少table中的存储碎片,优化存储空间和性能 案例1:移动table到其他表空间 --alter table move SQL> create table t tablespace system as select * from all_objects; Table cre

gumengkai的博客 1万+

SWIPT技术(无线通信携能技术)的简介与架构——(后续补充无人机SWIPT方向)

SWIPT一、SWIPT(无线通信携能)技术简介1.1、组成:1.2、与传统无线通信的区别:1.3、SWIPT 的集成接收器架构设计1、单独的接收器2、TS架构——时间开关(Time switching,TS)3、PS架构——功率分流(Power splitting,PS)4、天线开关接收器主要两种架构的区别参考文献SWIPT的发展 一、SWIPT(无线通信携能)技术简介 SWIPT(Simultaneous Wireless Information and Power Transfer )是各种WPT技术

Blue 1万+

ALTER TABLE...MOVE 相关使用方法

1.  The ALTER TABLE...MOVE statement enables you to relocate data of a non-partitioned table or of a partition of a partitioned table into a new segment, and optionally into a different tablespace f

zhanglongfei1016的专栏 2700

有史以来最小的GIF/png/jpg/jpeg

昨天我对图像进行了 base64 编码,这样我就可以将它发送到 CouchDB 以测试我正在为客户编写的一些代码。它让我想起了我之前在远程服务器上设置 cookie 时所做的事情。基本上,一个小的 PHP 脚本被放在远程服务器上,它接受几个 GET 参数并根据它们的值设置一些 cookie。然后脚本输出一个 1x1 的透明 GIF。本地服务器上的 PHP 脚本生成了一个 IMG 标签,该标签链接到该图像并根据本地服务器上的 COOKIES 设置参数。

凌凌1301的博客 1417

【MIMIC数据库教程】一、MIMIC-IV3.1表格与字段详解(一):Hosp和ICU模块表格整体介绍

MIMIC-IV 3.1 版本包含住院 (hosp) 和 重症监护 (ICU)提供全院电子病历数据,包括入院信息、实验室测量、微生物学、用药、账单等,共计22 张表。记录重症监护室数据,如静脉注射、呼吸机设置、生命体征等,共计9 张表。

BD_Design_cs的博客 3426

alter table move 与shrink space的区别

转自:https://blog.youkuaiyun.com/zhjxixi/article/details/7661378 案例: 同事将一关键表中删了多余的300w条数据后,程序就变的异常缓慢。分析得出,应该是表空间碎片过多,旧的索引效率过低。 执行下面两句话:   alter table ycsbt_qyygxx_jb move; alter index R_SBXX_YCSBD_FK re...

lv941002的博客 723

【鸿蒙游戏上架审核规范指南】

华为鸿蒙游戏上架审核规范指南摘要

weixin_44161102的博客 928

oracle alter table alter table move跟shrink space的区别

http://www.08.la/news2010/newshtml/JiShuWenZhang/ORACLE/18696.html

旅行人生 1900

【Labview】对连续采集数据的一种采样方法

图1如图1,想要对这样一个连续信号进行数据点的采集,我根据网上收集到的方法,在此分享一下最终的结果。可以拓展结合文件的写入,完成对连续信号的采集和输出。 已知: 一个连续信号,如图1. 目标: 设定一定采集点个数、采集点时间间隔、和采集周期次数,得到这条连续信号的数据点,如图2. 图2 方法如下: 主要利用的是队列的方法。 在连续信号生成的时候,不断的写入队列,并且清除队列。 ...

李时珍食疗志的博客 1万+

AgentScope实战训练营-Java开发HITL人机协作AI应用完整指南

本文手把手带你从零搭建一个基于 Spring Boot WebFlux + AgentScope + 通义千问的人机协作(HITL)AI 聊天应用。项目涵盖流式对话、工具调用、高危操作确认、对话中断、动态 MCP 工具接入、中英文双语界面等完整功能。文章从环境准备、pom.xml 配置、DTO 数据模型、Hook 机制、AgentService 核心服务、ChatController 接口到前端 HTML/CSS/JS 实现,逐一讲解每行代码的设计意图,并附带 REST API 接口说明、测试场景、常见问题

program哲学 713

oracle table space,alter table move 和 alter table shrink space的区别

本帖最后由 lhqmccn 于 2014-5-15 15:49 编辑move 和shrink 的共同点1、收缩段2、消除部分行迁移3、消除空间碎片4、使数据更紧密shrink语法:alter table TABLE_NAME shrink space [compact|cascate]segment shrink执行的两个阶段:1、数据重组(compact):通过一系列insert、delete操...

weixin_33945547的博客 1077

【git】win 10 / win 11:git 首次拉取云效平台代码详细教程

git 首次拉取云效平台代码详细教程:Git 生成 SSH 公钥、云效工作台添加 SSH 公钥、git 使用 SSH / HTTP 链接拉取云效代码

顾三殇 —— 博客空间(软件测试) 4219

ALTER TABLE MOVE | SHRINK SPACE区别

ALTER TABLE MOVE | SHRINK SPACE区别 Alter table move或者shrink space 可以收缩段,消除部分行迁移,消除空间碎片,使数据更紧密,但move跟shrink space...

161

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

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

alter table move和alter table shrink space的区别

Alter table move和alter table shrinkspace的区别 1)使用alter tablemove,会把表格最多收缩到创建表格时的storage子句指定的初始大小,使用alter table shrink space,则不受此限制。 2)使用alter table move之后,索引会无效,需要重建,使用alter table shrink space,则不会使索引

gumengkai的博客 1812

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

上一篇: Oracle的同义词(synonyms)详解
下一篇: ORACLE 中的lock 机制
VagueCoder
博客等级 码龄13年 4粉丝 8原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值