Debugging a Stack Overflow

别再只会重启了!用Keil的Fault Reports和Call Stack窗口,给你的HardFault做个‘CT扫描’ 本文深入解析Keil MDK中的Fault Reports和Call Stack窗口,帮助嵌入式开发者高效诊断HardFault问题。通过系统化的调试方法,快速定位内存越界、堆栈溢出等常见故障,提升单片机bug调试效率,告别盲目重启的无效操作。 阅读详情

A stack overflow is an error that user-mode threads can encounter. There are three possible causes for this error:

  • A thread uses the entire stack reserved for it. This is often caused by infinite recursion.
  • A thread cannot extend the stack because the page file is maxed out, and therefore no additional pages can be committed to extend the stack.
  • A thread cannot extend the stack because the system is within the brief period used to extend the page file.

 

Here is an example of how to debug this error. In this example, NTSD is running on the same computer as the target application and is redirecting its output to KD on the host computer. See Controlling the User-Mode Debugger from the Kernel Debugger for details.

The first step is see what event caused the debugger to break in:

0:002> .lastevent
Last event: Exception C00000FD, second chance

You can look up exception code 0xC00000FD in ntstatus.h, which can be found in the Microsoft Windows SDK and the Windows Driver Kit (WDK). This exception code is STATUS_STACK_OVERFLOW.

To double-check that the stack overflowed, you can use the k (Display Stack Backtrace) command:

0:002> k 
ChildEBP RetAddr
009fdd0c 71a32520 COMCTL32!_chkstk+0x25
009fde78 77cf8290 COMCTL32!ListView_WndProc+0x4c4
009fde98 77cfd634 USER32!_InternalCallWinProc+0x18
009fdf00 77cd55e9 USER32!UserCallWinProcCheckWow+0x17f
009fdf3c 77cd63b2 USER32!SendMessageWorker+0x4a3
009fdf5c 71a45b30 USER32!SendMessageW+0x44
009fdfec 71a45bb0 COMCTL32!CCSendNotify+0xc0e
009fdffc 71a1d688 COMCTL32!CICustomDrawNotify+0x2a
009fe074 71a1db30 COMCTL32!Header_Draw+0x63
009fe0d0 71a1f196 COMCTL32!Header_OnPaint+0x3f
009fe128 77cf8290 COMCTL32!Header_WndProc+0x4e2
009fe148 77cfd634 USER32!_InternalCallWinProc+0x18
009fe1b0 77cd4490 USER32!UserCallWinProcCheckWow+0x17f
009fe1d8 77cd46c8 USER32!DispatchClientMessage+0x31
009fe200 77f7bb3f USER32!__fnDWORD+0x22
009fe220 77cd445e ntdll!_KiUserCallbackDispatcher+0x13
009fe27c 77cfd634 USER32!DispatchMessageWorker+0x3bc
009fe2e4 009fe4a8 USER32!UserCallWinProcCheckWow+0x17f
00000000 00000000 0x9fe4a8

The target thread has broken into COMCTL32!_chkstk, which indicates a stack problem.

Now you should investigate the stack usage of the target process. The process has multiple threads, but the important one is the one that caused the overflow, so identify this thread first:

0:002> ~*k

   0  id: 570.574   Suspend: 1 Teb 7ffde000 Unfrozen
   .....

   1  id: 570.590   Suspend: 1 Teb 7ffdd000 Unfrozen
   .....

. 2  id: 570.598   Suspend: 1 Teb 7ffdc000 Unfrozen
ChildEBP RetAddr
009fdd0c 71a32520 COMCTL32!_chkstk+0x25  
.....

   3  id: 570.760   Suspend: 1 Teb 7ffdb000 Unfrozen

Now you need to investigate thread 2. The period at the left of this line indicates that this is the current thread.

The stack information is contained in the TEB (Thread Environment Block) at 0x7FFDC000. The easiest way to list it is using !teb. However, this requires you to have the proper symbols. For maximum versatility, assume you have no symbols:

0:002> dd 7ffdc000 L4
7ffdc000   009fdef0 00a00000 009fc000 00000000 

To interpret this, you need to look up the definition of the TEB data structure. If you had complete symbols, you could use dt TEB to do this. But in this case, you will need to look at the ntpsapi.h file in the Microsoft Windows SDK. For Windows XP and later versions of Windows, this file contains the following information:

typedef struct _TEB {
    NT_TIB NtTib;
    PVOID  EnvironmentPointer;
    CLIENT_ID ClientId;
    PVOID ActiveRpcHandle;
    PVOID ThreadLocalStoragePointer;
    PPEB ProcessEnvironmentBlock;
    ULONG LastErrorValue;
    .....
    PVOID DeallocationStack;
    .....
} TEB;

typedef struct _NT_TIB {
    struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
    PVOID StackBase;
    PVOID StackLimit;
    .....
} NT_TIB;

This indicates that the second and third DWORDs in the TEB structure point to the bottom and top of the stack, respectively. In this case, these addresses are 0x00A00000 and 0x009FC000. (The stack grows downward in memory.) You can calculate the stack size using the ? (Evaluate Expression) command:

0:002> ? a00000-9fc000
Evaluate expression: 16384 = 00004000

This shows that the stack size is 16 K. The maximum stack size is stored in the field DeallocationStack. After some calculation, you can determine that this field's offset is 0xE0C.

0:002> dd 7ffdc000+e0c L1 
7ffdce0c   009c0000 

0:002> ? a00000-9c0000 
Evaluate expression: 262144 = 00040000

This shows that the maximum stack size is 256 K, which means more than adequate stack space is left.

Furthermore, this process looks clean — it is not in an infinite recursion or exceeding its stack space by using excessively large stack-based data structures.

Now break into KD and look at the overall system memory usage with the !vm extension command:

0:002> .breakin 
Break instruction exception - code 80000003 (first chance)
ntoskrnl!_DbgBreakPointWithStatus+4:
80148f9c cc               int     3

kd> !vm 

*** Virtual Memory Usage ***
        Physical Memory:     16268   (   65072 Kb)
        Page File: /??/C:/pagefile.sys
           Current:    147456Kb Free Space:     65988Kb
           Minimum:     98304Kb Maximum:       196608Kb
        Available Pages:      2299   (    9196 Kb)
        ResAvail Pages:       4579   (   18316 Kb)
        Locked IO Pages:        93   (     372 Kb)
        Free System PTEs:    42754   (  171016 Kb)
        Free NP PTEs:         5402   (   21608 Kb)
        Free Special NP:       348   (    1392 Kb)
        Modified Pages:        757   (    3028 Kb)
        NonPagedPool Usage:    811   (    3244 Kb)
        NonPagedPool Max:     6252   (   25008 Kb)
        PagedPool 0 Usage:    1337   (    5348 Kb)
        PagedPool 1 Usage:     893   (    3572 Kb)
        PagedPool 2 Usage:     362   (    1448 Kb)
        PagedPool Usage:      2592   (   10368 Kb)
        PagedPool Maximum:   13312   (   53248 Kb)
        Shared Commit:        3928   (   15712 Kb)
        Special Pool:         1040   (    4160 Kb)
        Shared Process:       3641   (   14564 Kb)
        PagedPool Commit:     2592   (   10368 Kb)
        Driver Commit:         887   (    3548 Kb)
        Committed pages:     45882   (  183528 Kb)
        Commit limit:        50570   (  202280 Kb)

        Total Private:       33309   (  133236 Kb)
         .....

First, look at nonpaged and paged pool usage. Both are well within limits, so these are not the cause of the problem.

Next, look at the number of committed pages: 183528 out of 202280. This is very close to the limit. Although this display does not show this number to be at the limit, you should keep in mind that while you are performing user-mode debugging, other processes are running on the system. Each time an NTSD command is executed, these other processes are also allocating and freeing memory. That means you do not know exactly what the memory state was like at the time the stack overflow occurred. Given how close the committed page number is to the limit, it is reasonable to conclude that the page file was used up at some point and this caused the stack overflow.

This is not an uncommon occurrence, and the target application cannot really be faulted for this. If it happens frequently, you may want to consider raising the initial stack commitment for the failing application.

Analyzing a Single Function Call

It can also be useful to find out exactly how much stack space a certain function call is allocating.

To do this, disassemble the first few instructions and look for the instruction sub esp,number. This moves the stack pointer, effectively reserving number bytes for local data.

Here is an example:

0:002> k 
ChildEBP RetAddr
009fdd0c 71a32520 COMCTL32!_chkstk+0x25
009fde78 77cf8290 COMCTL32!ListView_WndProc+0x4c4
009fde98 77cfd634 USER32!_InternalCallWinProc+0x18
009fdf00 77cd55e9 USER32!UserCallWinProcCheckWow+0x17f
009fdf3c 77cd63b2 USER32!SendMessageWorker+0x4a3
009fdf5c 71a45b30 USER32!SendMessageW+0x44
009fdfec 71a45bb0 COMCTL32!CCSendNotify+0xc0e
009fdffc 71a1d688 COMCTL32!CICustomDrawNotify+0x2a
009fe074 71a1db30 COMCTL32!Header_Draw+0x63
009fe0d0 71a1f196 COMCTL32!Header_OnPaint+0x3f
009fe128 77cf8290 COMCTL32!Header_WndProc+0x4e2
009fe148 77cfd634 USER32!_InternalCallWinProc+0x18

0:002> u COMCTL32!Header_Draw
COMCTL32!Header_Draw:
71a1d625 55               push    ebp
71a1d626 8bec             mov     ebp,esp
71a1d628 83ec58           sub     esp,0x58
71a1d62b 53               push    ebx
71a1d62c 8b5d08           mov     ebx,[ebp+0x8]
71a1d62f 56               push    esi
71a1d630 57               push    edi
71a1d631 33f6             xor     esi,esi

This shows that Header_Draw allocated 0x58 bytes of stack space.

 
【pyinstaller】modulenotfounderror no module named ‘rasterio._shim‘、‘rasterio.control‘等 对于出现no module not found error的情况一般的解决办法就是使用hidden imports参数 当前对于这种问题的解决方法就是将所有缺少的模块用hidden imports给加进去,当然手动加有些麻烦, 故参考博文https://stackoverflow.com/questions/53149750/something-wrong-with-how-im-bundling-rasterio-into-an-executable给出的解决方法: # -*- mode: pyt 阅读详情

相关推荐

AttributeError: ‘Tensor‘ object has no attribute ‘lower‘

Debug进行时,错误代码如题所示。、 问题出使用GlobaleAveragePooling2D,我写成了GlobaleAveragePooling2D(net) net就是定义的、要进行最大均值池化的模型。 但这样是不行的,有两个解决办法: 1. 先定义GlobalAP=GlobaleAveragePooling2D() 然后再x=GlobalAP(net) 2.直接GlobaleAveragePooling2D()(net) ...

weixin_48253350的博客 3213

stack overflow常见解决方法

stack overflow一般都是堆栈内存不够 情况一:递归次数过多 解决办法:用循环来代替递归一般百分之九十能解决堆栈溢出的问题 情况二:创建的局部变量过多 解决办法:这种情况一般就是因为局部变量没有及时清除导致的,一般也是递归,要么把局部变量改成全局变量,要么传入引用(就是再数据类型的前面加以个&,这样不用去重新再子函数里面去开辟一个空间给变量了)要么用指针 情况三:数组开的过大 解...

萌新的博客 1万+

WinDbg Preview实战:手把手教你分析Windows 10崩溃dmp文件(附符号文件配置避坑指南)

本文详细介绍了如何使用WinDbg Preview分析Windows 10崩溃dmp文件,包括符号文件配置的优化技巧。从环境准备到实战演练,提供了一套完整的调试流程,帮助开发者快速定位和解决系统崩溃问题,特别强调了符号文件配置中的常见陷阱和解决方案。

weixin_30896511的博客 337

ESP32 出现A stack overflow in task httpd has been detected.错误

ESP32 stack overflow task httpd

liuguomark的专栏 6156

OpenGL 调试Debugging

OpenGL调试Debugging调试Debugging简介glGetError()调试输出GLFW中的调试输出过滤调试输出回溯调试错误源调试着色器输出OpenGL GLSL参考编译器帧缓冲输出外部调试软件gDebuggerRenderDocCodeXLNVIDIA Nsight 调试Debugging简介 图形编程可以带来很多的乐趣,然而如果什么东西渲染错误,或者甚至根本就没有渲染,它同样可以给你带来大量的沮丧感!由于我们大部分时间都在与像素打交道,当出现错误的时候寻找错误的源头可能会非常困难。调试(De

希望我的博客,能帮上你解决学习中工作中所遇到的问题 765

最新Docker GPU支持全解析:为什么nvidia-smi能用但PyTorch找不到CUDA?

本文深入解析了Docker容器中nvidia-smi命令可用但PyTorch无法调用CUDA的根本原因。关键在于默认配置仅暴露了GPU的utility管理能力,而CUDA计算所需的compute能力未被激活。通过正确设置NVIDIA_DRIVER_CAPABILITIES环境变量为compute,utility,并配合--gpus参数,即可解决此问题,确保AI训练等任务顺利进行。

convnet3designer的博客 242

偷换windows窗口过程

Window user32子动态库控件封装和消息分发浅析  这篇文章提到窗口程序在分发消息时会调用:UserCallWinProcCheckWow--->_InternalCallWinProc-->各个窗口程序的WndProc。各类控件的窗口程序不同,比如Button控件用的是Button_WndProc,_InternalCallWinProc { } 会通过。受到这篇文章的启示,

lixiangminghate的专栏 3252

抖音最新风控体系研究

小编从技术角度对抖音的风控史和落地目标,跟大家聊一聊抖音,包括海外版抖音TikTok的现状与生态。 1、非常非常早的时期,抖音刚出来的时候,没有任何封禁,这个阶段,导入一个开发库,加上一个请求头,咵咵咵的数据随便拿。 2、2018-2019年,抖音加入了设备id和xg机制,在绝大多数的接口中,携带了设备id参数,同时在请求头中加入了xg,如今的apk市场,能追溯到的最早xg是0200打头的,而小编见过的最早的xg是0000打头的。这个时期的接口,这些参数都还只是预设,没有实际的用处,设备随便写,

qq517348412的博客 1万+

dll反复加载卸载过程中遇见的诡异问题

这两天遇见了个诡异的问题,扩展进程反复的加载和卸载一个插件的dll的时候,扩展会在启动的时候崩溃。   通过windbg查看崩溃栈: 0:024> kbChildEBP RetAddr Args to Child WARNING: Frame IP not in any known module. Following frames may be wrong.02c6f7d4 ...

weixin_30725315的博客 902

LiveKit 本地部署实战:从零搭建安全实时通信环境(Caddy+HTTPS)

本文详细介绍了如何从零开始搭建LiveKit本地部署环境,结合Caddy服务器实现HTTPS安全通信。通过环境准备、证书生成、服务配置到前端客户端集成的完整流程,帮助开发者快速构建实时音视频应用,特别适合需要安全实时通信的场景。

weixin_29227585的博客 681

5G移动网络运维(优化)

5G 网络优化现状 移动通信行业属于技术密集型行业,是国民经济的重要支柱以及整个社会经济运转体系中不可或缺的基础。2019 年年底 5G 开始商用,截止到 2020 年3月,我国三大运营商建设了 16.1 万个 5G 基站,我国成为目前全球 5G 基站最多的国家。预计到 2020 年年底,我国运营商会建设大概 70 万个 5G 基站。基于 5G高频段的特性,信号覆盖距离会低于ins 基站,再加上 5G 万物互联的巨大经济潜力价值需求,后续三大运营商在 5G 基站建设数量上势必会超过当前 LTE 基站数量的

2301_78171382的博客 1327

07 | 函数调用:为什么会发生stack overflow?

这一节,我们讲了一个程序的函数间调用,在 CPU 指令层面是怎么执行的。其中一定需要你牢记的,就是程序栈这个新概念。我们可以方便地通过压栈和出栈操作,使得程序在不同的函数调用过程中进行转移。而函数内联和栈溢出,一个是我们常常可以选择的优化方案,另一个则是我们会常遇到的程序 Bug。通过加入了程序栈,我们相当于在指令跳转的过程种,加入了一个“记忆”的功能,能在跳转去运行新的指令之后,再回到跳出去的位置,能够实现更加丰富和灵活的指令执行流程。

qq_37756660的博客 2079

Ansys HFSS 中的同轴电缆仿真

准确模拟它们的行为对于确保 RF 系统的最佳性能至关重要。在本博客中,我们将介绍在 HFSS 中设置同轴电缆仿真并绘制插入损耗、回波损耗和电场分布的过程。将波端口分配给同轴线的两端以激励模型,并定义了从 1 GHz 到 20 GHz 的频率扫描以评估其宽带性能。铜分配给内部导体,铝分配给外部导体。介电区域使用 PTFE 定义,其相对介电常数为 2.1,损耗角正切为 0.00022。仿真完成后,结果用于绘制整个频率范围内的回波损耗和插入损耗。此外,电介质内的电场分布也被绘制和动画化。

jkh920184196的博客 1911

Debugging a Stack Overflow with Windbg

zz from windbg help doc Debugging a Stack Overflow A stack overflow is an error that user-mode threads can encounter. There are three possible causes for this error: A thread uses the e

fxismonk的专栏 770

端侧 AI 落地避坑指南(中):为什么 QAT 救不了精度?——对齐“融合后算子“的硬件物理约束

在上一篇文章中,我们深入探讨了量化的本质,并得出结论:QAT(量化感知训练)是保持精度的关键。明明做了 QAT,精度还是崩塌了!让我们看一个真实的案例:✅ 使用了✅ 配置了量化✅ 训练了 50 个 epoch,学习率降为原来的 1/10✅ 冻结了 BN 统计量FP32 模型:mAP = 0.85QAT 后 FP32:mAP = 0.84(正常)工具量化后:mAP = 0.68(崩塌!问题出在哪里?层融合(Layer Fusion)机制。

weixin_51988935的博客 56

【Win10/11】Windows电脑WiFi显示小地球/断网的解决方法 Windows WiFi小地球、网络连接中断、网络重置、无线网卡驱动、Win10/Win11网络修复

最近经常有粉丝留言问我,Windows 电脑突然连不上 WiFi,右下角网络图标显示成了“小地球 🌐”,或者干脆提示“未连接 - 没有可用的连接”。明明其他设备网络都正常,唯独自己的电脑断了。作为在互联网大厂混迹多年的前端程序员,我自己也碰到过这个问题。总结几种比较常见、亲测有效的解决方法,写出来供大家参考,希望能帮你快速恢复上网!问题原因推荐解决方法系统设置错乱使用网络重置功能驱动异常或冲突卸载后重启自动安装驱动驱动版本过旧手动更新网卡驱动实在不行考虑使用系统还原点或重装系统这几个方法中,

代码简单说 Vue、JAVA、PHP、Node.js 熟练运用,接口、架构、性能全搞定。 3852

xcode - iPhone Debugging: How to resolve 'failed to get the task for process'? - Stack Overflow

The program being debugged is not being run. Everyone sees this once in a while during Xcode development for iPhone apps. And there are a million reasons and hacks that make it go away. Here is...

aikun2355的博客 184

010、Zephyr RTOS开发环境搭建(Docker)

摘要 本文分享了使用Docker搭建Zephyr RTOS开发环境的实践经验。作者通过团队新人配置环境的真实案例,指出传统安装方式存在版本冲突、缓存污染等问题,而Docker方案能确保环境一致性。文章详细介绍了自定义Docker镜像的设计思路,重点解决工具链版本匹配、Python虚拟环境隔离等问题,将镜像体积从2GB优化到800MB。提供了从拉取镜像到点亮LED的完整工作流程,并总结了USB设备直通、文件权限、缓存问题等常见陷阱。还探讨了多阶段构建、CI集成等进阶用法,同时客观分析了Docker方案的局限性

m0_50546716的博客 81

xv6 stack overflow

学习目的:kernel stack overflow.

weixin_41028621的博客 697

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

C++ no debugging symbol found

C++ no debugging symbol found

上善若水 2836

深度学习工具包 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 realase debug 区别,xmpp - aSmack Android documentation and debugging - Stack Overflow

ASmack library refers to the documentation at http://www.igniterealtime.org/builds/smack/docs/latest/documentation/index.htmlwhich I think it is outdated and does not provide accurate info. Examples a...

weixin_34656273的博客 145

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

android生成coredump,debugging - Generate core dump in android - Stack Overflow

The ndk comes with ndk-gdb, which supposedly allows you to debug native applications. Also, if you download the whole andriod open source project, they also have some version of gdb used for debuggin...

weixin_32494599的博客 186

stack的wp

https://hackme.inndy.tw/scoreboard/ 题目很有趣,我做了stack这个题目感觉还不错,我把wp分享出来,方便大家学习 stack的题目要求是: nc hackme.inndy.tw 7716Here is my C programming homework But compiled with full protection (RELRO, PIE, NX, Sta

一个码农的笔记 2313

android studio break,debugging - Android Studio IDE: Break on Exception - Stack Overflow

To break on all exceptions in your code and other exceptions if uncaught:This methods filters out the exception types that the runtime throws during normal operation (not very exceptional, are they?)....

weixin_39951930的博客 164

An experience of fixing a memory-corruption bug (2)

(4) Asking for

一个手艺人的专栏 1087

AndroidStudio 疑难杂症 - app:dataBindingGenBaseClassesDebug Parameter ‘directory‘ is not a directory

在编译项目时,有时会有到一个奇葩错误。 Execution failed for task ':app:dataBindingGenBaseClassesDebug'. Parameter 'directory' is not a directory 尝试过 invalidata Cache/Restart 或者删除 .idea 文件夹,都不好使,一度有些想卸载 android studio。 最终 stackoverflow 上看到解决方法 通过命令方式执行gradle一次就好类,命令如下: ./gra

愛橙絮 6323
上一篇: 从内存中加载Pe文件
下一篇: 反向进程注入及隐藏--动手做一个最简单的PELoader
iiprogram
博客等级 码龄25年 1068粉丝 1515原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值