grafana+prometheus+black_box 实现端口检测

Grafana常用模板推荐(后续持续更新) Grafana常用模板 阅读详情

0.blackbox_exporte安装

下载地址

验证安装

进入目录  执行 ./blackbox_exporter --version

配置自启动脚本

vim /usr/lib/systemd/system/blackbox_exporter.service

[Unit]
Description=blackbox_exporter
After=network.target

[Service]
User=root
Type=simple
ExecStart=/mnt/data/ELK/black-box/blackbox_exporter/blackbox_exporter  --config.file=/mnt/data/ELK/black-box/blackbox_exporter/blackbox.yml
Restart=on-failure

[Install]
WantedBy=multi-user.target

启动black_box

systemctl enable blackbox_exporter.service
systemctl start blackbox_exporter.service
systemctl status blackbox_exporter.service

1.prometheus配置

vim /usr/local/prometheus/prometheus.yml

1.1 主机存活状态

- job_name: 'node_status'
    metrics_path: /probe
    params:
      module: [icmp]
    static_configs:
      - targets: ['192.168.13.42','192.168.13.28']
        labels:
          instance: 'node_status'
          group: 'node'
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - target_label: __address__
        replacement: '$1'

1.2 监控主机端口存活状态

- job_name: 'port_status'
    metrics_path: /probe
    params:
      module: [tcp_connect]
    static_configs:
      - targets: ['192.168.13.29:8844','192.168.13.32:8330']
        labels:
          instance: 'port_status'
          group: 'tcp'
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
        #      - source_labels: [__param_target]
        #        target_label: instance
      - target_label: __address__
        replacement: '$1'

1.3  监控网站状态

 - job_name: web_status
    metrics_path: /probe
    params:
      module: [http_2xx]
    static_configs:
      - targets: ['https://www.baidu.com']
        labels:
          instance: web_status
          group: web
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - target_label: __address__
        replacement: 127.0.0.1:9115

1.4 检查配置文件

#进入安装目录
./promtool check config prometheus.yml

#检查通过没有报错 可以刷新配置
curl -X POST http://127.0.0.1:9090/-/reload

#刷新配置的前提是 启动时 指定参数 --web.enable-lifecycle 配置告警需指定路径  --config.file=
nohup /mnt/data/ELK/prometheus/prometheus --web.enable-lifecycle --config.file=/mnt/data/ELK/prometheus/prometheus.yml >/dev/null 2>&1 &

#或使用systemctl 

1.5 完整配置示例

global:
  scrape_interval: 15s
  evaluation_interval: 15s
  external_labels:
    monitor: 'codelab-monitor'

scrape_configs:
  #监控主机
  - job_name: 'node_status'
    metrics_path: /probe
    params:
      module: [ icmp ]
    static_configs:
      - labels:
          group: 'node'
          instance: 'node_status'
        targets:
          - "192.168.13.42"
          - "192.168.13.28"
    relabel_configs:
      - source_labels: [ __address__ ]
        target_label: __param_target
      - source_labels: [ __param_target ]
        target_label: instance
      - target_label: __address__
        replacement: localhost:9115
  #监控端口 tcp
  - job_name: 'port_status'
    metrics_path: /probe
    params:
      module: [ tcp_connect ]
    static_configs:
      - labels:
          group: 'tcp'
          instance: 'gateway'
        targets:
          - "192.168.13.29:8844"
      - labels:
          group: 'tcp'
          instance: 'home-service'
        targets:
          - "192.168.13.32:8330"
      relabel_configs:
        - source_labels: [ __address__ ]
          target_label: __param_target
        - target_label: __address__
          replacement: localhost:9115
  #监控网站
  - job_name: 'web_status'
    metrics_path: /probe
    params:
      module: [ http_2xx ]
    static_configs:
      - labels:
          group: 'web'
          instance: 'web_status'
        targets:
          - "https://www.baidu.com"
    relabel_configs:
      - source_labels: [ __address__ ]
        target_label: __param_target
      - source_labels: [ __param_target ]
        target_label: instance
      - target_label: __address__
        replacement: localhost:9115
#配置告警
rule_files:
  - "/mnt/data/ELK/prometheus/my_rule.yml"

1.6 告警规则配置

groups:
- name: blackbox_network_stats
  rules:
  - alert: 'url服务探测失败'
    expr: probe_success == 0
    for: 60s
    labels:
      severity: high
      alertinfo: push_blackbox_alert
    annotations:
      summary: "{{ $labels.instance }}探测失败"
      description: "url探测失败,请检查业务是否正常!!!"

1.7 查看targets

访问 http://127.0.0.1:9090/targets 查看加入的监控信息。
 

2. 配置grafana

2.1 安装饼图插件

grafana-cli plugins install grafana-piechart-panel

service grafana-server restart

如果页面报错 方法找不到 可以尝试升级grafana版本为最新版

2.2 导入blackbox_exporter模板

数据源选择Prometheus

模板号为9965,模板下载地址 1 Blackbox Exporter Dashboard 2022/04/12 | Grafana Labs

配置成功后 如图所示

 以上

监控平台prometheus+grafana+snmp_explorer+blackbox_exporter+alertmanager 监控平台prometheus超实用教程 阅读详情

相关推荐

Prometheus 监控服务端口、网站状态等(黑盒监测)

1、blackbox_exporter介绍 blackbox_exporter是Prometheus 官方提供的 exporter 之一,可以提供 http、dns、tcp、icmp 的监控数据采集。 blackbox_exporter 应用场景: HTTP 测试: 定义 Request Header 信息,判断 Http status / Http Respones Header /Http Body 内容 TCP 测试:业务组件端口状态监听, 应用层协议定义与监听 ICMP 测试:主机探活机制 POS

qq_40907977的博客 1万+

Prometheus+Grafana(Kubernetes)企业级监控

本套课程由浅入深地对Prometheus进行了全方位的介绍,内容通俗易懂,理论与实践相结合。首先从监控体系讲起,介绍了关于监控的各种经典理论和方法。然后循序渐进地介绍了Prometheus的各个功能组件和配置方法,包括监控主机和容器、服务发现、警报管理,以及Kubernetes和运行其上的应用程序的监控。后面讲解了kube-prometheus的详细用法。主要讲解prometheus、alertmanager的以下几个方面: 1. Prometheus服务器部署及PromQL的查询及使用案例 2. Alertmanager的使用详解 3. 常见的日志告警,如邮件、钉钉、微信等 4. 在kubernetes中监控的手工部署、应用监控。 5. kube-prometheus在Kubernetes的应用,对k8s的各个组件的监控、告警、和对部署在k8s中应用的监控。注意:本课程学习需要具有一定的Linux基础,网络基础,至少需要您了解网络七层协议,路由等基础知识,并掌握Docker和k8s相关知识点。

【信息科学与工程学】计算机科学与自动化 第二百三十三篇 凤凰架构01

编号类型领域系统软件/硬件或系统集成方案及系统架构模块子模块函数名称/算法名称算法的数学分析及计算机体系架构及数据结构与算法详细设计及参数列表及数值范围设计关联知识1共识算法分布式基石状态机复制架构:Proposer/Acceptor/Learner 多节点角色模型,基于操作转移(Operation Transfer)分布式共识PaxosPaxos 协议(Prepare/Promise/Accept/Accepted 两阶段)数学基础:多数派(Quorum)投票,基于鸽巢原理保证 W+R>N 时读写集合必有

weixin_49199313的博客 269

prometheus监控(二)

为什么prometheus天然适合监控kubernetes 指标分析 容器基础资源指标 | kubelet 内置cadvisor metrics接口 | 查看容器cpu、mem利用率等 |k8s_sd node级别直接访问node_ip| k8s资源指标 通过coredns访问 k8s服务组件指标| 服务组件 metrics接口 | 查看apiserver 、scheduler、etc、coredns请求延迟等 | k8s_sd endpoint级别 部署在pod中业务埋点指标| pod 的metrics

m0_51445191的博客 2558

【信息科学与工程学】【数据中心】第三十五篇 云计算数据中心的学科知识04

编号学科(课程)核心知识点在云计算/云存储/云网络/云安全/云MaaS中的作用代表教材/资料/论文 + 数学方程式列表工业界应用D1421​云原生数据库:TiDB​HTAP(混合事务/分析处理)、分布式SQL、水平扩展、强一致(Raft)、自动故障恢复、与MySQL兼容、TiFlash列式引擎提供弹性扩展的分布式数据库;支撑高并发在线交易与实时分析教材:《TiDB in Action》PingCAP(2020) 论文:《TiDB: A Raft-based HTAP Database》(2017)

weixin_49199313的博客 419

【信息科学与工程学】【数据科学】数据科学领域 第六篇 算法设计 07 堆、栈、表、矩阵、集合、队列、数组、字符串、树、图、动态规划、结构体、元组的算法01

当前段必须包含所有字符的最后出现位置。1. 字符串分割成最多片段2. 基因序列功能域划分3. 文本段落划分4. 音频声道分离5. 图像色彩分区6. 社交网络社群划分7. 蛋白质结构域8. 音乐乐章分段9. 代码模块划分10. 章节划分特征:一次扫描,贪心确定边界。

weixin_49199313的博客 1281

【Prometheus】prometheus监控案例

【Prometheus】prometheus监控案例

qq_41466440的博客 3788

【信息科学与工程学】计算机科学与自动化 第二百零一十一 软件开发模型01

编号类型模型领域模型中的知识点/因素/参数关联知识和法律法规1传统顺序模型瀑布模型 (Waterfall)通用软件开发、硬件紧密耦合系统、政府/军工项目、需求稳定的传统信息系统严格线性阶段:可行性研究→需求分析(SRS,含功能/非功能/接口/约束,使用IEEE 830模板)→系统设计(概要设计HLD:架构、模块划分、数据库ER图;详细设计LLD:伪代码、类图、接口定义)→实现(编码规范、代码审查、静态分析工具SonarQube)→测试(单元测试JUnit、集成测试、系统测试、验收测试UAT,测试计划提前编写

weixin_49199313的博客 180

prometheus+node_exporter+grafana搭建

鉴于近期正好在研究监控方面的工具,所以有了这篇搭建随笔。鉴于是随笔,所以有些地方没有详细解释,后期会慢慢补上,这里仅写了如何搭建。 一.前期规划和准备 1.软件安装规划 介于个人虚拟机只有2台, 故安排: 172.16.16.80 安排上 全部的exporter+prometheus+grafana 172.16.16.74 安装单机redis 和nginx 2...

ZLC20050116的博客 354

【信息科学与工程学】计算机科学与自动化——第八十六篇 各类应用上云计算 01

数字孪生:核心是实时性不等式(Δ<Δt)与带宽-精度权衡。数学上归结为带约束的非线性优化。预测性维护:从物理退化方程(Paris 定律)出发,结合贝叶斯推断,云端训练用深度时序模型,边缘推理用轻量模型。机器人协同:本质是多商品流 + 动态障碍物,需用图论(冲突检测)+ 最优控制(轨迹平滑)。工业视觉:延迟由四个环节组成,需用排队论分析流水线瓶颈,量化感知是降低延迟的关键。液压/气动系统上云(涉及流体力学、热力学、控制)机械臂力控/阻抗控制上云(涉及动力学、力/位混合控制)

weixin_49199313的博客 206

COCO2017数据集类别分布深度解析

本文深入解析了COCO2017数据集的类别分布情况,包括80个常见物体的分类统计和样本数量分析。通过对比训练集与验证集的分布一致性,探讨了数据均衡性问题,并针对高频和低频类别提出了实用的数据预处理和模型训练建议,帮助优化计算机视觉任务的性能。

weixin_42533751的博客 370

prometheus监控对外服务

Blackbox Exporter 通过向指定的端口发送请求,并根据返回结果来确定服务是否健康。这种方式适用于你并不希望直接暴露应用内部的指标数据,而只是希望监控其外部可用性。组件,该组件能主要用于提供对外部服务的“黑盒监控”。注意:探测mysql时会导致mysql一直中断连接,导致mysql中断连接次数多,探测redis时,会一直探测失败,需要在。,如果不在安装目录启动需要指定配置文件目录。配置1:验证http返回码是否为2xx。配置2:验证服务端口是否可用。文件用于配置相关告警规则。

本博客为自己学习过程或工作过程的一些学习心得,在这里进行分享 971

Cursor Cloud Agent:云原生编程工作流的底层重构

编程工作流正从本地计算范式转向云原生执行范式。Cloud Agent 本质是将代码理解、生成、执行与调试等核心能力下沉至隔离、可控、按需分配的云端虚拟机,通过 Firecracker 微虚拟机实现亚秒级启动,并依托上下文快照、环境镜像化和内核级沙箱保障一致性、算力弹性与数据安全。这一范式突破了传统本地 AI 编程助手在环境依赖、调试能力与企业合规上的根本局限,使 IDE 从编辑工具升维为分布式开发指挥中心。本文深入解析其运行机制与工程落地实践。

weixin_34354173的博客 337

goalng开发_开发篇

Go 面试,基础知识

qq_46640341的博客 1162

基于PyTorch的BP神经网络PID控制器动态调参实战

本文详细介绍了基于PyTorch的BP神经网络PID控制器动态调参实战,结合BP神经网络的自适应能力和PID控制算法的经典优势,实现工业控制中的高效参数调整。通过PyTorch实现BP-PID融合架构,包括网络设计、损失函数优化及动态调参技巧,显著提升控制性能,适用于温度控制、电机控制等场景。

weixin_29094775的博客 523

GD32F450以太网(1):ETH 外设接口简介

GD32F450以太网ETH MAC外设接口简介

Zhichao_Zhang的博客 1万+

Prometheus监控TCP端口(blackbox-exporter)

prometheus判断probe_success的值(1正常,0异常)

weixin_49566876的博客 3086

【保姆级教程】基于UNet++&MobileNetv3的语义分割模型从训练到RK3588部署:让边缘AI落地效率提升300%

通过SMP库一键构建encoder_name="mobilenet_v2", # 选择MobileNetv3作为骨干encoder_weights="imagenet", # 加载预训练权重加速收敛in_channels=3, # 输入图像通道数(RGB)classes=29, # Cityscapes数据集类别数activation=None # 输出无激活,便于后续损失计算本教程从“模型设计-训练-转换-边缘部署”全链路拆解了。

FJN110的博客 258

Prometheus黑盒测试模块,监控TCP端口+ HTTP/HTTPS路由状态

996513659。

秦子腾 4448

AI 时代嵌入式工程师的能力模型与学习路线:全系列收官

AI 时代嵌入式工程师的能力模型与学习路线:全系列收官

weixin_42162924的博客 43

Win10或Win11电脑找不到以太网网络适配器的解决方法

Win10或Win11电脑找不到以太网网络适配器的解决方法

Robot_PLC_HMI_Automation 658

Prometheus监控使用

Prometheus入门到投产级教程

大鱼 6916

YOLOv11改进策略【独家融合改进】| 模型轻量化二次改进:StarNet + FreqFusion,极限降参,适用专栏内所有轻量化模型

FreqFusion是一种旨在解决密集图像预测任务中特征融合问题。

Limiiiing的博客 2127

prometheus学习4Grafana监控mysql&blackbox了解

仅自己学习笔记

weixin_60092693的博客 685

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

搭建 Prometheus 对服务进行监控

这里不做介绍,可以自行查阅或者去官网查询材料 (https://prometheus.io)。介绍几个相关的模块:1. prometheus:监控的主服务模块2. alertmanager:告警模块3. blackbox_exporter:监控类型模块(支持 http、tcp等类型,并可自定义监控)4. node_exporter:服务器资源监控模块,需要安装在被监控的服务器上,服务端口 9100。

清泉影月 2910

假人有限元模型

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

prometheus监控

1、部署安装cAdvisor cAdvisor是专门用于收集容器相关信息滴 1.1、启动容器 方式一、直接docker run docker run \ -v /:/rootfs:ro \ -v /var/run:/var/run/:rw \ -v /sys:/sys:ro \ -v /var/lib/docker:/var/lib/docker:ro \ -p 8080:8080 --detach=true --name=cadvisor \ --net=host google/cadvisor

qq_43297415的博客 1124

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

上一篇: Java线程池实现缓存功能
下一篇: 个人家装自用
codeLife1993
博客等级 码龄8年 23粉丝 60原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值