HadoopDB集群配置方法

hadoopDB 数据仓库 简介 读了两篇关于hadoopDB数据仓库的论文之后,写一点关于hadoopDB的简介: hadoopDB是耶鲁大学的一个大学项目, 目的是为了构建一个数据仓库的工具。 HadoopDB 结合了hadoop 和paralled RDBMS,结合两个技术的优点。 HadoopDB is to connect multiple single_node database systemusing Ha 阅读详情

本文介绍在2个节点上安装配置HadoopDB方法。各节点的名称分别为Cluster01(192.168.0.1),Cluster02(192.168.0.2)。

以下若是用 hadoop@Cluster0X:~ 代表 Cluster01 ~ Cluster02 都要做的.


参考资料1:HadoopDB Quick Start Guide

参考资料2:HadoopDB安装使用




1  首先在各节点上安装Hadoop-0.20.2, 参考此文 。

 

2  各节点安裝设置 PostgreSQL:

  • 安裝并为数据库建立 hadoop 帐号,假定使用密碼为 1234
  • hadoop@Cluster0X:~$ sudo apt-get install postgresql
  • hadoop@Cluster0X:~$ sudo vim /etc/postgresql/8.4/main/pg_hba.conf
    • #local   all         all                               ident
      local   all         all                               trust
      # IPv4 local connections:
      #host    all         all         127.0.0.1/32          md5
      host    all         all         127.0.0.1/32          password
      host    all         all         192.168.0.1/24          password            # 加上Cluster 機器 IP 範圍
      # IPv6 local connections:
      #host    all         all         ::1/128               md5
      host    all         all         ::1/128               password
  • hadoop@Cluster0X:~$ sudo /etc/init.d/postgresql-8.4 restart
  • hadoop@Cluster0X:~$ sudo su - postgres
  • postgres@Cluster0X:~$ createuser hadoop
    • Shall the new role be a superuser? (y/n) y
      postgres@Cluster01:~$ psql
      psql (8.4.2)
      Type "help" for help.

      postgres=# alter user hadoop with password '1234';
      ALTER ROLE
      postgres=# /q
  • 測試其他機器可否連線
    • hadoop@Cluster01:~$ createdb testdb
    • hadoop@Cluster02:~$ psql -h Cluster01 testdb
      • 如果能够连接上,则出现以下提示:
        • 口令:
          psql (8.4.2)
          SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256)
          Type "help" for help.

          testdb=#

3 设置HadoopDB

 

    首先从http://sourceforge.net/projects/hadoopdb/files/下载hadoopdb,解压后,其中包含hadoopdb.jar。

    然后再从http://jdbc.postgresql.org/download.html下载postgresql-8.4-701.jdbc4.jar。

 

  • hadoop@Cluster0X:~$ cp hadoopdb.jar HADOOP_HOME/lib/
  • hadoop@Cluster0X:~$ cp postgresql-8.4-701.jdbc4.jar HADOOP_HOME/lib/
  • hadoop@Cluster0X:~$ vim HADOOP_HOME/conf/core-site.xml
    • core-site.xml 文件中添加以下内容:
      <property>
      <name>hadoopdb.config.file</name>
      <value>HadoopDB.xml</value>
      <description>The name of the HadoopDB cluster configuration file</description>
      </property>

      <property>
      <name>hadoopdb.fetch.size</name>
      <value>1000</value>
      <description>The number of records fetched from JDBC ResultSet at once</description>
      </property>

      <property>
      <name>hadoopdb.config.replication</name>
      <value>false</value>
      <description>Tells HadoopDB Catalog whether replication is enabled.
      Replica locations need to be specified in the catalog.
      False causes replica information to be ignored.</description>
      </property>
      • hadoop@Cluster01:~$ vim nodes.txt
      • 将集群中的所有节点IP写入此文件:
        • 192.168.0.1
        • 192.168.0.2
      • hadoop@Cluster01:~$ vim  Catalog.properties
        • #Properties for Catalog Generation
          ##################################
          nodes_file=nodes.txt
          # Relations Name and Table Name are the same
          relations_unchunked=raw
          relations_chunked=poi
          catalog_file=HadoopDB.xml
          ##
          #DB Connection Parameters
          ##
          port=5432
          username=hadoop
          password=1234
          driver=org.postgresql.Driver
          url_prefix=jdbc/:postgresql/://
          ##
          #Chunking properties
          ##
          # the number of databases on a node
          chunks_per_node=2
          # for udb0 ,udb1 ( 2 nodes = 0 ~ 1 )
          unchunked_db_prefix=udb
          # for cdb0 ,cdb1, ... , cdb5 (2 nodes x 3 chunks = 0~5 )
          chunked_db_prefix=cdb
          ##
          #Replication Properties
          ##
          dump_script_prefix=/root/dump_
          replication_script_prefix=/root/load_replica_
          dump_file_u_prefix=/mnt/dump_udb
          dump_file_c_prefix=/mnt/dump_cdb
          ##
          #Cluster Connection
          ##
          ssh_key=id_rsa-gsg-keypair
      • hadoop@Cluster01:~$ java -cp lib/hadoopdb.jar edu.yale.cs.hadoopdb.catalog.SimpleCatalogGenerator Catalog.properties
        • 产生的 HadoopDB.xml 类似下面:
        • <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
          <DBClusterConfiguration xmlns="http://edu.yale.cs.db.hadoop/DBConfigurationSchema">
              <Nodes Password="1234" Username="hadoop" Driver="org.postgresql.Driver" Location="
          192.168.0.1 ">
                  <Relations id="raw">
                      <Partitions url="jdbc:postgresql://
          192.168.0.1 :5432/udb0" id="0"/>
                  </Relations>
                  <Relations id="poi">
                      <Partitions url="jdbc:postgresql://
          192.168.0.1 :5432/cdb0" id="0"/>
                      <Partitions url="jdbc:postgresql://
          192.168.0.1 :5432/cdb1" id="1"/>
                  </Relations>
              </Nodes>
              <Nodes Password="1234" Username="hadoop" Driver="org.postgresql.Driver" Location="
          192.168.0.2 ">
                  <Relations id="raw">
                      <Partitions url="jdbc:postgresql://
          192.168.0.2 :5432/udb1" id="1"/>
                  </Relations>
                  <Relations id="poi">
                      <Partitions url="jdbc:postgresql://
          192.168.0.2 :5432/cdb2" id="2"/>
                      <Partitions url="jdbc:postgresql://
          192.168.0.2 :5432/cdb3" id="3"/>
                  </Relations>
              </Nodes>
          </DBClusterConfiguration>
      • 将HadoopDB.xml放入HDFS中:
      • hadoop@Cluster01:~$ hadoop dfs -put HadoopDB.xml HadoopDB.xml

    4 数据加载

      • 在此以 raw 这个 talbe 当作例子进行讲解。根据前面HadoopDB.xml的内容,集群中的两个节点,第一个节点的数据库名称为udb0 ,第二个节点为udb1,首先分别创建这两个数据库:
        • hadoop@Cluster01:~$ createdb udb0
          hadoop@Cluster02:~$ createdb udb1
      • 在对应数据库上建立raw 这个table:
        • hadoop@Cluster01:~$ psql udb0
          udb0=# 
          CREATE TABLE raw (
          ID int,
          NAME varchar(300)
          );
        • 同理如 Cluster02
      • 先将本地文件系统中的数据put到HDFS中:
      • $ hadoop fs -put  localfile  input_in_hdfs/
      • 数据切割: 使用 HadoopDB 所提供的切割工具将数据切割成n份(一般,n是集群有节点数目),以下例子中:n=2,每一份数据的分割符是'/n':
      • $ hadoop jar lib/hadoopdb.jar edu.yale.cs.hadoopdb.dataloader.GlobalHasher input_in_hdfs out_in_hdfs 2 '/n' 0
      • 在各个节点上,将切割后的数据,从hdfs中传到各个节点的本地文件系统中:
      • $ hadoop fs -get out_in_hdfs/part-00000 /home/hadoop/p0
      • 将本地文件载入到数据库中:
      • hadoop@Cluster01:~$ psql udb0
        udb0=# COPY RAW FROM '/home/hadoop/p0' WITH DELIMITER E'/t' ;
      • 同理如 Cluster02

    5 SMS安装配置

     

        第3步下载的hadoopdb解压后包含SMS_dist.tar.gz文件夹。

        SMS的安装方法很简单:首先将其解压,然后打开bin目录下的hive-config.sh文件,再最后加上一句:

        export HADOOP_HOME="此处写hadoop的安装路径"。

      • 然后在hive上建立上面raw这个table对应的数据库:
      • 假設 Hive 使用的数据將儲存在 HDFS 的 /db
      • hadoop@Cluster01:~ $ hadoop dfs -mkdir /db
      • hadoop@Cluster01:~ $ SMS_dist/bin/hive
        CREATE EXTERNAL TABLE raw  (
        ID int,
        NAME string
        )
        ROW FORMAT DELIMITED
        FIELDS TERMINATED BY '|'
        STORED AS
        INPUTFORMAT 'edu.yale.cs.hadoopdb.sms.connector.SMSInputFormat'
        OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
        LOCATION '/db/raw';
      • /db/raw中的raw是指table的名称

    5  以上设定完后,即可在一台机器上(Ex: Cluster1) 執行 $ SMS_dist/bin/hive 看看成果

    • hadoop@Cluster01:~ $ SMS_dist/bin/hive
      hive> show tables;
      hive> select name from raw;

hadoopdb.pdf 附件是hadoopdb.pdf ,这个是hadoopdb的官方说明文档,也可从官网上进行下载 立即下载

相关推荐

HadoopDB-开源

HadoopDB是并行数据库和MapReduce技术的混合体。 它在性能和效率上接近并行数据库,但仍可提供MapReduce系统的可伸缩性,容错性和灵活性。

Hadoop集群的搭建和配置

hadoop运行环境的搭建、配置文件的修改、ssh免密登录、完全分布式的搭建、分发脚本xsync编写、集群的群起关的脚本...

BXMMJ的博客 1295

飞机大战完整版代码

基本都加注释 个人感觉还是不错的。

Hadoop与MongoDB的区别是什么?底层原理是什么?

在底层原理方面,Hadoop采用了分布式存储和计算的架构,数据被划分成多个块,并存储在不同的计算节点上。MongoDB的设计目的是为了处理半结构化和非结构化数据,并且具有高度的灵活性和可扩展性。Hadoop采用了分布式存储和计算的架构,将数据分成多个块,存储在不同的计算节点上,并通过MapReduce算法来处理和计算这些数据。Hadoop适用于需要处理大规模结构化和半结构化数据的场景,而MongoDB适用于需要快速读写非结构化数据和需要高度可扩展性的场景。

长风破浪会有时的博客 860

WEB下载控件(ReYoWebDownLoad)最新版

API说明 ReYoWebDL.copyright="锐洋软件拥有版权 http://www.interdrp.com/" //必须 ReYoWebDL.url="http://dl.baofeng.com/storm3/Storm2009-0504-1.exe" //下载文件的路径 ReYoWebDL.path ="" //保存文件地址 ReYoWebDL.ReYoStartDownload() //下载动作 ReYoWebDL.ReYoStopDownload() //停止下载 ReYoWebDL.size //下载文件大小 ReYoWebDL.bytes//已下载大小 ReYoWebDL.speed //下载速度 KB/S ReYoWebDL.done //下载是否完成 ReYoWebDL.cancle=true; //是否取消下载 ReYoWebDL.urlsource //下载文件名 ReYoWebDL.percent //下载百分比

C++面向对象程序设计课后答案

一、单项选择题 1.B 2. C 3. C 4. A 二、概念题 1.解答要点:面向过程程序设计采用结构化思想,将数据和对数据的操作分离,程序是由一个个的函数组成的;面向对象程序设计将数据和操作封装在一起,程序是由一个个对象组成的,对象之间通过接口进行通信,能够较好地支持程序代码的复用。 2.面向对象程序设计语言有四个特征: ⑴ 抽象性 ---- 许多实体的共性产生类。 ⑵ 封装性 ---- 类将数据和操作封装为用户自定义的抽象数据类型。 ⑶ 继承性 ---- 类能被复用,具有继承(派生)机制。 ⑷ 多态性 ---- 具有动态联编机制。 3.经过四个阶段:编辑、编译、连接、执行。

Hadoop3 - MapReduce DB 操作

对于本专栏的前面几篇文章的操作,基本都是读取本地或 HDFS 中的文件,如果有的数据是存在。不过如果要把数据库内容映射成对象实体,还需要该实体实现。数据库中,然后读取表信息作为数据集分析每个州的。案例进行试验,首先将文本类型的数据集导入。类,由于这里无需聚合分组操作,可以不做。已经写入成功,下面基于该表统计每个。方法用来指定获取数据库中的字段,现在和上面不同的是,输入和输出都是。方法用于指定写入数据库字段。负责把数据最终写入数据库中。的总数,并将计算结果写入。负责从数据库中读取数据,中的我们要怎么处理呢?

小毕超博客 1306

大专非科班拿下汇丰外包Java岗:我的TEKSystem面试全流程复盘(含IKM笔试真题)

本文详细记录了一位非科班大专生成功通过TEKSystem面试,拿下汇丰银行Java外包岗位的全过程。从IKM全英文笔试到技术面试,作者分享了7个关键转折点的实战经验,包括简历优化、技术考点、英语面试策略及薪酬谈判技巧,特别适合初级Java开发者参考。

weixin_30074763的博客 393

第十一章 大数据技术与实践

第十一章 大数据技术与实践 1、大数据概述 1)大数据定义 大数据一词由英文“big data”翻译而来,是最近几年兴起的概念,目前还没有一个统一的定义。相比于过去的“信息爆炸”的概念,它更强调数据量的“大”。大数据的“大”是相对而言的,是指所处理的数据规模巨大到无法通过目前主流数据库软件工具,在可以接受的时间内完成抓取、储存、管理和分析,并从中提取出人类可以理解的资讯。 2)大数据的4V特征 业...

chenhanl的博客 471

几率大的网络安全面试题(含答案)

其他篇章:Java校招极大几率出的面试题(含答案)----汇总 本文面试题汇总: 防范常见的 Web 攻击 重要协议分布层 arp协议的工作原理 rip协议是什么?rip的工作原理 什么是RARP?工作原理 OSPF协议?OSPF的工作原理 TCP与UDP区别总结 什么是三次握手四次挥手? tcp为什么要三次握手? dns是什么?dns的工作原理 一次完整的HTTP请求过程 Cookies和ses...

睶 6万+

ENVI 5.6保姆级教程:高分七号DLC影像从打开到融合的完整流程(附避坑指南)

本文详细介绍了ENVI 5.6处理高分七号DLC影像的完整流程,包括环境准备、数据解压、正射校正、图像融合等关键步骤。特别针对国产卫星数据处理的独特挑战,提供了实用的避坑指南和优化技巧,帮助用户高效完成光学影像的预处理和质量提升。

weixin_33269743的博客 382

HadoopDB安装使用

由於它是在 Hadoop-0.19.x 開發的,因此我還是用 Hadoop-0.19.2 來架設,至於架設部分可以參考這篇:[Linux] 安裝 Hadoop 0.20.1 Multi-Node Cluster @ Ubuntu 9.10,其中 0.19.2 與 0.20.1 安裝上只有些微的差別,在上述文章中的 hadoop-0.20.1/conf/core-site.xml 與 hadoo

zhang434的专栏 1079

国产数据库迁移必看:达梦到ES的CDC方案优化全记录(含完整代码)

本文详细记录了从达梦数据库到Elasticsearch的CDC方案优化全过程,涵盖触发器方案局限性、Debezium架构优势及完整代码实现。通过Flink集成和性能调优,实现毫秒级延迟同步,显著降低数据库负载,为国产数据库迁移提供可落地的技术方案。

weixin_29079671的博客 498

HadoopDB GlobalHasher的参数问题

hadoop jar hadoopdb.jar edu.yale.cs.hadoopdb.dataloader.GlobalHasher input_path output_path 10 \| 0上面的命令是将数据切分到10个分区内,即集群中的10个结点,最后的参数 0是指对每行记录的第一个字段进行hash,可将其视作键值。 下面是edu.yale.cs.hadoopdb.dataloa...

maozhuxigood 113

MATLAB实战:手把手教你实现Gardner环路位同步(附完整代码)

本文通过MATLAB实战,详细讲解了Gardner环路位同步算法的原理与实现。内容涵盖插值滤波器、定时误差检测、环路滤波器与数控振荡器等核心模块,并提供完整代码和调试技巧,帮助读者掌握数字通信中关键的符号定时同步技术。

weixin_29048775的博客 174

利用恒源云在云端租用GPU服务器训练YOLOv8模型(包括Linux系统命令讲解)

为当涉及到深度学习的训练任务时,GPU的计算能力是不可或缺的。相对于传统的中央处理器(CPU),图形处理器(GPU)具有更强大的并行计算能力,能够显著加速深度学习模型的训练过程。深度学习算法通常涉及大量的矩阵运算和张量操作,而GPU的并行计算架构使得它们能够高效地执行这些计算,从而加速模型训练的速度。恒源云是一个经济高效的云计算平台,您可以通过恒源云的控制台或者命令行界面来管理实例、上传和下载数据、执行训练任务等。

Snu77的博客 6724

常见结构化存储系统架构

什么是结构化存储系统 结构化数据一般指存储在数据库中,具有一定逻辑结构和物理结构的数据,最为常见的是存储在关系数据库中的数据;非结构化数据:一般指结构化数据以外的数据,这些数据不存储在数据库中,而是以各种类型的文本形式存放,其中Web上的一些数据(内嵌于HTML或XML标记中)又具有一定的逻辑结构和物理结构,被称为半结构数据。 目前比较成熟的结构化存储系统有Cassandra、Bigtable...

神技圈子的博客 1万+

ESD防护设计宝典(二十三):ESD与EOS失效差异分析

ESD和EOS是电子制造业面临的两大挑战,随着电子产品向更高集成度、更低工作电压和更高工作频率发展,这一问题将更加突出。根据美国军方上世纪八十年代与可靠性分析中心(RAC)共同建立的现场失效返回程序(FFRP)统计数据,产品现场返回中EOS占比高达46%,而ESD仅占6%,另有6%的案例难以区分是EOS还是ESD。

m0_56451176的博客 322

Hadoop伪集群搭建实践

环境:CentOS7 1G 前期准备: 1、4台机器(1master+3slave)虚拟机,为减少放开端口的操作,直接关闭防火墙 2、安装java环境,配置环境变量,此处使用JDK8 3、上传hadoop安装包,此处使用2.7.7版本,解压至/usr/local下 下面开始搭建过程: 1、修改/usr/local/hadoop-2.7.7/etc/hadoop下的hadoop-env...

frwcode的博客 216

⑤单细胞学习-cellchat组间通讯差异分析

参考:

hx2024的博客 1980

数学建模模型总结

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

hadoop 集群优化1

1. 概述 随着企业要处理的数据量越来越大,MapReduce思想越来越受到重视。Hadoop是MapReduce的一个开源实现,由于其良好的扩展性和容错性,已得到越来越广泛的应用。Hadoop作为一个基础数据处理平台,虽然其应用价值已得到大家认可,但仍存在很多问题,以下是主要

zhaoguoxian12345的专栏 1979

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

漫谈大数据

Hello各位old铁,我是酷酷的小张,今日份漫谈注意查收…… 一提到大数据就会想到他的背景、存储平台、以及计算模式和分析处理平台等等。但是相信还是有很多小伙伴会问到底什么是大数据又或者处理到多大才算大数据。如果你没有接触过大数据,那么你就不知道大数据究竟有多大,大到什么样的数据才能称之为大数据。那么,根据数据收集的端口,企业端与个人端之间,大数据的数量级别是不同的。 关于大数据的定义也是众说风云...

zPluto_CharonF的博客 490

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

android 蓝牙通讯demo

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

大数据

第十一章 大数据技术与实践 大数据定义 大数据一词由英文“big data”翻译而来,是最近几年兴起的概念,目前还没有一个统一的定义。相比于过去的“信息爆炸”的概念,它更强调数据量的“大”。大数据的”大“是相对而言的,是指所处理的数据规模巨大到无法通过目前主流数据库软件工具处理,在可以接受的时间内完成抓取、存储、管理和分析,并从中提取出人类可以理解的信息。”大“是与时俱进的,不能以具体的数据量来界...

weixin_45956703的博客 300

大数据技术与实践

大数据概述 定义:   大数据一词由英文“big data”翻译而来,是最近几年兴起的概念,目前还没有一个统一的定义。相比于过去的“信息爆炸”的概念,它更强调数据量的“大”。 大数据的4V特征   数据量大Volume、变化速度快Velocity、多类型Variety与高价值Value   1.Volume是大数据的首要特征,数据体量巨大。当今世界需要进行及时处理以提取有用信息的数据数量级已经从T...

weixin_45614071的博客 184
上一篇: Hadoop使用问题集锦
下一篇: Hbase学习笔记汇总
xiejava
博客等级 码龄19年 26粉丝 19原创
评论 6
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值