The Design of Model (part 2)

别再纠结SolidWorks了!用FreeCAD 0.19.4的Part Design工作台,从草图到3D零件保姆级教程 本文提供FreeCAD 0.19.4的Part Design工作台从草图到3D零件的保姆级教程,帮助习惯商业CAD的设计师快速掌握开源工具。详细解析参数化设计流程、约束系统使用技巧,以及与SolidWorks等软件的关键差异,助力高效完成零件建模任务。 阅读详情

The Design of Model (part 2)

仅供个人学习使用,请勿转载,勿用于任何商业用途。

    继续上次的讨论,所有渲染器支持的对象都必须支持接口Draw,那么Draw应该实现哪些职责呢?由于已经把材质作为单独的对象来管理,所以Draw只需要完成2个任务:设置几何数据,绘图。下面是一个可能的Draw方法实现:

  1. Draw()
  2. {
  3.     graphicsDevice.Vertices[0].SetSource(vb,0,vertexStride);
  4.     graphicsDevice.Indices = ib;
  5.     graphicsDevice.VertexDeclaration = vertexDecl;
  6.     graphicsDevice.DrawIndexPrimitive();
  7. }

    也许把Draw更名为SubmitGeometry()更合适。显然,通过这一层封装,渲染器不需要知道所绘制几何体的任何细节。你可以把顶点保存为带索引的顶点缓冲,也可以是简单的顶点数组。这些顶点可以是三角形,也可以是线段,或者点。此外,还应该明确drawable object就是一个最小绘图单元。假设我们使用带索引的顶点缓冲(这也是最常见的方法)来保存几何体数据,那么一个可能的drawable object也许是这样:

  1. class DrawableMesh:IDrawableGeometry
  2. {
  3.     GraphicsDevice graphics;
  4.     VertexBuffer vb;
  5.     IndexBuffer ib;
  6.     VertexDeclaration vertexDecl;
  7.     
  8.     PrimitiveType primitiveType;
  9.     int baseVertex;
  10.     int numVertex;
  11.     int primitiveCount;
  12.     int minVertexIndex;
  13.     int startIndex;
  14.     int streamOffset;
  15.     int vertexStride;
  16.     int startVertex;
  17.     //other properties….

  18.     public void SubmitGeometry(){}
  19.     //other method….
  20. }

    上面的代码非常直观,DrawableMesh只是包含了绘图所需要的所有基本元素而已。确定了类的大概外观,接下来讨论实现细节。这里的DrawableMesh相当于我们上次讨论的mesh part,一个最小绘图单元。复杂模型通常由一个或者多个mesh part组成。但是为每个mesh part都保存独立的vertex buffer或者index buffer却并不是最高效的做法。每创建一块buffer,DirectX就必须花费一定资源对它进行管理, 因此,大量琐碎的buffer会对性能有所影响。常见的方法是把众多buffer打包为一个大buffer,然后通过索引获得不同mesh part的实际数据。打包的方法和策略是多种多样的,可以选择把某个模型中的几个部分打包为一个buffer,或者把整个模型,甚至几个模型的数据都打包为一个buffer(当然,使用顶点数组保存几何体则不必考虑这个步骤)。为了方便讨论,这里只考虑打包整个模型数据的情况:

  1. class GeometryData
  2. {
  3.     GraphicsDevice graphics;
  4.     VertexBuffer vb;
  5.     IndexBuffer ib;
  6.     VertexDeclaration vertexDecl;
  7.     int startVertex;
  8. }

  9. class DrawableMesh:IDrawableGeometry
  10. {
  11.     GeometryData geometryData;
  12.     PrimitiveType primitiveType;
  13.     int baseVertex;
  14.     int numVertex;
  15.     int primitiveCount;
  16.     int minVertexIndex;
  17.     int startIndex;
  18.     int streamOffset;
  19.     int vertexStride;
  20.     //other properties….
  21.     public void SubmitGeometry(){}
  22.     //other method….
  23. }

     一个模型也许包含了若干mesh part,但每个mesh part的实际几何数据都保存在同一个对象中。   

     那么LOD呢?在讨论如何实现LOD前,先来看看相关的LOD技术。我把LOD分为三类,1,顶点改变,索引不变;2. 顶点不变,索引改变;3,顶点和索引都改变。第一种听起来有些奇怪,索引不变,那么绘制的图元数量肯定也不会变,如何能达到LOD的目的呢?其实通过改变顶点位置是可以实现LOD的。举个例子来说,假设有2个三角形,ABC和BCD,4个顶点互不重合,2个三角形共享BC边,但是面积上没有重叠部分(呃,懒得画图了),这是2个三角形正常情况下的拓扑结构。现在假设我移动A点或者D点,使其与B点或C点重合会怎样呢?显然,其中一个三角形会变为直线,图形学中,把这样的三角形的称为退化(degeneration)三角形或者0区域三角形。有趣的是对于这样的三角形,硬件在流水线早期阶段就会把它们裁剪去,因此,虽然图元数量没有改变,仍然达到了LOD的目的。第二种LOD类型是处理地形时最常见的方法,通过改变索引,减少三角形数量。第三种也非常容易理解,相当于创建一个全新的模型。

    对于LOD数据的计算,又分为两类:预处理或者运行时生成。对预处理来说,可以使用手工建模的方式,也可以通过程序;实时LOD自然只能通过程序计算,比如DX里的progress mesh。我比较倾向于手工预处理的方式,原因有2点:1. 程序LOD通常是很费时的工作,我不愿把CPU资源浪费在LOD计算上,现代计算机已经有足够大的硬盘和内存,可以保存预处理数据;2. 所有程序LOD的结果都不理想,程序无法分析某个面的重要性,常常把关键的面缩减了,而该缩的地方又处理不好。当然,手工预处理会极大的增加模型师的工作量,要模型师为每个模型都建立几个不同的LOD副本显然是不现实的,因此,顶点改变,索引不变的LOD方式就变的非常就用了,毕竟与新建模型相比,简单的移动顶点要快的多。对于储存空间来说,仅仅改变索引的方式是最优的,可以共享同一个vertex buffer,可惜这样的数据不太容易生成,大多数建模软件都不允许直接修改索引,当然,你总是可以自己写工具来实现:) 。如何需要支持连续的LOD(CLOD)怎么办呢?显然,预处理的方式无法获得几何上的CLOD,但是通过一些特别的渲染方法,同样能让不连续的LOD对象在变化时,达到视觉上的连续性,比如alpah blend或者geo-morphing.

    如何把LOD集成到我们已有的类中呢?先来看你会如何使用一个支持LOD的模型,下面是2中最有可能的情况:

  1. DrawableMesh.SubmitGeometry(int lod);
  2. 或者
  3. DrawableMesh.SetLod(int lod)
  4. DrawableMesh.SubmitGeometry();

    如果使用前者,就意味着要修改接口,而且并不是场景中所有模型都支持LOD,所以我选择了后者,让支持LOD的mesh派生于DrawableMesh:

  1. class DrawableLodMesh:DrawableMesh
  2. {
  3.     public int Lod{get;set;}
  4. }

    为了保存额外数据,DrawableMesh也需要做相应修改,可以选择把不同的LOD都打包为一块buffer,也可以分开,比如:

  1. public class MeshPartInfo
  2. {
  3.     int baseVertex;
  4.     int numVertex;
  5.     int primitiveCount;
  6.     int minVertexIndex;
  7.     int startIndex;
  8.     int streamOffset;
  9.     int vertexStride;
  10. }
  11. class DrawableMesh:IDrawableGeometry
  12. {
  13.     GeometryData[] geometryData;
  14.     PrimitiveType primitiveType;
  15.     MeshPartInfo[] meshPartInfos;
  16.     //other properties….
  17.     public void SubmitGeometry(){}
  18.     //other method….
  19. }

    可以用相同的方法来处理morph,模型可以既支持lod,也支持morph,Renderer不需要知道这些细节,只需要为不同类型编写相应的SubmitGeometry()方法就可以了。

    至今为止,这样的设计看起来还不错,可是,如果要渲染两个相同模型的不同实体时怎么办呢,两个实体的位置和LOD都可能不相同,如何区分呢?

(to be continue..............)

FreeCAD切割操作指南:从Pocket到布尔运算的完整流程 参数化建模是3D设计领域的核心技术,通过定义几何特征之间的数学关系实现模型智能更新。在FreeCAD中,基于草图的特征建模和实体布尔运算是实现模型切割的两种核心原理。特征建模通过Pocket功能在现有实体上减去草图定义区域,保持完整的参数化关联;布尔运算则通过Cut功能对独立实体进行空间减法操作,适用于复杂形状切割。这两种技术为机械设计、产品原型开发提供了灵活的模型编辑能力,特别是在3D打印和装配设计场景中,精确的切割操作直接影响成品质量。本文以FreeCAD的Part Design和Part工作台为例,系 阅读详情

相关推荐

CATIA从草图到渲染:用Part Design和GSD创建擀面小人

三维CAD建模是工业设计和机械制造的基础技能,而参数化实体建模与自由曲面设计更是其中的核心。在CATIA中,Part Design(零件设计)与Generative Shape Design(创成式曲面设计,即GSD)分别承担规则实体与复杂曲面的构建任务,两者结合可以高效完成从概念到成品的完整建模流程。草图约束、旋转体、拉伸体、扫掠、布尔运算和圆角等基础操作,是打通这两个工作台的关键技术节点,也是工程实践中高频使用的功能。通过一个“擀面小人”卡通造型的完整建模案例,可以直观理解如何将实体建模与曲面设计协同运

weixin_30411819的博客 380

The Design of Model (part 1)

The Design of Model (part 1)仅供个人学习使用,请勿转载,勿用于任何商业用途。              过去一段时间都做引擎设计,小有成果,过几天陆续整理出来,今天先发个引子吧. ^_^           第一步当然是定义模型数据,有了模型,才方便做后续开发。通俗一点说,就是要创建model类。也许你会说XNA或者说DirectX已

Clayman的专栏 3931

FreeCAD参数化建模实战:从草图到复杂机械零件的完整流程解析

参数化建模是现代CAD设计的核心技术,它通过建立特征间的参数关联实现设计的智能更新。FreeCAD作为开源参数化3D建模软件,采用基于历史记录的建模原理,允许用户随时修改早期设计参数,系统会自动更新所有相关特征。这种技术价值在于大幅提升设计迭代效率,避免重复劳动,特别适用于机械设计、产品开发等需要频繁修改的场景。在实际应用中,通过草图绘制、特征建模、布尔运算等基础操作的组合,可以构建出复杂的机械零件。FreeCAD的Part Design工作台提供完整的参数化建模工具链,结合布尔运算和扫掠操作,能够高效完成

weixin_34331102的博客 343

Provider Model Design Pattern Part 1

  Related BooksThis column has been quiet for some time—sorry about that. I have a really, really good excuse, though: Weve been busy working on the next version of the Microsoft® .NET Fram

海豚宝宝的专栏——专注于企业项目管理系统的开发 1141

Vitis Model Composer:基于模型的FPGA设计,从算法到硬件的快速通道

在FPGA开发中,硬件描述语言(HDL)和寄存器传输级(RTL)设计是实现算法硬件加速的传统核心方法,但其手动编码过程耗时且易错。基于模型的设计(MBD)通过提升抽象层级来解决这一痛点,允许工程师在图形化环境中进行系统建模与算法验证,从而将设计焦点从底层电路实现转向高层功能逻辑。这种方法的**技术价值**在于大幅提升了开发效率与可靠性,通过自动化代码生成和硬件感知优化,确保了从算法到可综合RTL代码的正确性与性能。其**应用场景**广泛覆盖信号处理、图像算法和通信协议等数学密集型任务,特别适合算法工程师和系

weixin_33910759的博客 276

电池管理系统(BMS)系列—状态估计之SOH

BMS系列文章,介绍了SOH估计

zxx52113140的博客 1846

Provider Model Design Pattern and Specification, Part 1

转自:http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspnet/html/asp02182004.aspRob HowardMicrosoft CorporationMarch 2, 2004Summary: Rob Howard returns to Nothin But ASP.NET to

monkeyliu19801029的专栏 1004

深入Luckfox Pico的Web界面:从Angular前端到CGI后端的RV1106 IPCWeb全栈解析

本文深入解析了基于瑞芯微RV1106芯片的Luckfox Pico设备上,IPCWeb全栈解决方案的架构与部署。详细介绍了如何通过SDK编译配置,将现代Angular前端框架与高效的C++ CGI后端结合,并利用nginx和FastCGI在嵌入式环境中构建稳定、高性能的Web管理界面,为物联网设备开发提供了完整的实战参考。

3a9bq4r8t2y的博客 276

ABAP Objects Design Patterns – Model View Controller (MVC) Part 2

转载自 By Naimesh Patel In this post, we will see how we can implement the MVC (Model-View-Controller) design pattern in ABAP using the Objects. If you have not read the previous discussion about

zhanghua9948的专栏 577

中国城市统计年鉴1991-2024面板数据真正无缺失值填补指标说明

大学普通高等中等职业教育成人中小学学前教育在校学生人数。大学普通高等中等职业教育成人中小学学前教育在校学生人数。大学普通高等中等职业教育成人中小学学前教育在校学生人数。大学普通高等中等职业教育成人中小学学前教育在校学生人数。大学普通高等中等职业教育成人中小学学前教育在校学生人数。大学普通高等中等职业教育成人中小学学前教育在校学生人数。大学普通高等中等职业教育成人中小学学前教育在校学生人数。大学普通高等中等职业教育成人中小学学前教育在校学生人数。大学普通高等中等职业教育成人中小学学前教育在校学生人数。

yushibing717的博客 928

90nm CMOS工艺下6μW超低功耗LDO设计实战:从原理图到版图全解析

本文详细解析了在90nm CMOS工艺下设计一款静态功耗仅为6μW的超低功耗LDO(低压差线性稳压器)的全过程。文章深入探讨了如何通过改进型翻转电压跟随器(FVF)架构实现无输出电容设计,在满足极低功耗和芯片面积高效(chip-area-efficient)要求的同时,确保环路稳定性与快速瞬态响应,为物联网、可穿戴设备等应用提供关键电源管理解决方案。

weixin_29196613的博客 274

ABAP Objects Design Patterns – Model View Controller (MVC) Part 3

转载自 By Naimesh Patel In this post, we will see how we can implement the Views which will access the Controller and model which is encapsulated in the controller. This post is in continuation of

zhanghua9948的专栏 507

STM32F4系列HAL库配置定时器实验——输入捕获

STM32F4系列HAL库配置定时器实验——输入捕获 输入捕获简单讲解 输入捕获模式可以用来测量脉冲宽度或者测量频率。我们以测量周期和频率为例,用一个简图来说明输入捕获的原理 假定定时器工作在向上计数模式, 图中 t1~t2 时间,就是我们需要测量的高电平时间。测量方法如下:首先设置定时器通道 x 为 上升沿捕获,这样,t1 时刻,就会捕获到当前的 CNT 值,然后立即清零 CNT,并设置通道 x为下降沿捕获,这样到 t2 时刻,又会发生捕获事件,得到此时的 CNT 值,记为 CCRx2。这样,根据定时器

azs0504的博客 9286

Part 7: Adaptive MPC Design with Simulink and Model Predictive Control Toolbox

In this video, we’ll use adaptive MPC to autonomously steer acar whose lateral vehicle dynamicsis changing with time due to the varying longitudinal velocity. In the previous video, we discussed the linear lateral vehicle dynamics and assumed that the ca..

weixin_43332626的博客 1093

量子密钥分发系统的设计与实现(二):光路子系统初步讨论

本文主要对量子密钥分发系统中的光路子系统方案进行了讨论。

量子领域相关话题 2406

4.2 多智能体系统的严格隔离机制:防止上下文污染与隐私数据脱敏实战

本文探讨了多智能体系统中上下文信息共享带来的安全风险与解决方案。研究发现,随着Agent数量增加,上下文信息泄露概率呈指数级上升,可能导致跨Agent错误传播、隐私泄露等问题。文章提出分层隔离架构,将上下文划分为全局共享和本地私有两部分,并通过命名空间隔离、递归压缩和隐私过滤技术确保数据安全。技术实现上,建议为每个子Agent创建独立状态空间,采用原子化更新和读写锁控制避免状态竞争。隐私保护方面,结合正则匹配和命名实体识别技术进行敏感数据过滤,确保符合GDPR等法规要求。这些措施共同构建了可靠、安全且合规的

公众号:AI前沿侦探 225

ABAP Objects Design Patterns – Model View Controller (MVC) Part 1

转载自 By Naimesh Patel | October 13, 2008 | ABAP Objects, OO Design Patterns  Today we will discuss about the Design Pattern: Model-View-Controller, which is also very famous by its abbriviat

zhanghua9948的专栏 481

物理信息神经网络(PINN)文献综述 —— 原理、严格推导与优化训练策略

本章系统阐述物理信息神经网络的理论基础、主要算法改进与训练策略。内容涵盖:PINN 的数学表述与残差构造;损失与梯度的逐步推导;训练困难(梯度消失/爆炸、损失幅度不平衡、频谱偏差、采样效率低等)的定量分析;四类核心解决方案(动态损失加权、梯度归一化与预条件化、自适应采样、分阶段/分域训练)的详细推导与实现要点;以及若干关键算法的伪代码与收敛性形式结论。所有涉及推导的步骤均按顺序展开,给出必要的数学依据与结论性陈述,可直接作为教学或参考章节使用。

u012133341的博客 423

Part 6: How to Design an MPC Controller with Simulink and Model Predictive Control Toolbox

In this video, we’ll use the MPC Designer app to design an MPC controller that autonomously steers a car in a lane change maneuver scenario. Let’s start by looking at the parameters of this system. The car’s global position is represented with respect to t

weixin_43332626的博客 945

visio安装包

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

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

Model View Presenter (MVP) design pattern close look – Part 2 – Passive View

What is Model View Presenter?MVP pattern is one of the major patterns used for extracting business logic outside of UI elements and by that, enabling unit testing the UI without the need for using spe...

weixin_30656145的博客 239

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

Qt Model/View 编程深度解析报告

本文介绍了Qt框架中的Model/View架构,该架构通过分离数据与视图解决了传统GUI开发中的数据冗余和同步问题。文章首先分析了传统基于项控件的局限性,指出其数据耦合导致的维护成本上升。随后阐述了Model/View对MVC模式的改进,合并视图和控制器角色并引入委托机制,形成了Model/View/Delegate范式。 核心内容围绕三大组件展开: 模型作为数据抽象层,通过QAbstractItemModel标准接口统一访问各类数据源,提供QAbstractListModel和QAbstractTable

greenspan的专栏 2177

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

Model View Presenter (MVP) design pattern close look – Part 1 (Supervising Controller)

Usually, usage of design patterns is associated with code executing in the lower tiers, but design patterns can be very usefully used in solving problems of the UI world too.Two of my architecture blo...

weixin_30609287的博客 247

Asp.net Design Pattern study notes -- PART 3

Transaction Script which isuseful in small project that has few business logic not complex to handle .     Active Record   For very small system , when DB modal is exactly likebusiness

我的英文站点:https://iorilan.medium.com/ 1294

Decision Modeling and Optimization in Game Design, Part 1: Introduction

The following blog post, unless otherwise noted, was written by a member of Gamasutra’s community. The thoughts and opinions expressed are those of the writer and not Gamasutra or its parent company.

wanglang3081的专栏 1191

Cadence学习

Cadence 公司不像 Alitum 只做电子设计自动化(EDA)设计软件,它旗下有两个产品链,一个是 IC 产品也就是半导体知识产权(IP),一个是电子设计自动化(EDA)软件。而我们说所的原理图和PCB绘制,其实是属于电子设计自动化(EDA)软件下的PCB设计工具范畴的。其中PCB设计工具又分成PO系列和PS系列,PO中低端系列,也就是OrCAD系列,PS是高端系列,有的人称其为Allegro系列,其实并不准确。其实OrCAD这个产品线是Cadence收购来的,Allegro才是嫡系。

weixin_45905650的博客 4519
上一篇: The Design of Model (part 1)
下一篇: 一些关于引擎设计,Scene Management的文章
soilwork
博客等级 码龄23年 290粉丝 116原创
评论 3
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值