//本头文件采用中英文两种语言注释,意在大家都能看懂
//This head file consists of the two language of Chinese and English
/**********************************************************************
**
**--------------------------file infomation----------------------------
**file name:list.h
**
**last modified date:
**
**descriptioin:对于链表的各种操作------any operation of the list
**
**created by:Ethan Wei
***********************************************************************/
/**********************************************************************
头文件------head file
**********************************************************************/
#include <stdio.h>
#include <stdlib.h>
/**********************************************************************
宏定义------macro definition
**********************************************************************/
#define Type int //链表元素类型
#define ROW 10 //打印链表是一行的个数
/*************************************************************************
结构体的定义-----------struct definition
*************************************************************************/
typedef struct list //单链表数据结构------single list struct
{
Type data; //链表中的数据
struct list *next; //下一个指针
}_SList;
typedef struct ulist //最后定义时的单链表数据结构
{
_SList *head; //头节点
_SList *last; //链表的尾指针
int length; //链表的长度
}SList;
/*************************************************************************
函数定义--------function definition
*************************************************************************/
/*************************************************************************
函数名称:InitList
函数表述: 对单链表进行初始化
输入值: SList *
返回值: 初始化成功返回0,否则退出
*************************************************************************/
int InitList(SList *list)
{
list->length = 0; //初始化长度为0
list->head = (_SList *)malloc(sizeof(_SList));
if(list->head == NULL)
{
fprintf(stderr,"内存不足,申请头结点空间失败");
getchar();
exit(1);
}
list->head->next = NULL; //链表的尾指针置空
list->last = list->head; //尾指针指向头指针
return 0;
}
/*************************************************************************
函数名称:create
函数表述: 申请一个动态的链表空间
输入值:
返回值: 申请成功返回空间首地址,否则返回NULL
*************************************************************************/
_SList* create()
{
_SList *newList;
newList = (_SList*)malloc(sizeof(_SList));
if(newList == NULL)
{
fprintf(stderr,"申请新空间失败------addtoHead");
return NULL;
}
return newList;
}
/*************************************************************************
函数名称:findtoPosition
函数表述: 根据位置找到链表的元素
输入值: SList *,int position
返回值: 查找成功返回地址,否则返回NULL
*************************************************************************/
_SList *findtoPosition(SList* list,int position)
{
_SList *curList;
int i;
if(position <= 0 ||position >list->length)
{
puts("查找位置不合法");
return NULL;
}
curList = list->head->next; //指向第一个元素
for(i = 1;i < position; i++)
{
curList = curList->next;
}
return curList;
}
/*************************************************************************
函数名称:findtoData
函数表述: 根据元素找到位置
输入值: SList *,Type data
返回值: 查找成功打印信息,返回0
*************************************************************************/
int findtoData(SList* list,Type data)
{
_SList *curList;
int i;
curList = list->head->next; //指向第一个元素
if(curList == NULL)
{
puts("链表为空");
return 1;
}
for(i = 1;i <= list->length;i ++)
{
if(curList->data == data)
{
printf("位置:%d 查找元素:%d\n",i,data);
}
curList = curList->next;
}
return 0;
}
/*************************************************************************
函数名称:InsertList
函数表述: 插入链表
输入值: SList *,int position,Type data
返回值: 插入成功返回0,否则返回1
*************************************************************************/
int InsertList(SList *list,int position,Type data)
{
int i ;
_SList *curNode;
_SList *newNode;
curNode = list->head; //设置当前节点为头节点,往后遍历
if(position > list->length+1 || position <= 0)
{
printf("插入位置不合法");
return 1;
}
for(i = 1; i < position; i++)
{
curNode = curNode->next;
}
//循环结束,得到要插入的位置前一个节点
newNode = create();
newNode->data = data;
if(curNode->next != NULL)
{
newNode->next = curNode->next;
curNode->next = newNode; //将节点链接上
}
else if(curNode->next == NULL)
{
curNode->next = newNode;
newNode->next = NULL;
list->last = newNode; //更新尾部节点
}
list->length += 1; //更新链表长度
return 0;
}
/*************************************************************************
函数名称:deltoPosition
函数表述: 删除链表,根据位置
输入值: SList *,int position
返回值: 删除成功返回0,否则返回1
*************************************************************************/
int deltoPosition(SList *list,int position)
{
_SList *curNode; //当前节点指针
_SList *delNode; //要删除的节点指针
int i;
if(position > list->length || position <= 0)
{
printf("删除位置不合法\n");
return 1;
}
curNode = list->head;
for(i = 1;i < position;i ++)
{
curNode = curNode->next;
}
//此时得到的节点是要删除节点的前面一个节点
delNode = curNode->next; //此时delNode 就是要删除的节点
if(delNode->next == NULL) //即删除最后一个节点
{
curNode->next = NULL;
free(delNode);
list->last = curNode; //更新最后一个节点
list->length -= 1; //更新链表长度
}
else
{
curNode->next = delNode->next;
free(delNode);
list->length -= 1; //更新链表长度
}
return 0;
}
/*************************************************************************
函数名称:deltoData
函数表述: 删除链表,根据元素
输入值: SList *,Type data
返回值: 删除成功返回0,否则返回1
*************************************************************************/
int deltoData(SList *list,Type data)
{
_SList *curList;
_SList *delList;
int delFlag = 0; //是否删除成功
curList = list->head; //指向第一个元素
if(curList->next == NULL)
{
puts("链表为空");
return 1;
}
while(curList->next != NULL)
{
if(curList->next->data == data)
{
delList = curList->next;
if(delList->next == NULL) //如果删除的节点为最后一个节点
{
free(delList);
curList->next = NULL;
list->length -= 1; //更新链表长度
list->last = curList; //更新尾部节点
delFlag += 1;
break;
}
else
{
curList->next = delList->next;
free(delList);
list->length -= 1; //更新链表长度
delFlag += 1; //记录删除次数
}
}
curList = curList->next;
}
if(delFlag != 0)
{
printf("删除成功,共删除%d个元素,删除元素为%d\n",delFlag,data);
}
return 0;
}
/*************************************************************************
函数名称:addtoHead
函数表述: 头插入节点
输入值: SList *list,Type data
返回值: 插入成功返回0,否则返回1
*************************************************************************/
int addtoHead(SList *list,Type data)
{
static char lastFlag = 0; //是否更新尾部节点的标记
_SList *newList;
newList = create();
newList->data = data;
newList->next = list->head->next;
list->head->next = newList;
list->length += 1; //更新长度
if(list->head->next != NULL)
{
lastFlag = 1; //第一次插入不是头插法
}
if(lastFlag == 0)
{
list->last = newList; //更新末尾节点
lastFlag = 1;
}
return 0;
}
/*************************************************************************
函数名称:addtoTail
函数表述: 尾插入节点
输入值: SList *list,Type data
返回值: 插入成功返回0,否则返回1
*************************************************************************/
int addtoTail(SList *list,Type data)
{
_SList *newList;
newList = create();
newList->data = data;
list->last->next = newList;
newList->next = NULL;
list->length += 1; //更新长度
list->last = newList; //更新末尾节点
return 0;
}
/*************************************************************************
函数名称:Traversal
函数表述: 遍历链表
输入值: SList *list
返回值:
*************************************************************************/
void Traversal(SList *list)
{
_SList *curList;
int i = 0;
curList = list->head;
printf("链表长度:%d\n",list->length);
printf("链表内容如下:");
for(i = 0;i < list->length;i++)
{
if(i % ROW == 0)
{
puts("");
}
printf("%d ",curList->next->data);
curList = curList->next;
}
puts("");
}
/*************************************************************************
函数名称:destroyList
函数表述: 销毁链表
输入值: SList *
返回值: 删除成功返回0,否则返回1
*************************************************************************/
int destroyList(SList *list)
{
int nResult;
while(list->head->next != NULL)
{
nResult = deltoPosition(list,1);
}
return nResult;
}
相关推荐
内核移植链表头文件:list.h
本代码使用Linux Kernel 版本4.19.144中移植出了链表,现在使用C++或者是C语言环境下兼容性很好,不过仅限在Linux平台上!!
c语言slist.h文件下载,关于调用头文件list.h
该楼层疑似违规已被系统折叠隐藏此楼查看此楼诸如此类的,反馈了一大堆的头文件问题,无法把所有的代码上传,刚才代码全部被度娘吃了d:\vc98\include\list.h(38) : error C2059: syntax error : '}'d:\vc98\include\list.h(40) : error C2143: syntax error : missing '{' before '...
linux内核list.h完整源代码
本文档是从GiHup上linux/include/linux/list.h复制过来的,有完整版的list.h,但其中含包含Linux的其它头文件的函数,但基本不影响阅读
Linux内核数据结构之链表list.h
Linux-3.5版本下的list.h注释翻译加详细分析
list.h文件
模板链表类,实现链表基本操作:push、pop、front、back、qurey、insert、sort功能,抛出基本异常。
Linux源码List.h文件详细分析(链表、队列、堆栈、哈希表等)
对Linux内核源码中list.h文件自己分析总结,主要是一些双向循环链表的操作及一些数据结构的实现,方便借鉴引用。
【数据结构】list.h 详细使用教程 -- 附带例子代码
介绍list.h 的详细用法,并给出例子代码
list.h.zip
详见《linux C —— 通用链表(整理自Linux内核链表)》
深入解析Linux内核container_of宏:原理、实现与应用实践
在C语言系统编程中,指针操作与数据结构管理是核心基础。通过指针偏移与地址计算,可以实现高效灵活的内存访问,这是理解底层内存布局的关键。这种技术价值在于,它允许开发者从结构体成员指针反向定位其所属的完整容器结构,从而在资源受限的环境下实现类似面向对象的多态与封装,极大地提升了代码的复用性与模块化。这一原理广泛应用于操作系统内核、嵌入式系统及高性能中间件等场景,用于构建通用数据结构(如链表)与回调机制。本文以Linux内核中广泛使用的container_of宏为具体案例,剖析其如何通过offsetof与类型安全
kernel的list.h(分享)
内核list.h绝对经典,包含了对链表操作的最高境界!新手入门很好用的。
list.h的源文件
list.h的源文件,如果可以和自己的c代码放在一个文件夹,然后#include “list.h”就可以把使用内部的函数
C语言函数深度解析:从基础语法到底层实现与工程实践
函数是编程语言中实现代码复用和模块化的核心机制,其本质是将特定功能封装为可重复调用的代码单元。在C语言中,函数通过参数传递、返回值机制和局部作用域实现数据隔离与通信,其底层依赖于栈帧管理调用过程与内存分配。理解函数的工作原理对于编写高效、健壮的代码至关重要,尤其在系统编程和性能敏感场景中。本文聚焦C语言函数的**参数传递**机制与**栈帧**结构,深入探讨值传递的原理、函数指针的应用以及递归调用的内存模型。通过分析函数设计的最佳实践,如高内聚低耦合原则和错误处理策略,并结合实际案例展示如何构建安全的字符串处
国内9大Coding Plan平台实测:CI/CD延迟与开发者体验横评
代码托管平台不仅是Git仓库,更是现代研发流程的‘生产力基建’核心。其底层能力涵盖Git协议优化、CI/CD调度实时性、制品库并发吞吐及RBAC权限收敛效率等关键维度。尤其在团队规模扩张、日均提交激增、多环境高频部署场景下,Webhook延迟、CI排队耗时、制品上传卡顿等应用层性能指标,远比网络层ping值更能决定开发效能。本文基于真实微服务项目(32模块、8.7万行/仓)与三类极端负载(长尾构建、热区冲突、制品洪峰),对国内9个满足Coding Plan标准的平台开展端到端压测,聚焦CI/CD延迟与开发者
C语言图书管理系统项目实战:从编译运行到功能扩展全解析
数据结构与C语言课程设计是计算机专业学习的核心实践环节,其中文件操作、内存管理和模块化编程是构建可运行程序的关键技术。通过实现一个完整的图书管理系统,开发者能够深入理解结构体、指针、链表等基础数据结构在工程中的应用价值,掌握控制台程序从数据输入、处理到持久化存储的完整闭环。本项目以不少于450行的C语言代码为例,详细演示了如何在VSCode、Visual Studio等主流环境中配置、编译与调试,并提供了从功能测试、边界异常处理到性能优化的系统化方法。对于需要完成课程设计或希望巩固C语言综合应用能力的学习者
实战派指南:反激电源EMI滤波器设计,从理论计算到PCB布局避坑
本文详细解析了反激式开关电源EMI滤波器设计的全流程,从理论计算到PCB布局避坑,结合34W PD快充电源案例,系统介绍了共模与差模干扰的识别、关键元件选型、参数计算优化及PCB布局技巧,帮助工程师有效解决传导测试超标等常见问题。
2025年人形机器人产业研究
人形机器人是一种模仿人类外形、动作和行为的机器人,旨在替代或辅助人类完成各种任务。其显著特征包括人类外形、动作模仿和智能交互能力。根据形态和功能,人形机器人可分为小型、中型、大型以及服务型、工业型、救援型和娱乐型等类别。发展历程经历了初始阶段、高度集成系统阶段和突破性进展阶段,技术不断进步。关键技术包括执行系统、控制系统和感知与交互系统,涉及机械结构、运动控制、平衡控制、任务执行控制以及感知与交互能力。主要研究方向包括外部仿人化和内部仿生,前者关注外观设计、动作控制和任务执行能力,后者致力于模拟人类核心机制
C++模板编程:从函数模板到类模板的泛型编程实践
泛型编程是一种编程范式,其核心思想是编写与数据类型无关的通用代码。其原理是通过类型参数化,在编译时根据具体类型生成特化代码,实现算法和数据结构的复用。这种技术价值在于提升代码的复用性、类型安全性和可维护性,有效避免代码重复。应用场景广泛,包括容器类(如vector、list)、通用算法(如排序、查找)以及需要支持多种数据类型的数据结构实现。本文以C++模板为例,深入探讨了函数模板和类模板的语法、实例化机制及编译模型,并通过栈(Stack)等实际案例展示了如何利用模板实现泛型编程,解决类型相关的代码冗余问题。
成功解决安装cuda的时候,下载的文件自动消失,并且出现An unknown error has occurred
成功解决安装cuda的时候,下载的文件自动消失,并且出现An unknown error has occurred. 目录 解决问题 解决思路 解决方法 解决问题 安装cuda的时候,下载的文件自动消失,并且出现An unknown error has occurred. 解决思路 发生未知错误。 解决方法 很可能是因为当前电脑下载的cuda版本不适合当前电脑GPU支持的cuda版本! 推荐文章:CV:Win1..
从语法到工程:微软视角下的C++实践进阶指南
C++作为一门经典的编译型语言,其核心价值在于对系统资源的精细控制和高性能计算能力。理解其工作原理,需要从编译链接过程、内存管理机制和标准库设计等基础概念入手。这些原理决定了C++在构建大型、高性能软件系统中的技术优势,尤其在操作系统、游戏引擎、高频交易等对性能和可靠性要求极高的场景中不可或缺。然而,从掌握语法到胜任实际工程项目,开发者常面临环境配置、依赖管理、代码健壮性等工程实践挑战。本文聚焦于这一关键跃迁,结合CMake、vcpkg等现代工具链,拆解如何构建可维护、可协作的C++项目,帮助开发者将孤立的
回声消除AEC初探
那段保留即可——在播放期间把麦克风关闭(软件层面的 mute),同样能根除回声,只是会失去“一句话期间仍能捕获背景噪声”的能力。如果还有更细节的需求(比如多语言 TTS、实时流式 ASR),欢迎继续交流。的完整示例,可直接拷贝、改造、集成到你现有的 LLM‑TTS 对话系统中。实际效果取决于用户设备的硬件与驱动,若仍有回声,可让用户佩戴。把扬声器信号(把播放音频拷贝给 AEC)从麦克风流中减去。:TTS 播放的声音被同一个麦克风再次捕获,导致声学回声。三种实现示例,帮助你快速落地。,几乎可以消除所有回声。
Agent Skills应用解析:构建可扩展、高效率AI探员
Agent Skills是一个简洁而强大的概念:它是一个包含组织化的指令、脚本和资源的文件夹,智能体可以动态地发现并加载这些内容,以在特定任务中表现更佳。可组合性(Composability):一个Agent Skill是一个独立的、封装良好的能力单元。开发者可以为不同的功能(例如PDF处理、网络浏览、数据分析)创建独立的技能,然后根据需要将它们组合起来,赋能不同的智能体。这意味着不再需要为每个用例构建碎片化、定制设计的智能体,而是可以通过组合现有技能来快速构建新的专业智能体。
C++ STL容器全解析:从基础类型到智能指针的存储实践
在C++编程中,数据结构和算法是构建高效软件的核心基础。通过泛型编程思想,开发者可以创建独立于数据类型的通用组件,实现代码的高度复用和类型安全。标准模板库(STL)正是这一思想的典范,它将常用的数据结构和算法封装为模板,通过迭代器实现容器与算法的解耦,极大提升了开发效率和程序性能。在工程实践中,STL容器如vector和map能够有效管理动态数组和键值对,避免手动内存管理的繁琐与风险。对于自定义类对象,STL要求类型满足可拷贝构造和可赋值的基本要求,同时通过移动语义和emplace_back等现代C++特性
机器人视觉联动精度优化:从±2mm到±0.02mm,产线级手眼标定全实战
2025年我接东莞长安Type-C接口分拣项目的时候,就是栽在了手眼标定上:实验室里标定完精度±0.5mm,一到产线直接掉到±2mm,机器人10次有3次抓不住,2000多件Type-C接口直接报废,还撞坏了2套汇川SCARA机器人的吸盘,本来45天的工期拖了3个月,不仅没赚到钱,还倒贴了几万块。手眼标定从来不是简单的跑个demo、算个矩阵就完事了,它是一个系统工程:从硬件选型、安装固定、相机标定、标定流程、算法优化、环境控制、重复验证,每一个环节都会影响最终的联动精度。
NXP Layerscape处理器基准测试实战:从CoreMark到EEMBC的深度优化指南
在嵌入式系统开发中,基准测试是评估处理器性能、进行系统调优和平台选型的关键技术手段。其核心原理在于通过一系列标准化、可复现的测试程序,量化CPU的整数运算、浮点处理、内存子系统及网络数据包处理等关键能力。对于网络通信、工业控制和边缘计算等场景,精准的性能数据能为软件优化与硬件选型提供至关重要的决策依据。其中,CoreMark作为现代CPU整数性能的权威测试,通过链表、矩阵和状态机等算法综合反映处理器效率;而EEMBC网络基准测试套件则模拟真实网络负载,其IPmark和TCPmark分数是衡量网络处理器(如N
深度学习工具包 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');```[](https://bitdeli.com/free "Bitdeli Badge")
STM32F407中文手册
STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。
420



被折叠的 条评论
为什么被折叠?



