ORB (Oriented FAST and Rotated BRIEF)

ORB算法 ORB算法论文来自:ORB: an efficient alternative to SIFT or SURF                                    http://www.vision.cs.chubu.ac.jp/CV-R/pdf/Rublee_iccv2011.pdf        ORB算法用FAST算法进行角点检测,用BRIEF算法生成特征描述符。 阅读详情

ORB (Oriented FAST and Rotated BRIEF)

目标
   • 我们要学习 ORB 算法的基础
  
  对于一个 OpenCV 的狂热爱好者来说 ORB 最重要的一点就是:它来自“OpenCV_Labs’'。这个算法是在 2011 年提出的。在计算开支,匹配效率以及更主要的是专利问题方面 ORB 算法是是 SIFT 和 SURF 算法的一个很好的替代品。SIFT 和 SURF 算法是有专利保护的,如果你要使用它们,就可能要花钱。但是 ORB 不需要!!!
  ORB 基本是 FAST 关键点检测和 BRIEF 关键点描述器的结合体,并通过很多修改增强了性能。首先它使用 FAST 找到关键点,然后再使用 Harris角点检测对这些关键点进行排序找到其中的前 N 个点。它也使用金字塔从而产生尺度不变性特征。但是有一个问题,FAST 算法步计算方向。那旋转不变性怎样解决呢?作者进行了如下修改。
  它使用灰度矩的算法计算出角点的方向。以角点到角点所在(小块)区域质心的方向为向量的方向。为了进一步提高旋转不变性,要计算以角点为中心半径为 r 的圆形区域的矩,再根据矩计算除方向。
  对于描述符,ORB 使用的是 BRIEF 描述符。但是我们已经知道 BRIEF
对与旋转是不稳定的。所以我们在生成特征前,要把关键点领域的这个 patch的坐标轴旋转到关键点的方向。For any feature set of n binary tests at location (xi{{x}_{i}}xi​, yi{{y}_{i}}yi​), define a 2×n matrix, S which contains the coordinates of these pixels. Then using the orientation of patch,θ, its rotation matrix is found and rotates the S to get steered(rotated) version Sθ{{S}_{θ}}Sθ​.
  ORB discretize the angle to increments of2π/30(12 degrees), and construct a lookup table of precomputed BRIEF patterns. As long as the keypoint orientation \theta is consistent across views, the correct set of points Sθ{{S}_{θ}}Sθ​ will be used to compute its descriptor.
  BRIEF has an important property that each bit feature has a large variance and a mean near 0.5. But once it is oriented along keypoint direction, it loses this property and become more distributed. High variance makes a feature more discriminative, since it responds differentially to inputs. Another desirable property is to have the tests uncorrelated, since then each test will contribute to the result. To resolve all these, ORB runs a greedy search among all possible binary tests to find the ones that have both high variance and means close to 0.5, as well as being uncorrelated. The result is called rBRIEF.
  For descriptor matching, multi-probe LSH which improves on the traditional LSH, is used. The paper says ORB is much faster than SURF and SIFT and ORB descriptor works better than SURF. ORB is a good choice in low-power devices for panorama stitching etc.
  实验证明,BRIEF 算法的每一位的均值接近 0.5,并且方差很大。steered_BRIEF算法的每一位的均值比较分散(均值为 0.5,0.45,0.35… 等值的关键点数相当),这导致方差减小。数据的方差大的一个好处是:使得特征更容易分辨。为了对steered_BRIEF 算法使得特征的方差减小的弥补和减小数据间的相关性,用一个学习算法(learning method)选择二进制测试的一个子集。
  在描述符匹配中使用了对传统 LSH 改善后的多探针 LSH。文章中说 ORB算法比 SURF 和 SIFT 算法快的多,ORB 描述符也比 SURF 好很多。ORB是低功耗设备的最佳选择。
  
OpenCV 中的 ORB 算法
  和前面一样我们首先要使用函数 cv3.ORB() 或者 feature2d 通用接口创建一个 ORB 对象。它有几个可选参数。最有用的应该是 nfeature,默认值为 500,它表示了要保留特征的最大数目。scoreType 设置使用 Harris打分还是使用 FAST 打分对特征进行排序(默认是使用 Harris 打分)等。参数 WTA_K 决定了产生每个 oriented_BRIEF 描述符要使用的像素点的数目。默认值是 2,也就是一次选择两个点。在这种情况下进行匹配,要使用NORM_HAMMING 距离。如果 WTA_K 被设置成 3 或 4,那匹配距离就要设置为 NORM_HAMMING2。
  下面是一个使用 ORB 的简单代码。

# -*- coding: utf-8 -*-
"""
Created on Thu Jan 23 22:41:39 2014
@author: duan
"""
import numpy as np
import cv2
from matplotlib import pyplot as plt
img = cv2.imread('simple.jpg',0)
# Initiate STAR detector
orb = cv2.ORB()
# find the keypoints with ORB
kp = orb.detect(img,None)
# compute the descriptors with ORB
kp, des = orb.compute(img, kp)
# draw only keypoints location,not size and orientation
img2 = cv2.drawKeypoints(img,kp,color=(0,255,0), flags=0)
plt.imshow(img2),plt.show()

结果如下:
在这里插入图片描述
我们将在其他章节介绍 ORB 特征匹配。

opencv 进阶16-基于FAST特征和BRIEF描述符的ORB(图像匹配) 在计算机视觉领域,从图像中提取和匹配特征的能力对于对象识别、图像拼接和相机定位等任务至关重要。实现这一目标的一种流行方法是ORB(Oriented FAST and Rotated Brief)特征检测器和描述符。ORB 由 Ethan Rublee等人开发,结合了两种现有技术的优势——FAST(加速分段测试特征)和Brief(二进制鲁棒独立基本特征)——为特征提取和匹配提供了强大而高效的解决方案。 阅读详情

相关推荐

ORB - (Oriented Fast and Rotated BRIEF)算法

ORB - (Oriented Fast and Rotated BRIEF) ORB detector 使用 FAST detector 和 BRIEF descriptor 基本思路。在介绍 ORB 之前,首先对 FAST 与 BRIEF 进行说明。 1 FAST FAST(Featrues from Accelerated Segment Test),其基本思想是比较当前点与周边点差异,当周边有连续不少于一半的点均比中间点亮或者暗,则认为该点为一个特征点。其中,亮或暗的定义为: 使用以

微信号:Custom-Software 4916

ORB(Oriented FAST and Rotated BRIEF)

ORB(Oriented FAST and Rotated BRIEF)

gls_nuaa的博客 2232

opencv学习——ORB(Oriented FAST and Rotated BRIEF)

1、FAST FAST算子的基本原理是:若某像素点与其周围领域内足够多的连续的像素点存在某一属性差异,并且该差异大于指定阈值,则可以断定该像素点与其邻域像素有可被识别的不同之处,可以作为一个特征点(角点);对于灰度图像,FAST算子考察的属性是像素与其邻域的灰度差异。 这个检查过程可以用下图更清楚的描述:对于图像上所有像素点,考察其7*7邻域内以该点为圆心,半径是3的圆周上的共计16个像素点和中

ei1990的博客 2561

ORB特征

ORB(Oriented FAST and Rotated BRIEF)特征是一种常用的图像特征,其最大的优点是提取速度快,按业界的说法,ORB特征提取速度臂SURF快10倍,比SIFT快100倍。ORB特征由关键点和描述子两部分组成。他的关键点称为“Oriented FAST”,是一种改进的FAST角点。ORB提取速度快就得益于采用了FAST角点。它的描述子称为BRIEF(Binary Robust Independent Elementary Feature),是一种速度极快的二进制描述子。

qq_34493401的博客 6371

ORB算法介绍 Introduction to ORB (Oriented FAST and Rotated BRIEF)

Introduction to ORB (Oriented FAST and Rotated BRIEF) 1. Introduction ORB(Oriented FAST and Rotated BRIEF)是一种广泛应用于计算机视觉领域的特征描述算法。它结合了FAST角点检测算法和BRIEF描述子算法,以实现高效且具有旋转不变性的特征提取和匹配。 ORB算法的主要特点如下: 旋转不变性,...

越努力越幸运 246

[总结] orb(Oriented FAST and Rotated BRIEF) 2.代码

1. 引言 参考:【OpenCV学习笔记】之图像金字塔(Image Pyramid)_zhu_hongji的博客-CSDN博客_图像金字塔 1.1 图像金字塔(Image Pyramid) 尺度调整,可以用 resize 函数 图像金字塔是图像中 多尺度表达 的一种,是一种以 多分辨率来解释图像的结构。 2.ORB (Oriented FAST and Rotated BRIEF) 2.1 ORB由来介绍 ORB (Oriented FAST and Rotated BRIE...

心宝的博客 2438

python 亮度一致_ORB(Oriented FAST and Rotated BRIEF)简介及Python实现

Oriented FAST and Rotated BRIEF (ORB)由Ethan Rublee,Vincent Rabaud,Kurt Konolige和Gary R. Bradski于2011年在OpenCV实验室开发,是SIFT和SURF的有效可行的替代方案。ORB的构思主要是因为SIFT和SURF是专利算法。但是,ORB可以免费使用。论文链接:http://www.willowgara...

weixin_39760206的博客 556

【opencv-文档】 翻译ORB(Oriented FAST and Rotated BRIEF)

ORB--Oriented FAST and Rotated BRIEFOpencv官方文档中英翻译python simple Opencv官方文档 OpenCV-Python Tutorials>Feature Detection and Description https://docs.opencv.org/trunk/d1/d89/tutorial_py_orb.html 中英翻译 Theory 理论 As an OpenCV enthusiast, the most important th

jn10010537的博客 1392

【OpenCV-Python】教程:4-8 ORB (Oriented FAST and Rotated BRIEF)

BRIEF有一个重要的特性,即每个位特征的方差较大,均值接近0.5。为了解决所有这些问题,ORB在所有可能的二进制测试中运行贪婪搜索,以找到方差高且均值接近0.5且不相关的二进制测试。在ICCV2011的论文 “ORB: An efficient alternative to SIFT or SURF” 提出,是 SIFT 和 SURF 的替代,没有专利问题;计算局部角点为中心的Patch的亮度加权重心,方向就是角点到重心的连线。,找到它的旋转矩阵,并旋转。在视图中是一致的,正确的点。为patch的大小。

815

SIFT和SURF的替换算法——ORB (Oriented FAST and Rotated BRIEF 快速定向和旋转)

这篇博客将继续介绍特征检测的算法:FAST和BRIEF的融合版——ORB (Oriented FAST and Rotated BRIEF 快速定向和旋转) 。 ORB比SURF和SIFT快得多,ORB描述符比SURF工作得更好,是用于全景拼接等低功耗设备的理想选择。 在计算成本、匹配性能以及主要专利方面,它是SIFT和SURF的良好替代品。SIFT和SURF是专利算法,需要为它的使用付费。但ORB不需要。

qq_40985985的博客 1073

[总结] orb(Oriented Fast and rotated Brief) 1.详解

心宝的博客 440

OpenCV---特征检测算法(ORB,Oriented FAST and Rotated BRIEF)

ORB是一种高效的特征检测与描述算法,结合了FAST关键点检测和BRIEF描述符的优点,并改进了旋转和尺度不变性。通过图像金字塔实现尺度不变性,灰度质心法赋予方向特征,旋转BRIEF增强描述符鲁棒性。相比SIFT/SURF,ORB速度更快(适合实时应用)、无专利限制,虽然对噪声敏感度较高,但仍是计算机视觉任务的理想选择。OpenCV提供了ORB的完整实现,包括关键点检测、描述符计算和特征匹配功能。

MzKyle的博客 2855

实现 PDF 添加水印的五种方式

PDF(Portable Document Format,便携式文档格式)是一种流行的文件格式,它可以在多个操作系统和应用程序中进行查看和打印。在某些情况下,我们需要对 PDF 文件添加水印,以使其更具有辨识度或者保护其版权。本文将介绍如何使用 Spring Boot 来实现 PDF 添加水印的方式。

逸轩 6477

ORB(Oriented FAST and Rotated BRIEF) 特征点

ORB(Oriented FAST and Rotated BRIEF) 特征点 在Fast角点与brief描述子的基础上,拓展得到ORB特征点。 具有实时性好,提取效果也不错的优势,被广泛应用于需要实时处理处理任务的场景中。 特征提取 预备知识: FAST角点 Fast角点不具备尺度不变性,某些点在较小尺度下可能是角点而在大尺度下则变成了边缘,如图所示 因此ORB在提取特征点时进行了改进,利用单张图像金字塔进行多尺度特征提取,得到多尺度下的特征点。 特征描述 ORB特征点的描述子是在brief描述子基

木独的博客 2214

保姆级教程:在ESXi 8.0上为NVIDIA ConnectX-5/6网卡开启SR-IOV(从BIOS到虚拟机配置)

本文提供在ESXi 8.0上为NVIDIA ConnectX-5/6网卡开启SR-IOV的详细教程,涵盖BIOS设置、固件配置、驱动优化及虚拟机部署。通过SR-IOV技术,显著提升虚拟化环境中的网络性能,适用于高性能计算、AI训练等场景。

weixin_26934905的博客 462

碳化硅外延层厚度测量:红外干涉光谱与FFT技术详解

薄膜厚度测量是半导体制造中的关键工艺控制环节,其核心原理基于光的干涉现象。当光在薄膜上下界面反射并叠加时,会产生与厚度相关的干涉条纹。通过分析这些条纹,可以非接触、无损地获取薄膜的精确厚度信息。这项技术的核心价值在于实现了对关键工艺参数的在线、快速监控,对于提升器件性能与生产良率至关重要。在第三代半导体,尤其是碳化硅功率器件的制造中,外延层厚度直接决定了器件的击穿电压和导通电阻等核心性能。红外干涉光谱法因其对碳化硅材料在红外波段的良好透过性,成为该领域主流的厚度测量方案。通过快速傅里叶变换(FFT)对采集到

weixin_29032489的博客 310

ORB(Oriented FAST and Rotated BRIEF)特征提取算法原理详解和C++代码实现

int x, y;Level 0: 原始图像(尺度 1.0)Level 1: 缩小为 1/√2(尺度 ~0.707)Level 2: 缩小为 1/2(尺度 0.5)...Level N: 最小图像(尺度 ≈ 0.25)每一层都可以进行特征点检测,并将检测到的特征点坐标统一映射到原始图像坐标系中。ORB 是轻量、高效、旋转不变的特征提取方法。上述代码完全不依赖 OpenCV,可用于嵌入式或定制平台。可与 Hamming 距离 + 暴力搜索或 FLANN 结合完成特征匹配。

qq_36812406的博客 1750

STMicroelectronics 系列:STM32G4 系列_(11).STM32G4系列编程基础

通过本文,我们学习了如何在 STM32CubeIDE 中搭建开发环境,创建新项目,配置 GPIO、定时器和 ADC 外设,并编写相应的代码示例。这些基础知识将帮助你快速上手 STM32G4 系列的编程。希望本文对你有所帮助,祝你编程愉快!

2401_87715305的博客 1282

[cv] orb特征提取和描述(Oriented FAST and Rotated BRIEF)

参考:https://blog.csdn.net/qq_20791919/article/details/80176643?utm_medium=distribute.pc_relevant.none-task-blog-baidujs_baidulandingword-1&spm=1001.2101.3001.4242 1. ORB算法介绍 ORB(Oriented FAST and Rotated BRIEF)是一种快速特征点提取和描述的算法。 这个算法是由Ethan Rublee, Vince

心宝的博客 673

SAP ABAP CO核心扩展-ZCKMLQS 多物料工厂的评估数量结构报表(CKMLQS)

CKMLQS 只能查看单一物料工厂的评估数量结构,SAP 没有提供多物料工厂的评估数量结构报表。这篇文章将实现 CO核心扩展-ZCKMLQS 多物料工厂的评估数量结构报表。

SAP李斌,本人承诺所有原创文章均不使用任何AI生成技术,请大家放心阅读。 1096

26、使用WiFiServer和WiFiClient建立tcp 连接

在前面的篇章,我们使用过WiFiClient跟WiFiServer这两个类,也比较过WiFiClient跟ESP8266HTTPClient的区别,今天我们来通过例子代码学习WiFiClient跟WiFiServer怎样建立TCP连接并传输数据的。

繁星点点~ 1779

OpenCV-Python官方教程-26- ORB (Oriented FAST and Rotated BRIEF)

OpenCV中的ORB算法 我们必须创建一个ORB对象,通过函数 cv.ORB_create() 。或者使用 feature2d公共接口。它有多个可选参数。最有用的几个,是nFeatures,它表示要保留特征的最大数量(默认是500),scoreType 表示是在为特征点排序时,是要用哈里斯的方式来计分还是使用FAST算法来计分(默认是哈里斯的计分算法)等等。还有个参数,WTA_K 决定产生有方向的BRIEF描述符的每个元素点的数目。默认情况下是两个,因为两点决定一条线。这种情况下,使用汉明距离(译者注:N

Galen_xia的博客 642

【系统架构设计师】二十六、论文写作要点

论文写作概述:时间所需120分钟;题目可四选一,必有一题考察软件架构,总有一款适合你;考察形式是机试(开心,再也不用担心字丑了),约2500字。

帅次的博客 4602

5.8. ORB (Oriented FAST and Rotated BRIEF)

这个算法由Ethan Rublee,Vincent Rabaud,Kurt Konolige和Gary R. Bradski在他们的论文ORB中提出:2011年是SIFT或SURF的有效替代方案。为了解决所有这些问题,ORB在所有可能的二进制测试中运行一个贪婪的搜索,以找到具有高方差和意味着接近0.5的那些,以及不相关的。结果称为rBRIEF。为了改善旋转不变性,用x和y计算矩,该x和y应该在半径为r的圆形区域中,其中r是贴片的大小。处的n个二进制测试的任何特征集,定义2×n矩阵,其包含这些像素的坐标。

195

西安交通大学软件学院——分布式系统练习题(综合题)

摘要:本文探讨了分布式系统的核心特性与关键问题。首先阐述了分布式系统的8种透明性特性,包括访问、定位、迁移等。然后通过具体案例分析了分布式事务的回滚机制、域名解析的迭代与递归过程、不同分布式系统的异同比较。重点讨论了RPC通信中客户端/服务器崩溃的处理方法,包括消灭、再生和到期三种策略。最后介绍了Lamport时间戳算法在进程通信中的应用及问题解决方案。全文涵盖了分布式系统设计中的透明性、可靠性、一致性等核心问题。

qq_73044452的博客 206

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

图像处理检测方法 — ORB(Oriented FAST and Rotated BRIEF)

1、FAST  FAST算子的基本原理是:若某像素点与其周围领域内足够多的连续的像素点存在某一属性差异,并且该差异大于指定阈值,则可以断定该像素点与其邻域像素有可被识别的不同之处,可以作为一个特征点(角点);对于灰度图像,FAST算子考察的属性是像素与其邻域的灰度差异。   这个检查过程可以用下图更清楚的描述:对于图像上所有像素点,考察其7*7邻域内以该点为圆心,半径是3的圆周上的...

dbsggal90047018的博客 383

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

上一篇: BRIEF 算法的基础-BRIEF(Binary Robust Independent Elementary Features)
下一篇: 在图像间进行特征匹配
越努力越幸运@
博客等级 码龄8年 6961粉丝 126原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

越努力越幸运@

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值
⌂ 换网址