greenplum创建表空间脚本-待更新

Greenplum创建表空间 在Greenplum中,默认的表空间只有两个,分别是pg_default和pg_global,这两个表空间都放在了gp_system下。为了更有效的管理数据,需要对表进行管理,在oracle中有表空间的概念,在Greenplum中,表空间和其类似。下面介绍如何创建一个新的表空间。 1、为每个表空间创建系统目录 在master和所有的segment上都要创建。 MASTER:/home/gpa 阅读详情
文件空间和目录
testdb=# select oid,* from pg_filespace;
 oid  |  fsname   | fsowner 
------+-----------+---------
 3052 | pg_system |      10
(1 row)


testdb=# select * from pg_filespace_entry;
 fsefsoid | fsedbid |      fselocation      
----------+---------+-----------------------
     3052 |       1 | /data/master/gpseg-1
     3052 |       2 | /data1/primary/gpseg0
(2 rows)


                                                             ^
testdb=# SELECT  spcname as tblspc, fsname as filespc, fsedbid as seg_dbid, fselocation as datadir FROM  pg_tablespace pgts, pg_filespace pgfs, pg_filespace_entry pgfse WHERE  pgts.spcfsoid=pgfse.fsefsoid AND pgfse.fsefsoid=pgfs.oid ORDER BY tblspc, seg_dbid;
   tblspc   |  filespc  | seg_dbid |        datadir        
------------+-----------+----------+-----------------------
 pg_default | pg_system |        1 | /data/master/gpseg-1
 pg_default | pg_system |        2 | /data1/primary/gpseg0
 pg_global  | pg_system |        1 | /data/master/gpseg-1
 pg_global  | pg_system |        2 | /data1/primary/gpseg0
(4 rows)


创建新的文件空间及表空间
多节点可以使用这个命令去创建
[gpadmin@mdw data]$ gpssh -f /home/gpadmin/seg_host
先创建文件目录:
[gpadmin@mdw /]$ mkdir /data/user_spc
[gpadmin@mdw /]$ mkdir /data1/user_spc
[gpadmin@mdw /]$ mkdir /data/user_spc/master/
[gpadmin@mdw /]$ mkdir /data1/user_spc/primary/


创建一个配置文件:
[gpadmin@mdw data]$ gpfilespace -o gpfilespace_test
20160807:02:10:24:003377 gpfilespace:mdw:gpadmin-[INFO]:-
A tablespace requires a file system location to store its database
files. A filespace is a collection of file system locations for all components
in a Greenplum system (primary segment, mirror segment and master instances).
Once a filespace is created, it can be used by one or more tablespaces.




20160807:02:10:24:003377 gpfilespace:mdw:gpadmin-[INFO]:-getting config
Enter a name for this filespace
> gpfilespace_test


Checking your configuration:
Your system has 1 hosts with 1 primary and 0 mirror segments per host.


Configuring hosts: [localhost.localdomain]


Please specify 1 locations for the primary segments, one per line:
primary location 1> /data1/user_spc/primary/


Enter a file system location for the master
master location> /data/user_spc/master/
20160807:02:11:12:003377 gpfilespace:mdw:gpadmin-[INFO]:-Creating configuration file...
20160807:02:11:12:003377 gpfilespace:mdw:gpadmin-[INFO]:-[created]
20160807:02:11:12:003377 gpfilespace:mdw:gpadmin-[INFO]:-
To add this filespace to the database please run the command:
   gpfilespace --config /data/gpfilespace_test
 
配置文件空间:
[gpadmin@mdw /]$ gpfilespace -c /data/gpfilespace_test
20160807:02:21:35:003736 gpfilespace:mdw:gpadmin-[INFO]:-
A tablespace requires a file system location to store its database
files. A filespace is a collection of file system locations for all components
in a Greenplum system (primary segment, mirror segment and master instances).
Once a filespace is created, it can be used by one or more tablespaces.




20160807:02:21:35:003736 gpfilespace:mdw:gpadmin-[INFO]:-getting config
Reading Configuration file: '/data/gpfilespace_test'
20160807:02:21:35:003736 gpfilespace:mdw:gpadmin-[INFO]:-Performing validation on paths
..............................................................................


20160807:02:21:36:003736 gpfilespace:mdw:gpadmin-[INFO]:-Connecting to database
20160807:02:21:36:003736 gpfilespace:mdw:gpadmin-[INFO]:-Filespace "gpfilespace_test" successfully created


查询新创建的文件空间:
testdb=# select oid,* from pg_filespace;
  oid  |      fsname      | fsowner 
-------+------------------+---------
  3052 | pg_system        |      10
 17127 | gpfilespace_test |      10
(2 rows)


testdb=# select * from pg_filespace_entry;                                                                                                                               fsefsoid | fsedbid |          fselocation           
----------+---------+--------------------------------
     3052 |       1 | /data/master/gpseg-1
     3052 |       2 | /data1/primary/gpseg0
    17127 |       1 | /data/user_spc/master/gpseg-1
    17127 |       2 | /data1/user_spc/primary/gpseg0
(4 rows)
17127 为新创建的文件空间


表空间是基于文件空间创建的
创建表空间
testdb=# CREATE TABLESPACE tablespace_test FILESPACE gpfilespace_test;
CREATE TABLESPACE


testdb=# \db
             List of tablespaces
      Name       |  Owner  |  Filespae Name   
-----------------+---------+------------------
 pg_default      | gpadmin | pg_system
 pg_global       | gpadmin | pg_system
 tablespace_test | gpadmin | gpfilespace_test
 
postgres=# select procpid from pg_stat_activity where DATNAME = 'template1';
 procpid 
---------
    3168
    3319
(2 rows)


postgres=# \q
[gpadmin@mdw /]$ kill 3168
[gpadmin@mdw /]$ kill 3319
[gpadmin@mdw /]$ psql
psql (8.2.15)
Type "help" for help.


testdb=# create database gpload_testDB Tablespace tablespace_test;
CREATE DATABASE
testdb=# \l+
                                               List of databases
     Name      |  Owner  | Encoding |  Access privileges  | Size  |   Tablespace    |        Description        
---------------+---------+----------+---------------------+-------+-----------------+---------------------------
 gpload_testdb | gpadmin | UTF8     |                     | 19 MB | tablespace_test | 
 postgres      | gpadmin | UTF8     |                     | 19 MB | pg_default      | 
 template0     | gpadmin | UTF8     | =c/gpadmin          | 18 MB | pg_default      | 
                                    : gpadmin=CTc/gpadmin                             
 template1     | gpadmin | UTF8     | =c/gpadmin          | 19 MB | pg_default      | Default template database
                                    : gpadmin=CTc/gpadmin                             
 testdb        | gpadmin | UTF8     |                     | 19 MB | pg_default      | 
(5 rows)
testdb=# \c gpload_testdb
You are now connected to database "gpload_testdb" as user "gpadmin".
gpload_testdb=# create schema test;
CREATE SCHEMA
gpload_testdb=# create table test.t_date(dateid varchar(8),datename varchar(32),monthid varchar(6),yearid varchar(4))distributed by (dateid);
CREATE TABLE


gpload_testdb=# create tablespace tspc_1 filespace gpfilespace_test;
CREATE TABLESPACE
gpload_testdb=# \db+
                              List of tablespaces
      Name       |  Owner  |  Filespae Name   | Access privileges | Description 
-----------------+---------+------------------+-------------------+-------------
 pg_default      | gpadmin | pg_system        |                   | 
 pg_global       | gpadmin | pg_system        |                   | 
 tablespace_test | gpadmin | gpfilespace_test |                   | 
 tspc_1          | gpadmin | gpfilespace_test |                   | 
(4 rows)
gpload_testdb=# \d
No relations found.
gpload_testdb=# set search_path to public,test;
SET
gpload_testdb=# \d
              List of relations
 Schema |  Name  | Type  |  Owner  | Storage 
--------+--------+-------+---------+---------
 test   | t_date | table | gpadmin | heap
(1 row)


创建表使用另一表空间
gpload_testdb=# create table test.test1 (col1 int,col2 varchar(32),col3 varchar(64)) tablespace tspc_1 distributed by(col1);
CREATE TABLE




CREATE TABLE test.T_PARTITION_TEST(ID VARCHAR(16),MONTHID INT,COMPANYID VARCHAR(32),AMOUNT DECIMAL(18,2)) 
TABLESPACE TSPC_1 DISTRIBUTED BY(ID)
PARTITION BY LIST(MONTHID)(
  PARTITION T_PARTITION_TEST_PR_201601 VALUES(201601),
  PARTITION T_PARTITION_TEST_PR_201602 VALUES(201602),
  PARTITION T_PARTITION_TEST_PR_201603 VALUES(201603),
  PARTITION T_PARTITION_TEST_PR_201604 VALUES(201604),
  PARTITION T_PARTITION_TEST_PR_201605 VALUES(201605),
  PARTITION T_PARTITION_TEST_PR_201606 VALUES(201606),
  PARTITION T_PARTITION_TEST_PR_201607 VALUES(201607),
  PARTITION T_PARTITION_TEST_PR_201608 VALUES(201608),
  Default PARTITION OTHER TABLESPACE tablespace_test
);


创建分区表使用不同表空间
gpload_testdb=# CREATE TABLE test.T_PARTITION_TEST(ID VARCHAR(16),MONTHID INT,COMPANYID VARCHAR(32),AMOUNT DECIMAL(18,2)) 
gpload_testdb-# TABLESPACE TSPC_1 DISTRIBUTED BY(ID)
gpload_testdb-# PARTITION BY LIST(MONTHID)(
gpload_testdb(#   PARTITION T_PARTITION_TEST_PR_201601 VALUES(201601),
gpload_testdb(#   PARTITION T_PARTITION_TEST_PR_201602 VALUES(201602),
gpload_testdb(#   PARTITION T_PARTITION_TEST_PR_201603 VALUES(201603),
gpload_testdb(#   PARTITION T_PARTITION_TEST_PR_201604 VALUES(201604),
gpload_testdb(#   PARTITION T_PARTITION_TEST_PR_201605 VALUES(201605),
gpload_testdb(#   PARTITION T_PARTITION_TEST_PR_201606 VALUES(201606),
gpload_testdb(#   PARTITION T_PARTITION_TEST_PR_201607 VALUES(201607),
gpload_testdb(#   PARTITION T_PARTITION_TEST_PR_201608 VALUES(201608),
gpload_testdb(#   Default PARTITION OTHER TABLESPACE tablespace_test
gpload_testdb(# );
NOTICE:  CREATE TABLE will create partition "t_partition_test_1_prt_t_partition_test_pr_201601" for table "t_partition_test"
NOTICE:  CREATE TABLE will create partition "t_partition_test_1_prt_t_partition_test_pr_201602" for table "t_partition_test"
NOTICE:  CREATE TABLE will create partition "t_partition_test_1_prt_t_partition_test_pr_201603" for table "t_partition_test"
NOTICE:  CREATE TABLE will create partition "t_partition_test_1_prt_t_partition_test_pr_201604" for table "t_partition_test"
NOTICE:  CREATE TABLE will create partition "t_partition_test_1_prt_t_partition_test_pr_201605" for table "t_partition_test"
NOTICE:  CREATE TABLE will create partition "t_partition_test_1_prt_t_partition_test_pr_201606" for table "t_partition_test"
NOTICE:  CREATE TABLE will create partition "t_partition_test_1_prt_t_partition_test_pr_201607" for table "t_partition_test"
NOTICE:  CREATE TABLE will create partition "t_partition_test_1_prt_t_partition_test_pr_201608" for table "t_partition_test"
NOTICE:  CREATE TABLE will create partition "t_partition_test_1_prt_other" for table "t_partition_test"
CREATE TABLE


修改表空间名称
gpload_testdb=# alter tablespace tspc_1 rename to  tpsc_2;
ALTER TABLESPACE


gpload_testdb=# select * from pg_filespace;
      fsname      | fsowner 
------------------+---------
 pg_system        |      10
 gpfilespace_test |      10
(2 rows)


修改文件空间名称
gpload_testdb=# alter filespace gpfilespace_test rename to filespace_test;
ALTER FILESPACE
gpload_testdb=# select * from pg_filespace;
     fsname     | fsowner 
----------------+---------
 pg_system      |      10
 filespace_test |      10
(2 rows)


删除表空间时先移除依赖的对象
gpload_testdb=# drop tablespace tpsc_2;

ERROR:  tablespace "tpsc_2" is not empty


以上未整理完成,待更新,若有错误,请指正,谢谢

---------------------------------------------------------------------------------------------

gp初学者

《GreenPlum系列》GreenPlum初级教程-05GreenPlum语言DDL&DML&DQL 1.DDL(Data Definition Language)数据定义语言 2.DML(Data Manipulation Language)数据操作语言 3.DQL(Data Query Language)数据查询语言 阅读详情

相关推荐

获取greenplumn建表语句脚本

获取greenplumn建表语句脚本

openjtag 使用记录

让CPU运行 Reset run Reset和reset run是结果是一样的。 让CPU停止运行 Reset halt 让CPU停止运行,并且执行reset-init脚本 Reset init 从板上dump数据到PC端 Dump_image 格式:dump_image filename address size 保存在Work Dir中。 下载image到板上 loa

kevin.ji的专栏 1520

postgresql greenplum建表语句超详细

postgresql greenplum建表语句超详细 带说明 详细物理建模所需参数

Greenplum 6.16.3 创建表空间

很多说用gpfilespace工具来创建文件空间,但是发现没有这个工具,没有这个文件,用另一种方式:https://docs-cn.greenplum.org/v6/ref_guide/sql_commands/CREATE_TABLESPACE.html。/path/to/dir_i是segment实例用作表空间的根目录的主机系统文件位置的绝对路径。目录的绝对路径(主机系统文件位置),它将是表空间的根目录。只有超级用户可以创建表空间,但是他们可以将表空间的所有权分配给非超级用户。要创建的表空间的名称。

weixin_43488348的博客 436

Halcon一维测量实战:从measure_pos与measure_pairs的底层原理到精准应用

本文深入解析Halcon中measure_pos与measure_pairs算子的底层原理与精准应用,涵盖参数调优、测量矩形方向设置及典型工业场景实战。通过对比分析,揭示两者在一维测量中的核心差异与适用场景,提供从基础到高级的完整解决方案,助力工业视觉检测精度提升。

weixin_42525551的博客 422

避坑!瑞萨RZ/N2L用J-Link下载调试的那些‘坑’(从驱动版本到硬件架构选择)

本文详细解析了瑞萨RZ/N2L开发中使用J-Link调试时常见的兼容性问题与解决方案,包括驱动版本选择、SWD连接优化及e2 studio调试技巧。特别针对硬件架构与驱动版本的匹配问题提供了实用对照表,帮助开发者高效避开调试陷阱,提升开发效率。

weixin_30576827的博客 441

Greenplum表空间管理

本文介绍如何创建表空间,如何在表空间上创建数据库,如何查询表空间和database; 目录 1 表空间的概述 2 创建filespace 2.1 检查当前的配置情况 2.2 合理利用高速盘的方案 2.3 创建文件系统目录 2.4 创建配置文件 2.5 按照相关命令进行创建文件目录 3 创建表空间 4 相关查询 5 临时文件和事务文件的迁移 1 表空间的概述 表空...

murkey的专栏 1006

lumerical-环形谐振器

利用mode求解器优化得到所需的环的总长度,即环形器的半径,然后通过varFDTD得到光场分布和透过率.

m0_61776728的博客 2189

Greenplum6.x常用语句-表空间角色权限

root用户登录四台服务器,每台都执行下面操作 二.创建库 创建库gpadmin用户登录master机器 三. 表空间 gpadmin用户登录master机器每个 Greenplum 数据库系统都有以下默认表空间。pg_global用于共享系统目录。 pg_default,默认表空间。由template1和template0数据库使用。 要查看表空间信息,请使用pg_tablespace目录表获取表空间的对象 ID(OID),然后使用gp_tablespace_location()函数显示表空间目录。这是一

flying roc 1009

飞牛NAS打造成童年经典游戏机

这篇文章介绍如何使用飞牛NAS搭建经典游戏模拟器。首先需开启Docker并下载RetroArch-web镜像,随后创建容器并设置端口映射。启动后上传游戏ROM文件(如NES格式),在模拟器中加载即可游玩。文章以修改版坦克大战为例,详细说明按键配置方法。同时还提到公网访问需配置DDNS或使用ZeroTier内网穿透。通过这套方案,用户可以在NAS上重温红白机等经典游戏体验。

dgnankai的专栏 884

Open Dynamics Engine(ODE)物理引擎教程(1)--下载与安装准备

引言 ODE是一个免费的工业级库,用于模拟关节式刚体动力学,例如地面车辆、腿部生物和虚拟现实环境中的移动对象。它具有快速、灵活、健壮和独立于平台的特点,具有先进的关节、摩擦接触和内置的碰撞检测功能。 项目主页:http://www.ode.org/ 线上手册:http://ode.org/wiki/index.php?title=Manual 本教程为博主亲自亲测过程的总结,转载请注明出处! ...

腿足机器人领域 2216

greenplum授权

在Greenplum数据库中,表空间(Tablespace)是用于存储数据库对象的物理位置。通过授予创建、使用和修改模式的权限,您可以控制用户在数据库中创建、访问和修改对象的范围和权限。

东坡居士的博客 896

YOLOv12涨点改进 | 全网独家首发Conv改进篇 | Arxiv 2025 | 引入一种新的WConv加权卷积改进YOLOv12,显著提升其特征提取能力和目标检测精度

本文提出了一种新型加权卷积(WConv)模块,通过引入最优密度函数动态调整邻域像素权重,显著提升了YOLOv12目标检测性能。WConv在保持参数数量不变的情况下,提高了模型精度(VGG准确率提升10%)、增强了小目标检测能力,并改善了多尺度特征提取。文中详细介绍了模块原理、网络结构改进方法,并提供了核心代码实现和yaml配置文件。实验表明,该方法在图像任务中最高可降低53%的损失,虽然会带来11%的时间开销,但具有优异的鲁棒性。该技术可广泛应用于2D/3D图像处理领域。

Ai缝合怪、助力小伙伴高效发论文 215

Greenplum常用问题汇总【持续更新】

Greenplum是世界领先的MPP架构数据库,底层基于PostgreSQL,能处理大规模分析型查询。当前Greenplum在Pivotal被VMWare收购后,已经归属于VMWare Tanzu产品线。 当前社区在微信、钉钉、QQ等都有相关的群,有很多新入门的小伙伴会问到各种各样基础的问题。为了帮助Greenplum中文社区的小伙伴更好的使用Greenplum,我特意整理了社区和论坛中经常问到的一些问题供大家参考。本文内容将持续更新,敬请收藏关注! ------------------------20

专注数据库、大数据领域干货分享,用严谨的数据技术广交天下朋友。 1295

PyTorch深度学习实战(29)——变分自编码器(Variational Autoencoder, VAE)

变分自编码器 (Variational Autoencoder, VAE) 是一种结合了自编码器和概率建模的生成模型,通过编码器将输入数据映射到潜在空间中的概率分布,并通过解码器将从潜在空间采样得到的潜在变量映射回原始数据空间,实现了数据的生成和特征学习。

盼小辉丶的博客 1万+

【数字孪生与仿真技术】07:焊装生产线虚拟调试与PLC代码生成全流程实战:从数字孪生到智能优化

摘要:本文系统阐述焊装生产线虚拟调试与PLC代码自动化生成的完整技术体系,结合工业4.0背景下的智能制造需求,构建从离散事件仿真、机器人运动规划到PLC控制逻辑生成的全流程解决方案。通过MATLAB/Simulink平台实现焊装线物流仿真优化,采用遗传算法进行缓冲区容量配置,结合Stateflow状态机设计PLC控制逻辑,并利用PLC Coder生成西门子S7-1500兼容的ST代码。某车企焊装线应用案例显示,虚拟调试技术使调试周期缩短75%,OEE提升13.4%,年节约成本超$420万。

专注于人工智能、软件开发、工控自动化、工厂数字化及智能化等领域,希望和大家共同进步! 1829

Greenplum实践总结

实际使用greenplum中的一些问题或知识点,做一个汇总,会不断进行更新。 1.对于greenplum,当创建表时,若指定一个primary key,会将其默认设置为索引,此时,当进行大量数据的插入时,由于索引的存在,会导致出书时间变长。 另:当进行大量数据的插入时,需先删除掉索引,待数据插入完成后再建立索引。 2.在greenplum中,外部表不能指定 not null,也不能指定primar...

hmxz2nn的博客 2264

android 蓝牙通讯demo

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

mysql 表空间收缩_Greenplum 列存表(AO表)的膨胀和垃圾检查与空间收缩

Greenplum释放表的空间1 Greenplum产生垃圾空间说明Greenplum支持行储存(HEAP储存)与列(append-only)储存,对于AO存储,虽然是appendonly,但实际上GP是支持DELETE和UPDATE的,被删除或更新的行,通过BITMAP来标记删除与修改。AO存储是块级组织,当一个块内的数据大部分都被删除或更新掉时,扫描它浪费的成本实际上是很高的。而Postgre...

weixin_30647489的博客 600

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

数学建模模型总结

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

gp-greenplum-vacuum-资源回收-AO表空间回收

gp有个命令是VACUUM 这个命令主要用来回收过时的表空间,这些过时的空间是怎么产生的呢? 原因是: 由于Greenplum数据库中使用了MVCC事务并发模型,即使任何新事务都不可见,被删除或更新的数据行仍占据磁盘上的物理空间。 过期的行会增加磁盘上的表大小,并最终减慢表的扫描速度 怎么判断表是否需要回收呢:堆表通过查看这个视图gp_toolkit.gp_bloat_diag可以看到,AO表需要使用函数查看__gp_aovisimap_compaction_info AO表示例: select * fro

qq_33440853的博客 1591

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

[翻译]GPDB中的文件空间与表空间

GPDB中的文件空间与表空间GreenPlum是一个快速、灵活、纯软件的分析数据处理引擎,具有一些工具和特性可以充分利用任意个数硬件或者虚拟环境用来部署集群。这里讨论的一个特性是使用文件空间将数据加载和查询活动与底层的IO卷匹配。一旦在集群中创建了一个物理文件空间,它就会映射到一个逻辑表空间,然后创建表和索引时使用它。GP5的使用中可以参考下本文,GP6通过gpinitsystem工具创建文件空间...

帅的数说 308

Greenplum中管理数据

GP的管理数据

行者牛仔 9364

Greenplum系统参数查看操作

Greenplum问题分析的基本操作 Greenplum基于PostgreSQL开发的关系型数据仓库,跟PostgreSQL的兼容性非常好,因此本文很多语法与PG通用。 1.查看实例配置和状态 select * from gp_configuration order by 1 ; select * from gp_configuration_history order by 1 ; 主要字段说明: Content:该字段相等的两个实例,是一对P(primary instance)和M(mirror

芷芸的博客 4469

Greenplum中的vacuum和analyze

Greenplum中的vacuum和analyze 首先说说vacuum,该选项主要是清理数据库表中的垃圾空间 定义: VACUUM reclaims storage occupied by deleted tuples. In normal Greenplum Database operation, tuples that are deleted or obsoleted by an up

爱飞的蒲公英 1万+

Greenplum-表的存储模式

在学习Greenplum的过程中,了解到Greenplum中表有多种不同的存储模式,包括堆表、AO表、行存、列表、压缩、加密这些特性,这些不同的存储模式分别适用什么样的场景,我们在真正使用的时候又该怎么合理的选择哪一种表呢?本文就GP中的这几种表的存储模式加以说明。

数据源的港湾 1991

Greenplum简介

Greenplum: http://greenplum.org/ 原来是个商业产品,后来开源。从Slogan看: 是个数据库 着眼于数据仓库 主要在于大规模并行 基于强大的PostgreSQL,PostgeSQL提供了诸如表空间、外部表等功能,支持丰富的数据类型(包含key-value,JSON,XML,GIS,甚至支持各种集合图形的表示)。其中的FDW外部表是一个非常强大的功能,可以直接将外部文

Spring , Hadoop, Spark , BI , ML 5047

GREENPLUM优化建议

1. 在完成大批量数据装载之后,针对目标表总是进行vacuum analyze操作。 2. 表的布局: 尽量把数据分布键放在最前面,如果是分区表,那么接下来是分区键,并且在此基础上建议按照数据类型宽度从大到小的顺序排列比如先8 byte的列,再4字节,再2字节。 3. 数据分布键的选择: 数据分布均匀是保证GP高效并行处理能力的基础。因此定义表时,如果选用HASH分布策略,保证数据分布均匀

点点滴滴一世界 3838
下一篇: greenplum创建外部表笔记-readable篇
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值