Process Initiation

SSDSim源码分析-流程分析 首先分析这个源码,我们可以先从入口函数进行入手,首先我们来到ssd.c这个文件里面,来到它的main函数里面,首先我们先看这个比较重要的函数,initiation函数。 void main() { unsigned int i,j,k; struct ssd_info *ssd; #ifdef DEBUG printf("enter main\n"); #endif ssd=(struct ssd_info*)malloc(sizeof(struct ssd_info)); allo 阅读详情

Overview

Taking a simple C program, we look at its initiation using NTSD. There are four segments to the program's life cycle:
  1. Loading until the NTSD's entry breakpoint.
  2. From the entry breakpoint to the start of the actual module code, during which it runs as an APC.
  3. The running of the program, which consists of a compiler preamble, the code body, followed (perhaps) by a compiler postamble, until the hitting of NTSD's exit breakpoint.
  4. Process teardown from the exit breakpoint until the removal of the thread as a schedulable entity.

 

Exhibits

 

 

The Details

 

Predawn

Process creation occurs on two levels: NT and Windows. CreateProcess is the Windows call which creates both a process and the initial thread in the process. This uses NT calls to create the process on the OS level, and talks to csrss to "register" the process with the Windows-subsystem server.

The CreateProcess routine is a #define for either CreateProcessA or CreateProcessW, depending on the operating system's overal option: ASCII or Unicode. This routine is visable to Win32 users as an export of Kernel32.dll, a dll which is built in nt/private/windows/base. The code for CreateProcess is in nt/private/windows/base/client/create.c.

Createprocess does several things, the goal of which is to leave us with an APC queue for the initial thread of the new process. To achieve this:

  1. CreateProcess opens and verifies the exe file. Before loading the image, it is mapped by a call to LdrQueryImageFileExecutionOptions. This looks for registry key /Registry/Machine/Software/Microsoft/Windows NT/CurrentVersion/Image File Execution Options/ Using NtOpenKey, handing an Object Attributes block created by the macro InitializeObjectAttributes.
  2. A section object is wrapped around this exe (NtCreateSection). The section object is queried for entry point and stack information. Then it creates a process object wrapped around this section object, NtCreateProcess, which creates stack and code segments, apparantly. BasePushProcessParameters is called on the process object to push arguments onto the stack of the newly created process (this is a trans-context operation). BaseCreateStack, nt/private/windows/base/client/support.c, is called in preparation for thread creation, to allocate stack space for the initial thread (each thread has it's own stack). BaseCreateStack manipulates the TEB to reflect the stack creation. It calls NtAllocateVirtualMemory to allocate and commit the stack and optionally a guard page.
  3. BaseInitializeContext is called, nt/private/windows/base/client/i386/context.c, giving the starting address learned by the previous query to the section object (a long time ago!), to fill in a CONTEXT block. NtCreateThread is passed this block when the thread is being setup. The actual push onto the thread's stack in the thread's context might be in: KiInitializeContextThread in nt/private/ntos/ke/i386/thredini.c. Although we are in kernel mode, perhaps the memory for the new thread is mapped into the address space for the old process, since a full context switch does not seen to intervene.

Back in CreateProcess, windows, the process ends w/ a registration of the new process with csrss. (Some LPC magic here!)

Dawn

 

The queued APC is picked up by the kernel mode routine KiDeliverApc (nt/private/ntos/ke/apcsup.c). It individually calls out kernel and user mode APC's. The user mode part is handed off to KiUserApcDispatcher for handling (nt/private/ntos/rlt/i386/userdisp.asm). It's not clear what intervenes between KiDeliverApc and this routine, but this routine's documentation says that it is already in user mode (run "on return from kernel mode"). Indeed, this function is located in user memory, as part of the ntdll.dll. Furthermore, this function is passed CONTEXT, the continuation environment, as its argument.

Although APC's can do whatever their function pointer points to, this APC has been setup with certain specific function pointers to carry out its task of dll initialization. We are now in the context of the new process. At the bottom of the stack is the return to KiUserApcDispatcher and a pointer to KiUserApcDispatcher's important argument: the continuation environment built to start the users code. This CONTEXT structure (see nt/public/sdk/inc/nti386.h) is also in the user stack, put there by NtCreateThread.

  1. KiUserApcDispatcher calls LdrpInitialize, IPL 0, user mode,
  2. If Peb->BeingDebugged is true, a call to DbgBreakPoint in LdrpInitializeProcess stops the action before dll initialization, for debugging,
  3. on return to KiUserApcDispatcher, it int 2e's to NtContinue passing on its own passed in argument (type CONTEXT see which should be a continuation onto the start of user-executable code.

Morning sickness

 

The CONTEXT record was created by CreateProcess, in the case of an Windows create process, and contains the start address according to the loaded exe, and also a thunking location according to the kernel32.dll visable when CreateProcess was run. In fact, the NtContinue thunks on through BaseProcessStartThunk, see nt/private/windows/base/client/context.c. The true starting address is in eax of the CONTEXT, BaseProcessStartThunk is found in eip.

This causes problems when the location of kernel32.dll does not agree in the two contexts:

  1. Where CONTEXT was created: the caller of CreateProcess,
  2. Where CONTEXT was used: the context of the newly created process.
There is no intrinsic reason why kernel32.dll should not move. This must be enforced outside of the Windows NT system.

Dawn to Dusk

 

The change from APC to normal thread is reflected in the return location on the stack. Now the Top of Stack is BaseProcessStart, which has an ExitThread if the user were to return at this point. However, this apparantly does not survive, as the stack trace at the exit break point indicates. The Top of this Stack as a return address inside the user's program, and it calls into system exit as a Kernel32 function. I do not think BaseProcessStart expects to regain control.

It is difficult to say whether the APC and the user code operate in the same thread, or are they two different threads. Although there is kernel mode operations which punctuate the two code runs, they are a single, contiguous run entity, sharing stack, and so forth.

 

Author

Burton Rosenberg
16 August 1998

 


 

Exhibits

  • SimpleProgram.c

    int main(int argc, char * argv[]) {
        int i ;
        i = 1 ;
        _asm{ int 3 } ;
        i = 2 ;
    }
    

     

  • Predawn

    Microsoft(R) Windows NT Debugger
    Version 4.00
    Copyright (C) Microsoft Corp. 1981-1998
    
    CommandLine: simpleprogram
    Symbol search path is: C:/WTSRV
    NTSD ModLoad: 00400000 00408000   Image@00400000
    NTSD ModLoad: 77f60000 77fbc000   ntdll.dll
    NTSD ModLoad: 77ef0000 77f57000   C:/WTSRV/system32/KERNEL32.dll
    eax=00000000 ebx=00000000 ecx=00000009 edx=00000000 esi=7ffdf000 edi=001406a0
    eip=77f764a8 esp=0012fb84 ebp=0012feac iopl=0         nv up ei pl nz na pe nc
    cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000202
    *** WARNING: symbols checksum is wrong 0x000609b0 0x00062b31 for c:/wtsrv/symbols/dll/ntdll.dbg
    ntdll!DbgBreakPoint:
    77f764a8 cc               int     3
    0:000> kb
    ChildEBP RetAddr  Args to Child
    0012fb80 77f61c1d 00000000 7ffdf000 7ffdee0c ntdll!DbgBreakPoint
    0012feac 77f61187 0012ff30 77f60000 00000000 ntdll!LdrpInitializeProcess+0x825
    0012ff1c 77f767ff 0012ff30 77f60000 00000000 ntdll!LdrpInitialize+0x171
    00000000 00000003 0012ff30 77f60000 00000000 ntdll!KiUserApcDispatcher+0x7
    0:000>
    

     

  • Dawn

    [break at return to KiUserApcDispatcher]
    
    0:000> bp 0x077f767ff
    0:000> g
    eax=ffffffff ebx=7ffdf000 ecx=00000101 edx=ffffffff esi=00000149 edi=0012ff30
    eip=77f767ff esp=0012ff30 ebp=00000000 iopl=0         nv up ei pl zr na po nc
    cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000246
    ntdll!KiUserApcDispatcher+0x7:
    77f767ff 6a01             push    0x1
    0:000> u
    ntdll!KiUserApcDispatcher+0x7:
    77f767ff 6a01             push    0x1
    77f76801 57               push    edi
    77f76802 e8950effff       call    ntdll!ZwContinue (77f6769c)
    77f76807 90               nop
    ntdll!KiUserCallbackDispatcher:
    77f76808 83c404           add     esp,0x4
    77f7680b 5a               pop     edx
    77f7680c 64a118000000     mov     eax,fs:[00000018]
    77f76812 8b4030           mov     eax,[eax+0x30]
    0:000>
    
    [Note: this is a CONTEXT block, argument to NtContinue]
    
    0:000> dd edi
    0012ff30  00010017 00000000 00000000 00000000
    0012ff40  00000000 0000c00b 00000000 811f22f0
    0012ff50  80139782 fd9cedb8 fd9cedb8 fd9cee34
    0012ff60  80139608 811f22f0 00120089 801430f4
    0012ff70  0000000c 00000000 e11e4b08 8017b59f
    0012ff80  00000000 e11e4b08 8019c76f 80ffc020
    0012ff90  8017b5e8 80ffc020 00000101 ffffffff
    0012ffa0  00000030 810f3020 80ffc09c 00000246
    0:000> dd
    0012ffb0  00000000 80ffc020 8019c837 00000000
    0012ffc0  00000038 00000023 00000023 0024068c
    0012ffd0  00000149 7ffdf000 77f694b3 00240000
    0012ffe0  00401010 002405c0 77ef53bc 0000001b
    0012fff0  00000200 0012fffc 00000023 00000000
    00130000  00000000 77fa5be0 77fa5718 77fa5bc8
    00130010  00000000 00000000 00000000 00000000
    00130020  00130040 00000000 00000000 00000000
    0:000>
    
    [ Heading to 0x0401010 via 0x077ef53bc ]
    
    0:000> ln 0x077ef53bc
    *** WARNING: symbols checksum is wrong 0x00063fce 0x000700ee for c:/wtsrv/symbols/dll/kernel32.dbg
    (77ef53bc)   KERNEL32!BaseProcessStartThunk   |  (77ef53c8)   KERNEL32!BaseSwitchStackThenTerminate
    0:000> u 0x077ef53bc
    KERNEL32!BaseProcessStartThunk:
    77ef53bc 33ed             xor     ebp,ebp
    77ef53be 50               push    eax
    77ef53bf 6a00             push    0x0
    77ef53c1 e991bf0100       jmp     KERNEL32!BaseProcessStart (77f11357)
    77ef53c6 8bc0             mov     eax,eax
    KERNEL32!BaseSwitchStackThenTerminate:
    77ef53c8 8b5c240c         mov     ebx,[esp+0xc]
    77ef53cc 8b442404         mov     eax,[esp+0x4]
    77ef53d0 8b642408         mov     esp,[esp+0x8]
    0:000>
    

     

  • DawnToDusk

    0:000> bp 0x0401010
    0:000> g
    eax=00000000 ebx=7ffdf000 ecx=00000001 edx=ffffffff esi=00000149 edi=0024068c
    eip=00401010 esp=0012ffc4 ebp=0012fff0 iopl=0         nv up ei pl nz ac po nc
    cs=001b  ss=0023  ds=0023  es=0023  fs=0038  gs=0000             efl=00000216
    *** ERROR: Module load completed but symbols could not be loaded for image@00400000
    00401010 55               push    ebp
    0:000> kb
    *** WARNING: symbols checksum is wrong 0x00063fce 0x000700ee for c:/wtsrv/symbols/dll/kernel32.dbg
    ChildEBP RetAddr  Args to Child
    0012ffc0 77f11397 0024068c 00000149 7ffdf000 0x401010
    0012fff0 00000000 00401010 00000000 00000000 KERNEL32!BaseProcessStart+0x40
    0:000>
    
    [ user code, ExitThread waiting for us back at BaseProcessStart ]
    
    0:000> u 0x77f11397
    KERNEL32!BaseProcessStart+0x40:
    77f11397 50               push    eax
    77f11398 eb29             jmp     KERNEL32!BaseProcessStart+0x6c (77f113c3)
    77f1139a 8b45ec           mov     eax,[ebp-0x14]
    77f1139d 8b00             mov     eax,[eax]
    77f1139f 8b00             mov     eax,[eax]
    77f113a1 8945e4           mov     [ebp-0x1c],eax
    77f113a4 ff75ec           push    dword ptr [ebp-0x14]
    77f113a7 e8f71e0000       call   KERNEL32!UnhandledExceptionFilter (77f132a3)
    0:000> u 0x77f113c3
    KERNEL32!BaseProcessStart+0x6c:
    77f113c3 e8fa1b0000       call    KERNEL32!ExitThread (77f12fc2)
    77f113c8 c745fcffffffff   mov     dword ptr [ebp-0x4],0xffffffff
    77f113cf 8b45f0           mov     eax,[ebp-0x10]
    77f113d2 5f               pop     edi
    77f113d3 64a300000000     mov     fs:[00000000],eax
    77f113d9 5e               pop     esi
    77f113da 5b               pop     ebx
    77f113db 8be5             mov     esp,ebp
    0:000>
    
    [let it go to the exit breakpoint]
    
    0:000> g
    eax=00140500 ebx=00000000 ecx=7ffde000 edx=00000000 esi=00410200 edi=0024068c
    eip=77f68427 esp=0012fea0 ebp=0012ff64 iopl=0         nv up ei pl zr na po nc
    cs=001b  ss=0023  ds=0023  es=0023  fs=0038  gs=0000             efl=00000246
    ntdll!ZwTerminateProcess+0xb:
    77f68427 c20800           ret     0x8
    0:000> kb
    *** WARNING: symbols checksum is wrong 0x00063fce 0x000700ee for c:/wtsrv/symbols/dll/kernel32.dbg
    *** ERROR: Module load completed but symbols could not be loaded for image@00400000
    ChildEBP RetAddr  Args to Child
    0012fe9c 77f0f9b0 ffffffff 00410200 0024068c ntdll!ZwTerminateProcess+0xb
    0012ff64 00401270 00410200 00000149 0012ffc0 KERNEL32!ExitProcess+0x6d
    00410200 00000000 706d6973 7270656c 6172676f 0x401270
    0:000>
    
    

     

  • Twilight

呼叫(主叫)信令流程 RRC连接建立过程:17:06:50.358 UL CCCH RRC Connection Request ↑17:06:51.515 DL CCCH RRC Connection Setup ↓17:06:52.000 UL DCCH RRC Connection Setup Complete ↑ UE通过RRC连接向RNC发送初始化直传消息,请求连接管理和移动性管理请求:17:06:5 阅读详情

相关推荐

Python角色互动分析:从NLP基础到关系图谱可视化实战

自然语言处理(NLP)作为人工智能的重要分支,通过计算语言学方法让计算机理解人类语言。其核心原理涉及文本表示、特征提取和语义理解,能够将非结构化文本转化为结构化数据。在内容分析领域,NLP的技术价值在于实现关系挖掘和模式识别,帮助量化角色互动特征。基于Python的NLP工具链,结合情感分析和关系图谱技术,可以构建角色互动分析模型。该模型适用于影视剧本分析、游戏剧情设计和社交媒体内容策划等应用场景,通过量化互动频率、情感极性和关系强度等指标,为内容创作提供数据支持。本文以沈汐和、萧长瑜等角色为例,详细演示了

weixin_33971977的博客 367

windows用户态调试

windows用户态调试 打开windows的记事本小程序,windbg attach到这个进程,发现notepad不能动了,这是用户态调试的特点: 今天调试模式,应用程序所有线程都处于freeze状态。 观察一下线程状态: 会看到有6个线程。 0:006> ~* 0 Id: 1de4.1f6c Suspend: 1 Teb: 000007ff`fffdc000 Unfrozen Start: notepad!WinMainCRTStartup (00000000`ff683ac...

hb_zxl的专栏 1449

高分辨率航拍图像的目标检测切图优化策略

本文深入探讨了高分辨率航拍图像目标检测中的切图优化策略。针对大尺寸图像直接缩放导致小目标信息丢失的问题,文章详细阐述了基于重叠切割的核心方法,包括如何根据目标尺寸确定切图尺寸与重叠率,并提供了从切图到坐标还原的完整代码实现与避坑指南,有效提升检测精度与效率。

xk7n92h3p5m的博客 1114

[转]windows程序员进阶系列:《软件调试》之O--- WinDbg使用介

原帖地址:http://blog.youkuaiyun.com/ithzhang/article/details/8630429                         windows程序员进阶系列:《软件调试》之O--- WinDbg使用介绍      拥有一个顺手的武器是每一个武林高手梦寐以求的。对于windows程序员来说,WinDbg调试器就是我们的武器。熟练使用调试器能大大提高我们的

comhaqs的专栏 1497

对接萤石平台调用播放

萤石api 管理 · 萤石开放平台API文档 httpclient pom <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> <version>4.5.2</version> </dependency> package com.ruoyi...

u011799016的博客 1773

S4 HANA 1809+折旧过账(AFAB/AFABN)凭证行数据存储逻辑变迁:从BSEG到ACDOCA的深度解析

本文深度解析了S4 HANA 1809+版本中折旧过账(AFAB/AFABN)凭证行数据存储逻辑的变迁,从传统的BSEG表迁移到ACDOCA表。文章详细探讨了这一变更的技术背景、官方设计意图及实际影响,包括数据存储量减小和系统性能提升等优势。同时提供了升级项目的应对策略和最佳实践建议,帮助用户顺利过渡到新的数据存储模型。

weixin_28731223的博客 294

Windows软件调试学习笔记(三)—— 调试事件的处理

软件调试学习笔记(三)—— 调试事件的处理要点回顾调试事件的处理实验一:实现简单调试器(创建进程)实验二:分析异常来源实验三:实现简单调试器(附加进程)实验四:分析NtDebugActiveProcess总结 要点回顾 当调试器与被调试进程建立连接后,调试器与被调试进程关系如下图所示 被调试进程产生调试事件时,会有专门的API对调试事件进行捕获,并写入调试事件链表当中。 调试器不断检索调试事件链表,不断从调试事件链表中取出调试事件并进行处理。 调试事件的处理 调试器调试目标进程步骤: 关联(创建进程

lzyddf的博客 1745

ros入门(八)---TF坐标转换

TF(TransForm),就是坐标转换,包括了位置和姿态两个方面的变换。

weixin_51157015的博客 3389

KnownDll Herpaderping实现无文件进程注入

本文是对 Windows Process Injection: KnownDlls CachePoisoning的整理学习,并与Herpadering技术结合实现无文件注入。

dzqxwzoe的博客 818

用miniconda建立PyTorch、Keras、TensorFlow三个环境

如果还没有安装Miniconda,请从[Miniconda官网](https://docs.conda.io/en/latest/miniconda.html)下载合适的版本并进行安装。如果遇到问题,可以通过编辑`~/.condarc`文件来临时禁用某个源,或者通过`conda config --remove channels`命令来移除配置的镜像源。要切换到不同的环境,先使用`conda deactivate`命令退出当前环境,再用`conda activate 环境名称`命令激活另一个环境。

数字人生 2464

代数拓扑与AI架构:AI应用架构师深入探索数学研究如何分析复杂系统的结构特性

随着人工智能技术的飞速发展,AI系统变得越来越复杂。AI应用架构师需要有效的工具和方法来理解、设计和优化这些复杂系统。代数拓扑作为数学的一个分支,提供了独特的视角和技术来分析复杂系统的结构特性。本文旨在帮助AI应用架构师深入了解代数拓扑,以及如何将其应用于AI架构设计中,提升对复杂系统的分析能力。首先,我们会介绍代数拓扑和AI架构相关的核心概念及其联系,通过有趣的故事引入主题,让读者轻松理解复杂概念。接着,深入探讨代数拓扑的核心算法原理,结合具体的编程语言代码示例详细阐述。

大模型应用工坊 671

Load and Unload

Load and Unload

求索 1182

Pytorch实现之SRGAN+CBAM的结构设计

在SRGAN的残差连接中加入了CBAM注意力机制,同时设计了四类损失来训练。

LJ1147517021的博客 573

IBM Websphere MQ 基础6:进程定义process define

概念 A process definition contains information about the application that starts in response to a trigger event on a queue manager. When you enable triggering on a queue, you can create a process...

本博客纯属个人学习记载,不对外负责,若有错误,请批评指正 1112

制作你自己的yolov5数据集并进行训练

项目地址:make-your-yolov5_dataset 一、数据集标注软件 labelImg labelMe 精灵标注助手 更多的标注工具你可以去看:深度学习图像标注工具汇总 、 十个最常用深度学习图像/视频数据标注工具 、 百度一下 在这里我选择使用labelImg 二、数据集标注 下载labelImg 解压,直接打开labelimg.exe labelImg标注数据 标注完成后即可获得VOC格式(生成.xml文件)的数据 目录结构: dataset │ ├─Annotations .

年少的勇气已经用完,剩下的就是三思而后行 1万+

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

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

Process and thread

Thread and Process 是操作系统中最基本的两个概念也是必须掌握的两个概念

wgsddfe的专栏 714

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

jms之MQ的互联互通

一直在搞jms的东东, 一些命令还是比较麻烦的, 备份一下,留个记号。1:创建队列管理器:以管理员身份登陆websphere mq服务器,运行websphere MQ控制命令dspmq,显示已有队列管理器状态:dspmq比如项目用到的队列管理器是MQCOSMOS,如果没有,新建一个:crtmqm –q MQCOSMOS如果MQCOSMOS的状态为”Ended unexpec

lcllcl987的专栏 2048

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

Camera2Demo

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

软件构造2-1小结

本人编程这方面基础很差,看PPT需要一点一点翻译,这个帖子是用来翻译、总结老师课件上的内容。 理解传统软件过程的哲学 模型包括线性和迭代模型(瀑布,增量、原型、螺旋和V型模型) Software Configuration Management (SCM) 软件配置管理 了解如何将Git用于日常的SCM任务(基本命令个人开发,用于协作开发的高级命令) 1.Software Development ...

weixin_45665598的博客 250

IBM Websphere MQ 基础5:触发器trigger

概念 A trigger monitor is an application that processes the trigger messages that are put on initiation queues when a trigger event occurs. 触发监控器是一个进程,用于当触发事件发生时处理被put进initiation队列的触发消息; ...

本博客纯属个人学习记载,不对外负责,若有错误,请批评指正 1497

通过注解+AOP记录日志

AOP记录日志

weixin_44001317的博客 234

jms之Message queue的互连互通

贴一篇半年前的老文, 主要涉及 MQ server基础设施中的分布式mq的互联互通. 一 mqsc命令基础: 1:创建队列管理器: 以管理员身份登陆websphere mq服务器,运行websphere MQ控制命令dspmq,显示已有队列管理器状态: dspmq   比如项目用到的队列管理器是MQCOSMOS,如果没有,新建一个: crtmqm –q MQCOSMOS   如果MQCOSMO...

李哥在javaeye 320

CrewAI技术深度解析:多智能体协同框架的架构设计与生产实践

在当今人工智能应用快速发展的时代,构建可扩展、可维护的多智能体系统已成为企业数字化转型的关键挑战。传统单智能体架构在面对复杂业务场景时往往力不从心,而CrewAI框架通过创新的多智能体协同设计,为开发者提供了从原型到生产的技术解决方案。本文将从架构设计、核心组件、技术实现到生产部署等多个维度,深入解析CrewAI框架的技术优势和实践价值。 ## 多智能体协同的核心挑战与CrewAI解决方案 *

gitblog_00986的博客 306

FPGA中for循环的可综合实现与优化技巧

在数字电路设计中,for循环作为基础控制结构在硬件描述语言(HDL)中具有特殊实现方式。不同于软件编程的顺序执行,FPGA中的循环通过空间展开或时间复用转化为并行硬件电路,这种转换过程涉及可综合性与硬件效率的核心问题。通过参数化设计和generate语法,开发者可以创建高度可配置的IP核,如在图像处理中实现3x3卷积核的并行计算。关键技术难点在于平衡资源占用与吞吐量,其中循环展开策略和流水线优化能显著提升性能。实际工程中,for循环在向量化操作和硬件实例化等场景可节省80%代码量,但需警惕组合逻辑循环导致的

weixin_33826609的博客 386
上一篇: NT 下动态切换进程分析笔记
下一篇: 在ring0调用Ring3的代码
iiprogram
博客等级 码龄25年 1068粉丝 1515原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值