splunk 服务器 +windows&linux forwarder 安装

使用Splunk工具分析Windows日志和Apache日志 Splunk是一款更能强大的、记录详细的日志分析软件,能处理常见的日志格式,比如Apache、Squid、系统日志、邮件日志等,可对所有日志先进行索引然后可以交叉查询,支持复杂的查询语句,最后通过直观的方式表现出来。将搜索条件改为最初条件,如下,对于导入的日志数据,可以对其进行导出,单击“导出”,在弹出的对话框中可对导出结果进行命名,格式可以选择CSV、原始事件、XML或者JSON,搜索框内容为source=“C:\Users\Administrator\Desktop\access_log”。 阅读详情

系统准备

 

Su root

 

 

vi/etc/gdm/custom.conf


然后在[daemon]下面添加:

[daemon]
AutomaticLoginEnable=True
AutomaticLogin=root  #你想自动登录的用户名

 

 

 

安装部署

/opt  —— 建议/opt目录最好单独分区或者给/分区足够大

考虑:时间同步问题

内存:最好100G

 

安装配置

   软件下载:

      http://zh-hans.splunk.com/download

  1、安装

   # rpm -ivhsplunk-5.0.2-149561-linux-2.6-x86_64.rpm

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

Splunk has been installed in:

       /opt/splunk

 

To start Splunk, run thecommand:

/opt/splunk/bin/splunk start     #这一行命令要完整敲出来r

 

To use the Splunk Webinterface, point your browser to:

   http://localhost.localdomain:8000

 

Complete documentation is athttp://docs.splunk.com/Documentation/Splunk

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

  2、启动服务

  /opt/splunk/bin/splunk start   

     //首次启动会有许可协议,按q,再输入y。

 

  3、设置开机自启动

  /opt/splunk/bin/splunk enable boot-start

    #Init script installed at/etc/init.d/splunk.

    #Init script is configured to run atboot.

 

 

  4、查看帮助

    /opt/splunk/bin/splunk help enable

    可以使用/etc/init.d/splunk管理splunk的启停

 /etc/init.d/splunkstatus

 

  5、访问web页面

    firefox http://172.16.254.239:8000

      首次访问,会提示用户名密码admin/changeme

       登录后,设置新的密码

 

 

  6、修改默认端口的配置文件

      # vim/opt/splunk/etc/system/default/web.conf

       httpport = 8000

splunk日志的导入

  数据源可以是本地的、远程的、Linux的、Unix的、windows的、交换机的、路由器的等等。也可以是web服务器的,IIS服务器的、ftp服务器的等等。

 

7、停止当前服务器的防火墙,使得splunk 可以远程访问

systemctl stopfirewalld.service

 

启动: systemctl start firewalld

查看状态: systemctl status firewalld 

停止: systemctl disable firewalld

禁用: systemctl stop firewalld

在开机时禁用一个服务:systemctl disable firewalld.service

1、firewalld的基本使用

启动:systemctl start firewalld

查看状态:systemctl status firewalld 

停止:systemctl disable firewalld

禁用:systemctl stop firewalld

 

2.systemctl是CentOS7的服务管理工具中主要的工具,它融合之前service和chkconfig的功能于一体。

启动一个服务:systemctl startfirewalld.service
关闭一个服务:systemctl stopfirewalld.service
重启一个服务:systemctl restartfirewalld.service
显示一个服务的状态:systemctl statusfirewalld.service
在开机时启用一个服务:systemctl enablefirewalld.service
在开机时禁用一个服务:systemctl disablefirewalld.service
查看服务是否开机启动:systemctl is-enabled firewalld.service
查看已启动的服务列表:systemctl list-unit-files|grepenabled
查看启动失败的服务列表:systemctl --failed

3.配置firewalld-cmd

查看版本:firewall-cmd --version

查看帮助:firewall-cmd --help

显示状态:firewall-cmd --state

查看所有打开的端口:firewall-cmd --zone=public --list-ports

更新防火墙规则: firewall-cmd --reload

查看区域信息: firewall-cmd --get-active-zones

查看指定接口所属区域:firewall-cmd --get-zone-of-interface=eth0

拒绝所有包:firewall-cmd--panic-on

取消拒绝状态:firewall-cmd --panic-off

查看是否拒绝:firewall-cmd --query-panic

 

那怎么开启一个端口呢

添加

firewall-cmd --zone=public --add-port=80/tcp --permanent    (--permanent永久生效,没有此参数重启后失效)

重新载入

firewall-cmd --reload

查看

firewall-cmd --zone= public --query-port=80/tcp

删除

firewall-cmd --zone= public --remove-port=80/tcp --permanent

 

数据导入

 

一、向splunk中导入本地日志  messages

    添加数据——>syslog——>使用此 Splunk 服务器上的任何 syslog 文件或目录——>服务器上文件的路径 /var/log/messages ——>默认——>默认 继续——>默认,保存

 

二、搜索想要的日志

    开始搜索——>输入aborting

    搜其他host="localhost"

 

练习:将secure日志导入到splunk中,并验证其搜索功能

    

 

三、向splunk导入远程日志

  环境:

      splunkserver :172.16.254.239

      remoteapache:172.16.254.200 web.up.com

  开始配置:

    注意:导入远程日志需要远程主机安装通用转发器(splunkforwarder)。

    1、设置splunk服务器允许接收splunk转发器发送来的数据

    管理器——>转发和接收——>配置接收中“新增”——>9999(指定接收数据的端口)——> 保存

    2、在远程服务器上配置

    1)安装splunkforwarder包

       # rpm -ivh splunkforwarder-5.0.2-149561-linux-2.6-x86_64.rpm

    2)配置splunkforwarder转发apache的日志

       # /opt/splunkforwarder/bin/splunk start

       # /opt/splunkforwarder/bin/splunk add forward-server172.16.254.239:9999

        Splunk username: admin

        Password: changeme

        Added forwarding to: 172.16.254.239:9999.

       # cd /opt/splunkforwarder/etc/system/local/

       # vim inputs.conf

        [default]

        host = web.up.com

        [monitor:///var/log/httpd]

        sourcetype = access_common

    3)重启splunk转发器服务

       # /opt/splunkforwarder/bin/splunk restart

    3、验证结果

    如果在splunk服务器的web页面能够看到web.up.com的apache的日志,就成功了。

    简单搜索:

        host="web.up.com"

        host="web.up.com" error

        host="web.up.com"  OR error   //OR 或者

    

生成视图

导入测试数据

将Sampledata.zip放到splunk服务器上

 

继续浏览器操作

   管理器——>数据导入——>文件和目录“新增”——>跳过预览——>上载并索引文件 ——>保存

 

一、体验splunk强大的搜索功能

  sourcetype="access_combined_wcookie"

1、搜索源类型为access_combined_wcookie,并且IP为10.2.1.44的日志请求

        ——81条

  sourcetype="access_combined_wcookie" 10.2.1.44

2、进一步搜索关于“purchase”的请求—— 63条

  sourcetype="access_combined_wcookie" 10.2.1.44 purchase

3、进一步搜索http返回码不是200的购买请求

  sourcetype="access_combined_wcookie" 10.2.1.44 purchase NOT 200

4、进一步搜索不是404错误的请求

  sourcetype="access_combined_wcookie" 10.2.1.44 purchase NOT 200NOT 404

 

用关键字搜索

    搜索买花时间

     sourcetype="access_combined_wcookie" 10.2.1.44action=purchase category_id=flowers

   

|:前面的搜索结果作为后面的命令的输入

   1、搜索最热卖的商品  使用命令top

    sourcetype="access_combined_wcookie" action=purchase | topcategory_id

   2、有多少名不同的顾客买了鲜花

     需要使用stats命令和dc函数实现

    sourcetype="access_combined_wcookie" action=purchasecategory_id=flowers | stats dc(clientip)

   3、每个顾客分别买了多少花?

    sourcetype="access_combined_wcookie" action=purchasecategory_id=flowers | stats count by clientip

      需要使用stats命令和count函数并且使用by子句

   4、倒序显示每个顾客购买多少花?

     sourcetype="access_combined_wcookie"action=purchase category_id=flowers | stats count by clientip | sort -count

     sort-count:按照count字段倒序排序

     sortcount:按照正序排序

   5、给数据列起别名

    sourcetype="access_combined_wcookie" action=purchasecategory_id=flowers | stats count by clientip | sort count | rename clientip as"顾客", count as "购花总数"

   

二、将搜索结果保存为仪表盘

    1、创建一个空的仪表盘

    仪表板和视图——>创建仪表板——>ID:001 名称:每个顾客购花总数 ——> 创建

    2、将搜索结果保存到仪表盘

     sourcetype="access_combined_wcookie" action=purchase category_id=flowers| stats count by clientip | sort -count | rename clientip as "顾客" , count as"购花总数"

      搜索——>创建——>仪表板面板——>每个顾客购花总数——>现有仪表板——>下拉列表中选择需要的仪表板——> 默认

 

三、在收集结果时动态更新生成的图表

    创建报表

     搜索:sourcetype="access_combined_wcookie"action=purchase category_id=flowers | stats count by clientip | sort -count

     创建——>报表

 

 

 

日志转发器安装

 

 

 

Splunk日志服务器windows客户端安装

下载客户端http://www.splunk.com/download/universalforwarder

 

 

 

你懂的。

Splunk服务器地址和端口,必须写。

 

 

 

 

可以先不填,直接next。

直接下一步。

 

 

 

 

选择要上传的数据类型。这个只需要logs即可,右边那些是snmp干的活。

点击安装。

 

 

 

 

完成。

运行——cmd——回车不懂撞墙去。

 

cd {splunk安装目录}/bin/

        splunk.exe add forward-server 192.168.180.200:9997
用户名 admin  
密码 changeme
注:9997端口需要在splunk服务器上先设置好。
具体配置如下图:
重启splunk服务
 
检查设置splunk forwarder设置
 
Splunk.exe list forward-server
客户端计算机名称
使用查询功能。

 

搞定!!

 

 

Linux forward安装

 

1)、将通用转发器解压到opt目录下,Splunk转发器的安装方法和splunk一致,但它无UI界面。

tar zxvfsplunkforwarder-************-Linux-x86_64.tgz -C /opt

2)、切换到Splunkforwarder的bin目录下去启动通用转发器

cd/opt/splunkforwarder/bin/   #//切换到通用转发器的可执行程序目录

./splunkstart –accept-license    #//启动通用转发器一次启动有很长的 协议 使用回车键转到最后按”y” 同意在回车。

 

注意:如果splunk web和通用转发器安装在同一 服务器,通用转发器的管理端口也是8090,则会提示被splunk占用

 

3配置转发器需要转发的服务器ip和端口

./splunk addforward-server 192.168.180.200:9997

用户名 admin  

密码 changeme

注:9997端口需要在splunk服务器上先设置好监听端口。

 

4.设置开机自启动

/opt/splunkforwarder/bin/splunkenable boot-start

 

5.检查设置splunk forwarder设置

 

./Splunklist forward-server

splunk 日志分析系统搭建,部署,配置 本人对splunk了解不多,只限于使用及简单部署配置。搭建splunk之前需要先下载软件。 下载方式: 官网下载 官方下载地址 如果你是第一次访问 Splunk 网站,需要先注册一个 Splunk 用户,默认下载的是 60 天 Enterprise 试用版, 60 天试用之后将自动转化为 Free 版,转化位 Free 版后每日处理的日志量最高位 500M 。 链接下载 splunkserver软件包 splunkforwarder软件包 splunkserver搭建 1.上传软件压缩包到服务器 阅读详情

相关推荐

解决 Splunk windows数据接入奇葩问题

Splunk 对app 下面的inputs.conf 文件到 监控路径有严格的要求。

shenghuiping2001的专栏 1237

Linux(Ubuntu/CentOS)安装splunkforwarder步骤

Linux(Ubuntu/CentOS)安装splunkforwarder步骤: splunkforwarder是splunk的客户端log转发工具: 下载网址(下载tar包):https://www.splunk.com/en_us/download/universal-forwarder.html splunk服务器端要开启接收端口(设置——转发和接收——配置接收——新增——9997) 客户端...

weixin_34183910的博客 1333

splunkforwarder - 8.0.5 - linux.zip

Splunk通用转发器安装文件,版本:8.0.5,适用于Linux。 转发器可以从远程来源快速、安全地收集数据,从各种来源(包括其他转发器)收集数据,并将其发送到Splunk部署。使用通用转发器将数据无缝发送到Splunk Enterprise、Splunk Cloud或Splunk Light。

【安装uf bug】splunk9.1.2universal forwarder安装bug

其实splunk官网也是有关于转发器和平台适配的速查表,可以对照下。一般情况,同版本的uf和平台enterprise是兼容的。后面排查了下,是因为新版的uf缺少glibc库。后面我重新装了我的老版本splunk 8.2.1版本的时候,未发现报错。

weixin_43175581的博客 640

splunk forwarder 操作手册

Splunk forwarder 所以操作手册,包括介绍,安装,卸载,更新等

splunk最新版windows安装包,splunk-8.2.3.2-5281ae34c90c-x64-release.msi

splunk最新版windows安装包,下载后,一直点击下一步即可安装成功!

Ubuntu22.04安装老版本splunkforwarder转发器

ubuntu系统22.04安装splunkforwarder6.1.2

pazzn的博客 749

xilinx zynq-7000 linux下rs422串口通信测试步骤

这几天使用xilinx的zynq-7000系列调试rs422串口,期间遇到不少问题,好在最终调试完成,在这里记录一下调试步骤。 我用的soc型号是xc7z100,板载了2个rs422外设,PS端有2个uart控制器,uart0用于连接rs232并作为console控制台输出,uart1连接rs422。 rs422和主板连线原理图如下: 其中422_TXD1_3V3 和422_RXD1_3V3 为数据发送和接收引脚,422_TXD_DE1_3V3为发送使能引脚,422_RXD_REn1_...

dongyunke的博客 5907

Splunk 接入 Windows的DNS日志

windows 的dns日志目前在 wins 08之前的版本接入会出错,我自己实际部署过 wins2012是成功的 建议使用最新的 micorsoft add-on (当前版本8.0以上)去接入dhcp,下载地址https://splunkbase.splunk.com/app/742/ 。 然后将此包解压放到windows服务器上。 先在windows服务器安装 splunk forwarder。安装过程如下 输入用户名密码,这个不重要。然后deployment server这里不填 index.

qq_42938493的博客 1304

MIPI信号的分析--结合示波器实际测试波形

如果排查的思路对你有帮助,请记住 消雨匆匆 or 大吊工。码字和排查很累,仅此而已 ,硬件不是抄电路,拿烙铁,懂点软件,细致分析,找问题和破案搜集线索是一样的。 部分内容来自于此博客的大神总结: http://www.elecfans.com/news/wangluo/20170323499614.html http://www.elecfans.com/yuanqijian/jieko...

消雨匆匆 4万+

给大一新生的蓝桥杯EDA备赛规划:从电路分析到立创EDA,如何用一年时间高效备赛?

本文为大一新生提供了一份系统的蓝桥杯EDA备赛规划,从电路分析基础到立创EDA实战操作,分阶段指导如何高效备赛。内容涵盖理论学习、软件操作、PCB设计专项提升及冲刺优化策略,帮助学生在一年内全面提升电子设计能力,为竞赛做好充分准备。

weixin_31476015的博客 287

安全运维 -- splunk 操作手册

日常运维操作笔记 (持续更新)

leeezp的博客 4万+

在Ubuntu上通过Wine完美运行企业微信的详细指南

本文提供了在Ubuntu系统上通过Wine兼容层安装和运行企业微信的详细教程。针对官方未提供Linux版本的痛点,指南推荐使用Ubuntu Kylin团队优化打包的Wine环境,通过简单的命令行步骤即可完成部署,并涵盖启动、中文输入法配置、文件管理等常见问题的解决方案,帮助用户实现高效、稳定的办公沟通。

weixin_29306317的博客 232

@Splunk转发器部署(windows | linux)

文章目录1.Spunk概述2.Splunk获取3.Splunk转发器安装windows1)手动配置Splunk转发器2)splunk server配置添加4.Splunk转发器安装linux(center os)1)linux安装2)splunk转发器主要配置3)splunk配置5.splunk安装部署 1.Spunk概述 1)Splunk分为服务器(Splunk)和客户端(Splunkforwarder)。 Splunk的服务器就是索引器和接收器。客户端就是数据的转发器。顾名思义就是数据可由客户端转发

欢迎光临本栈——“码栈仙”,一个架构师的脑洞收容所。 这里不生产代码,只做bug的搬运工。 3300

【Benchmark 性能测试全指南:从核心原理到 CINEBENCH 实战解析】

本文深度拆解基准测试(Benchmark)的底层逻辑,详解数据集、工作负载、度量指标三大核心要素,分步演示测试流程与统计分析要点。结合 CINEBENCH R23 实战案例,揭秘 CPU 性能评估方法论,助你掌握系统性能量化与优化的核心技能。

rong_ha_ha的博客 6327

SAP CRP能力计划详细说明操作及相关配置

2、求助朋友同事的希望破灭后,网上找了资料发现在百度搜索的资料基本都是没有说明白什么才产能计划,都没有详细的操作说明,然后用google去搜索了一些相关的文章,好像也没有详细的文章。然后也去SAP的官网搜索了相关的文章,都是文字性的表述,对系统的配置都没有很大的帮助,很久之前有记得在隐身人的博客中有提到CRP的能力计划的文章,然后试着去找了一下相关的文章。5、首先产能排产肯定涉及的就是是能力的问题,能力第一个能想到的就是工作中心中的能力页签,在流程制造中也叫资源,其实都是一个东西。

我小时候很黑的博客 4518

日志管理工具 ——Splunk

Splunk日志管理平台实用指南 Splunk是一款功能强大的日志管理和数据分析平台,能够处理各种结构化和非结构化数据。核心功能包括数据收集、索引、搜索分析和可视化展示,支持IT运维监控、安全事件管理、业务分析等场景。 安装部署方面,Splunk支持Linux/Windows系统,提供企业版和轻量级转发器版本。

ececec12的博客 2271

“华为杯”研究生数学建模竞赛2019年-【华为杯】D题:汽车行驶工况构建(附获奖论文和MATLAB代码实现)

映了汽车道路行驶的运动学特征。准差、加速度标准差这九个特征参数用于后续的数据分析,建立了合理的汽车运动特征评。特征参数与所属类特征参数的特征值的相关性大小替代误差进行排序的,计算得到汽车行。对于问题一,我们首先对原始数据进行了时间变量转换,将原本的年月日时分秒的计。紧接着进行了运动学片段的划分,引入九个特征参数,通过主成分分析、本文研究的是汽车行驶工况构建,汽车行驶工况是描述汽车行驶的速度。的合理性评价标准,对两种方法都进行了合理性评价,得到的。进行了合理性评价,得到了最优的汽车行驶工况曲线。

getusushu的博客 1000

网络安全人士必会的Splunk Enterprise安装方法

Splunk Enterprise(企业版)免费版本:试用期60天,60 天后,可以转为可永久使用的免费许可证,每日许可量500MB,支持Windows、Linux、Mac OS。登录splunk官网(https://www.splunk.com/zh_cn),在官网注册账号信息,需要使用公司邮箱进行注册,注册完成之后,进行下载。除了支持来自Splunk通用转发器的数据,还支持上传本地日志等数据或上传Splunk平台实例上的文件和端口数据。● 登录Splunk Enterprise,查看“转发器管理”

Python_paipai的博客 3199

基于深度学习的番茄成熟度检测系统——YOLOv5、YOLOv8、YOLOv10及UI界面的实现

YOLO是一种快速且准确的目标检测模型,近年来,YOLOv5、YOLOv8和YOLOv10作为YOLO系列的重要版本,分别在速度、精度和效率上进行了优化。下面我们简要介绍这些模型。本文介绍了如何基于YOLOv5、YOLOv8和YOLOv10等深度学习模型,结合PyQt5设计一个番茄成熟度检测系统。通过训练模型、优化算法和设计用户友好的界面,我们能够构建一个高效且准确的番茄成熟度检测系统,广泛应用于农业自动化和智能化管理中。

YOLO 1002

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

Windows系统本地部署Splunk Enterprise数据管理平台并实现远程访问【内网穿透】

本文主要介绍如何简单几步,结合cpolar内网穿透工具实现随时随地在任意浏览器,远程访问在本地Windows系统部署的Splunk Enterprise 数据管理平台,提高工作效率。

内网渗透的博客 1492

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

Splunk组件和架构详解

本人主要讲解的是Splunk组件和架构!Splunk主要解决的问题splunk提供了统一管理分布在不同机器上的数据(比如日志数据)的服务。如下图所示: Splunk是一个功能完备的企业级产品,提供了命令行窗口,web图形界面接口和其他接口,查询结果展示,数据查询,权限控制,分布式管理服务,数据索引,网络端口监听,数据警报,文件监听等等。ForwarderSplunk提供了Forwarder组件,它

ChainingBlocks 1万+

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

window环境下启动splunk问题

1.windows环境下启动splunk要确保关闭防火墙。 2.如果关闭防火墙也启动不起来,那就要: 打开设置--服务--启动splunkservice服务--   3.启动完成后,显示正在运行: 4.再到浏览器运行即可:        ...

liangkaiping0525的博客 2077

Splunk转发器安装

在Linux操作系统上搭建一个Splunk日志文件管理工具转发器并运行它。

需要远程指导仿真实验、代码有问题的,请后台私信或者关注公众号 1145

Splunk日志服务器windows客户端安装

Splunk日志服务器windows客户端安装下载客户端http://www.splunk.com/download/universalforwarder你懂的。Splunk服务器地址和端口,必须写。可以先不填,直接next。直接下一步。选择要上传的数据类型。这个只需要logs即可,右边那些是snmp干的活。点击安装。完成。运行——cmd——回车不懂撞墙去。cd {splun...

weixin_34336292的博客 741

Splunk Forward简单部署_Win

1、关闭所有机器的防火墙(主要是在Win7Splunk Server开防火墙) 2、在192.168.1.236上安装Splunk 3、在192.168.1.237上安装SplunkForward Deployment Server:192.168.1.236:8089 Receiving Indexer:192.168.1.236:9997 Pa...

weixin_33953384的博客 481
上一篇: python 文本去重 排序
下一篇: 自动化运维,安装提权工具
yeah_go
博客等级 码龄19年 4粉丝 6原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值