bpl插件系统开发(3)

Delphi 中 BPL(2):大型项目中 BPL 对性能的影响及调优策略 BPL(Borland Package Library)性能受多种因素影响,包括加载与卸载开销、内存问题、全局状态冲突和依赖链复杂度。加载和卸载BPL文件涉及操作系统的动态链接库管理机制,可能导致磁盘I/O和内存分配操作,尤其在大型项目中,初始化时间会显著增加。内存问题如泄漏和碎片化可能影响系统稳定性,而全局状态冲突和多级依赖链则增加了调试和优化的难度。为优化BPL性能,建议采用按需加载机制、模块化设计、内存管理优化、状态隔离技术以及监控与调试工具链。这些策略可以有效减少不必要的加载次数、合理规划功能边界、 阅读详情
  上篇说了一些理论的东西,现在总结一下,我们的程序发布时应该想这样子:

  • 主程序

   一个完全由接口驱动的程序,它调用各种接口完成软件的功能.(当然并不是绝对的,如果你的某个功能并不需要外部来提供的化)

  • 插件s(注意,加了s复数形式)

   放在同一目录下,一个完整的插件应该有两个同名文件,一个是含有实现某接口的bpl,一个是描述该插件功能的xml.

主程序启动时,将加载所有的插件,在运行过程中调用某个接口时,将会向一个PluginLoader请求该接口,该PluginLoader会返回一个插件变量给调用者,而它是使用在bpl中的类来完成该调用.

over.

下面给出一个bplLoader类的代码例子,它可以被你的主程序调用,就是插件管理类

{*******************************************************}
{
 codemyth.Group
 copyright 2004-2005

 codemyth(at)gmail(dot)com

 Create at 2005-7-20 11:22:26

    插件容器类,用于载入插件

Change history:

}
{*******************************************************}

unit uPluginLoader;

interface

uses codemyth.utils, codemyth.util.objectlist, uIPlugin, Xmlplugin, Classes,
    
SysUtils;

type

    
TPluginLoader = class( TObject )
    
private
        
FPluginList: TObjectList;       //存储插件调用接口
        
function GetPlugin( const id: string ): IPlugin;
        
function GetCount: integer;
        
function GetPluginByIndex( const index: integer ): IPlugin;
    
protected
        
procedure UnloadPlugin( const id: string ); overload; //卸载指定的插件
        
procedure UnloadPlugin( const index: Integer ); overload;  //卸载指定的插件
        
procedure LoadPlugin( const XmlFile: string ); //载入位于某目录下的插件
        
procedure UnloadPlugins;        //卸载所有裁入的插件接口
    
public
        
constructor Create;
        
destructor Destroy; override;
    
public
        
procedure LoadPlugins( Directory: string ); //载入插件
        
property Plugin [const id: string]: IPlugin read GetPlugin;
        
property PluginByIndex [const index: integer]: IPlugin read
        
GetPluginByIndex;
        
property Count: integer read GetCount;
    
end;

implementation

{ TPluginLoader }

constructor TPluginLoader.Create;
begin
    
FPluginList := TObjectList.Create;
end;

destructor TPluginLoader.Destroy;
begin
    
UnloadPlugins;
    
FPluginList.Free;
    
inherited;
end;

function TPluginLoader.GetCount: integer;
begin
    
result := FPluginList.Count;
end;

function TPluginLoader.GetPlugin( const id: string ): IPlugin;
var
    
index                : Integer;
begin
    
index := FPluginList.IndexOfName( id );
    
Check( index >= 0, Format( '未找到%s插件.', [id] ) );

    
result := GetPluginByIndex( index );
end;

function TPluginLoader.GetPluginByIndex( const index: integer ): IPlugin;
begin
    
Check( Index < FPluginList.Count,
        
IntToStr( index ) + '超出范围 ,没有该索引.' );

    
result := IPlugin(Pointer(FPluginList.Objects [index]));
end;

procedure TPluginLoader.LoadPlugin( const XmlFile: string );
var
    
BplFile              : string;
    
XmlRoot              : IXMLPluginType;
    
ImplClass            : TPersistentClass;
    
obj                  : TPersistent;
    
Intf                 : IPlugin;
    
BplHandle            : Cardinal;
begin
    
BplFile := ChangeFileExt( XmlFile, '.bpl' );
    
XmlRoot := Xmlplugin.Loadplugin( XmlFile );

    
//载入bpl
    
BplHandle := LoadPackage( BplFile );

    
//存入接口变量
    
ImplClass := GetClass( XmlRoot.Class_ );
    
check( ImplClass <> nil,
        
Format( '没有在%s中找到%s类.', [BplFile, XmlRoot.Class_] ) );

    
obj := ImplClass.Create;
    
Check( Supports( obj,
        
StringToGUID( '{48BF4000-B028-4B57-9955-B1A8305DA394}' ), Intf ),
        
ImplClass.ClassName + '不支持插件接口IPlugin.' );

    
//存入plugin,不允许id重复
    
if FPluginList.IndexOfName( XmlRoot.Id ) = -1 then
    
begin
        
FPluginList.AddObject( XmlRoot.Id + '=' + IntToStr( BplHandle )
            
, Pointer(Intf) );
    
end;
end;

procedure TPluginLoader.LoadPlugins( Directory: string );
var
    
i                    : Integer;
begin
    
with TStringList.Create do
    
begin
        
try
            
Text := GetFilesList( Directory, '.xml' );
            
for i := 0 to Count - 1 do
                
if FileExists( ChangeFileExt( Strings [i], '.bpl' ) ) then
                    
LoadPlugin( Strings [i] );
        
finally
            
Free;
        
end;
    
end;
end;

procedure TPluginLoader.UnloadPlugin( const id: string );
var
    
index                : Integer;
begin
    
index := FPluginList.IndexOfName( id );
    
Check( index >= 0, Format( '未找到%s插件.', [id] ) );

    
UnloadPlugin( index );
end;

procedure TPluginLoader.UnloadPlugin( const index: Integer );
begin

    
UnloadPackage( StrToInt( FPluginList.ValueFromIndex [index] ) );

    
FPluginList.Delete( index );
end;

procedure TPluginLoader.UnloadPlugins;
var
    
i                    : integer;
begin
    
for i := FPluginList.Count - 1 downto 0 do UnloadPlugin( i );
end;

end.

XmlConfig单元,XmlPlugin单元是一个由delphi XmlBinding向导生成的单元,用来读写plugin的xml配置文件

uIPlugin单元,是插件接口声明类

{*******************************************************}
{
 codemyth.Group
 copyright 2004-2005

 codemyth(at)gmail(dot)com

 Create at 2005-7-20 10:22:47

    插件系统公用定义,容器和插件均应包含该单元定义

Change history:

}
{*******************************************************}

unit uIPlugin;

interface

type

    
//插件信息体
    
TPluginInfo = record
        
Id: string;                     //插件id  ,与xml文件中一样
        
Name: string;                   //插件名称
        
Version: string;                //插件版本
        
Description: string;            //插件简介描述
        
Vendor: string;
    
end;

    
//插件接口,开发之插件应实现该接口,容器使用该接口调用插件
    
{
        容器调用的例子,得到IPlugin的实例thePlugin后
        1.显示插件信息
        ShowMessage(thePlugin.GetInfo.Name);
        2.配置插件执行环境参数
        thePlugin.EditConfig
        3.执行插件
        thePlugin.SetRunParam;
        thePlugin.Execute;
        thePlugin.GetRunResult; //处理插件执行结果
    }
    
IPlugin = interface
        
['{48BF4000-B028-4B57-9955-B1A8305DA394}']
        
function GetRunResult: TObject; //用于向容器返回执行Execute后的结果
        
//用于容器传如执行参数,通常会显示一个Form让用户输入,如果用户存入了
        
procedure SetRunParam;
        
function GetInfo: TPluginInfo;  //向容器返回插件的信息
        
{
        用于容器调用配置插件的持久性配置,
        通常会显示插件内的一个配置Form,
        并可以将Form中的用户输入存入插件配置目录
        }
        
procedure EditConfig;
        
procedure Execute;              //执行插件
    
end;

implementation

end.

另两个codemyth开头的单元是我自己的函数包,其中codemyth.util.objectList声明了TObjectList类,它继承自TstringList类,但它可以自动销毁Objects中存储的对象实例而已.你可以用TstringList代替它,但你就需要自己释放TPluginList中的接口变量列表(虽然接口不需要释放,他通过引用计数来自释放

Delphi 中 BPL(1):基本概念、用途及使用方法 BPL 是 Binary Package Library 的缩写,表示二进制包文件。它是 Delphi 和 C++Builder 中用来存储运行时包的一种形式。这些包可以包含 VCL 或者自定义组件及其相关资源。 阅读详情

相关推荐

Delphi BPL模块化开发与实战应用

Delphi BPL(Package Library)是基于VCL框架的动态运行时包技术,本质上是一种封装了类、组件、窗体及资源的共享模块,支持在运行时动态加载与卸载。相比DLL,BPL不仅能导出函数,还可完整传递Delphi对象模型,实现跨模块的类继承与异常处理。其核心优势在于与IDE深度集成,支持设计期注册与运行时调用的统一,广泛应用于医疗、金融、工业自动化等需高可扩展性的系统中。例如,在医疗信息系统中,通过BPL实现检验、影像、电子病历等功能模块的热插拔,主程序无需重启即可动态集成新功能。

weixin_42527589的博客 1149

bpl插件系统开发(1)

  半路出家的delphier一如我,对于win32api式的调用有着近乎厌恶的抵触情绪,我很早以前看c++的教程时看到lptrXXXXX的变量就头大,以至于到现在都不会用c++,都不曾写成功过那怕一个hello world程序,所以对于dll式的导出函数后面加stdcall使用右到左的参数调用方式,总觉得没有delphi的美感.再加上看到了许多bpl可以导出类,而dll很麻烦的文章,更是坚定了我

一竿残照.金棣@CSDN.NET 2577

delphi中bpl的使用demo

delphi中bpl的使用demo,对一般初学者有所帮助。需要的可以下载

bpl插件系统开发(5)

在这样的构想下,我们来做一个demos,我们来定义如下的被IMisDriver驱动的接口,加入现在能想到的简单的应用,我们要作的工作如下定义被驱动的接口 撰写IMisDriver的一个实现,用它来驱动各个接口,IMisDriver通过调用TPluginLoader的获得接口实例. 撰写每个接口的实现,并生成多个bpl 用TPluginLoader来载入这些插件, 主程序,实例化一个TPluginL

一竿残照.金棣@CSDN.NET 1914

团子杂记:SAP收入确认工具RAR(Revenue Recognition&Reporting)在新收入准则下的应用

SAP收入确认工具RAR知识分享

Lucas1211的博客 4297

利用python爬取东方财富网股吧评论并进行情感分析(一)

利用python爬取东方财富网股吧评论(一) python-东方财富网贴吧文本数据爬取 分享一下写论文时爬数据用到的代码,有什么问题或者改善的建议的话小伙伴们一起评论区讨论。 新的改变 我们对Markdown编辑器进行了一些功能拓展与语法支持,除了标准的Markdown编辑器功能,我们增加了如下几点新功能,帮助你用它写博客: 全新的界面设计 ,将会带来全新的写作体验; 在创作中心设置你喜爱的代码高亮样式,Markdown 将代码片显示选择的高亮样式 进行展示; 增加了 图片拖拽 功能,你可以将本地的图片直

YMG521000的博客 1万+

bpl插件系统开发

一个插件系统需要什么?       一个最小的插件系统当然需要插件本身,调用插件的容器,最后需要契约.       契约是什么呢?契约就是两个对象相互沟通的一个标准,这个标准应该统一,这样容器才能和不同的插件通讯.我们可以使用接口来表述这个契约.例如 type     IPlugin = interface         ['{48BF4000-B028-4B57-9955-B1A

diligentcat的专栏 1762

小红书UID泄露风险揭秘:如何防止你的手机号被社工库关联(附防护指南)

本文揭示了小红书UID泄露的严重风险,详细解析了UID与手机号关联后被社工库利用的完整链条。通过分析黑产的数据整合技术,提供从基础到进阶的防护策略,包括密码管理、账号隔离和应急响应措施,帮助用户有效防范个人信息泄露风险。

ol789012345的博客 1566

bpl插件系统开发(4)

  我们可以想像这样一个系统,与mvc的思想比较相同,controller负责整个系统的调度,当用户执行了某个action后,controller将其处理后用某个特定的view来呈现给用结果.这就是mvc先看看这个图这图是我用Together6.1画的,关心的设计思想,而不是代码本省,而且together本身也不支持pascal语法生成(不知道有没有插件)其中的IMisDriver就是mvc中的T

一竿残照.金棣@CSDN.NET 2099

腾讯云DBA面试(一面)

在第二阶段,根据RM返回的结果,如果涉及分布式事务的所有RM都返回可以提交, 则TM给RM发送commit的命令,每个RM实现自己的提交,同时释放锁和资源,然后RM反馈提交成功, TM完成整个分布式事务;根据事务所处的阶段,可以回滚到具体的版本,实现一致性。1.并发执行的事务,在prepare阶段,redo log先写文件缓存,第一个领头的事务,在等待n个事务后, 在第一个事务去刷写磁盘时,会把同组的其他的事务,也一起刷写到磁盘上,这样就减少了刷盘的次数,降低了磁盘的IOPS。分布式锁是怎么实现的?

u012565458的博客 1988

基于多智能体协作的量化交易研究框架TradingAgents详解

量化交易系统通过算法模型分析市场数据,旨在实现自动化投资决策。其核心原理在于利用计算机强大的数据处理能力,结合统计学和机器学习方法,从历史数据中挖掘可重复的盈利模式。这一技术的价值在于能够克服人类情绪干扰,实现纪律性交易,并快速处理海量信息。在应用场景上,量化策略广泛应用于股票、期货、外汇等多个金融市场。本文聚焦的TradingAgents框架,创新性地引入了**多智能体协作**和**对抗性验证**机制,通过模拟真实投研团队的分工与辩论流程,构建了一个研究友好、决策过程可解释的量化交易研究平台,为探索大语言

weixin_36019375的博客 439

bpl插件系统开发(2)

  插件规范-----------插件必须实现一个接口,该接口通过GetObject,SetObject方法让容器和插件能够交互数据.IPlugin = interface         [{48BF4000-B028-4B57-9955-B1A8305DA394}]         function GetRunResult: TObject; //用于向容器返回执行Execute后的结果

一竿残照.金棣@CSDN.NET 1963

电商平台系统需求规格说明书(示例)

​​电商系统​​:指本文件所描述的集商品展示、销售、支付、物流跟踪、用户管理等功能于一体的综合性在线购物平台。​​API​​:应用程序编程接口(Application Programming Interface),用于实现系统各模块之间或与外部系统之间的数据交互和功能调用。

跟佟格湾一起学习计算机知识吧~ 1273

delphi bpl插件系统开发

一个插件系统需要什么? 一个最小的插件系统当然需要插件本身,调用插件的容器,最后需要契约. 契约是什么呢?契约就是两个对象相互沟通的一个标准,这个标准应该统一,这样容器才能和不同的插件通讯.我们可以使用接口来表述这个契约.例如 type IPlugin =interface ['{48BF4000-B028-4B57-9955-B1A8305DA39...

编程资料收集与共享交流 855

《中国电信运营商骨干网:历史、现状与未来演进》系列 第一篇:中国骨干网全景图:一级运营商与专用网络的演进

揭秘国家信息高速公路!一文读懂什么是骨干网,它如何支撑我们的数字生活,以及电信、联通、移动、广电等巨头如何构建这张“国家级动脉”。

maqh_csdn的博客 2043

Python 爬虫实战:就业市场趋势数据抓取与行业洞察

在当今竞争激烈的就业市场中,了解行业趋势和就业形势对于求职者、学生以及人力资源专业人士来说至关重要。通过获取和分析就业市场数据,我们可以深入了解不同行业的招聘需求、薪资水平、技能要求等关键信息,从而为职业规划和人才发展提供有力支持。

yansideyucsdn的博客 1409

Delphi创建bpl和动态调用bpl示例源码:探索Delphi的强大功能

Delphi创建bpl和动态调用bpl示例源码:探索Delphi的强大功能 去发现同类优质开源项目:https://gitcode.com/ 项目介绍 在软件开发领域,Delphi语言的强大功能和灵活性使其成为众多开发者的首选。今天,我们要推荐的是一个开源项目——Delphi创建bpl和动态调用bpl示例源码。这个项目为广大开发者提供了一个简便的方式来创建和调用BPL(Binary Portabl...

gitblog_06739的博客 786

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

BPL 和动态加载包

BPL 是一种特别的 DLL; 使用 Delphi 开发程序,可以把一个大程序的一部分,独立编译成一个 BPL,一个 Delphi 里面称作 Package 的东西,这里中文我们称作【包】,然后让 EXE 去加载它。 一个 EXE 加载 BPL 有两种模式:1. 静态加载;2. 动态加载; 关于静态加载: EXE 静态加载一个 BPL,如果 EXE 在启动的时候系统里面没有正确的 BPL 文件,EXE 会启动失败。 关于动态加载: 动态加载有很多好处。比如,BPL 文件不存在的时候,EXE 不会

pcplayer的博客 1791

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

深度学习工具包 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&#39;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(&#39;DeepLearnToolbox&#39;));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(&#39;state&#39;,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&#39;); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand(&#39;state&#39;,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 = &#39;sigm&#39;;%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, &#39;Too big error&#39;);```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(&#39;state&#39;,0)sae = saesetup([784 100]);sae.ae{1}.activation_function = &#39;sigm&#39;;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)&#39;)% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;;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, &#39;Too big error&#39;);```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x&#39;,28,28,60000))/255;test_x = double(reshape(test_x&#39;,28,28,10000))/255;train_y = double(train_y&#39;);test_y = double(test_y&#39;);%% 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&#39;ll get around 1.2% errorrand(&#39;state&#39;,0)cnn.layers = { struct(&#39;type&#39;, &#39;i&#39;) %input layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 6, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %sub sampling layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 12, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 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, &#39;Too big error&#39;);```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(&#39;state&#39;,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, &#39;Too big error&#39;);%% ex2 neural net with L2 weight decayrand(&#39;state&#39;,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, &#39;Too big error&#39;);%% ex3 neural net with dropoutrand(&#39;state&#39;,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, &#39;Too big error&#39;);%% ex4 neural net with sigmoid activation functionrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;; % 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, &#39;Too big error&#39;);%% ex5 plotting functionalityrand(&#39;state&#39;,0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = &#39;softmax&#39;; % 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, &#39;Too big error&#39;);%% 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(&#39;state&#39;,0)nn = nnsetup([784 20 10]); nn.output = &#39;softmax&#39;; % 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, &#39;Too big error&#39;);```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

BPL插件公共变量共享及BPL窗口融入Exe程序Demo源码介绍:项目核心功能及场景

BPL插件公共变量共享及BPL窗口融入Exe程序Demo源码介绍:项目核心功能及场景 去发现同类优质开源项目:https://gitcode.com/ 本文将为您详细介绍一个开源项目——BPL插件公共变量共享及BPL窗口融入Exe程序Demo源码。该项目不仅解决了Exe程序与BPL插件间数据同步的难题,还提升了用户界面的融合度,以下是详细的项目介绍和分析。 项目介绍 BPL插件公共变量共享及BPL...

gitblog_06786的博客 644

Delphi BPL包合并图文教程

Delphi IDE 本身就是一个插件模式的工具,插件的好处不用多说。运行包的BPL,其实就是众多单元的集合,因此可以再次重新组合,只要你将各个BPL包用到的单元再组合一次!本文以  http://code.google.com/p/tangram-plugin-framewor

leon_kin的专栏 4268

delphi bpl插件系统开发(转)

半路出家的delphier一如我,对于win32api式的调用有着近乎厌恶的抵触情绪,我很早以前看c++的教程时看到lptrXXXXX的变量就头大,以至于到现在都不会用c++,都不曾写成功过那怕一个helloworld程序,所以对于dll式的导出函数后面加stdcall使用右到左的参数调用方式,总觉得没有delphi的美感.再加上看到了许多bpl可以导出类,而dll很麻烦的文章,更是坚定了我的方向

gjtao1130的专栏 2678
上一篇: bpl插件系统开发(2)
下一篇: bpl插件系统开发(4)
JavaD
博客等级 码龄23年 3粉丝 11原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址