基于元数据驱动模型架构在ASP.Net的应用研究

8、IIS 6 架构与 ASP.NET 应用配置全解析 本文深入解析了 IIS 6 的架构设计及其与 ASP.NET 应用程序的配置方法。内容涵盖 IIS 服务的核心组件、XML 元数据库的优势与管理、IIS 6 的两种隔离模式对比,以及 ASP.NET 应用程序在 IIS 6 中的配置步骤和优化策略。同时,还总结了 IIS 6 与 ASP.NET 结合的优势,并提供常见问题的解决方案,帮助开发者更好地构建高效、稳定的 Web 应用环境。 阅读详情

目前流行的asp.net架构很多,有开源的有模式与实践(Microsoft patterns & practices)小组的开源项目Web Service

Factory,Nhibernet, Nbear ORM, Petshop等架构; 下面我又介绍另一种基于元数据(XML)架构,在ASP.net2.0的程

序应用,而且这种架构目前很多 IT公司使 用较少,它的特点灵活度较高, 简单高效,方便的IOC依赖注入,对象 间

解偶性好,开发效率较高,可以结合微软企业库进行 高效率的存储。 我在微软互联星空项目中,微软有很好的成功案例。

 

总体思想是采用XML(Template模板)进行权限控制,参考下图:

首先在Global.asax设置全局对象,系统启动后会把相关持久对象装入内存,提高系统运行速度:

相关代码如下:

<%@ Application Language="C#" %>
<%@ Import Namespace="Microsoft.XXXXX.Advertising.SystemFrameWork" %>

<script runat="server">

    void Application_Start(object sender, EventArgs e)
    {
        SystemVM VM = new SystemVM();
        Application.Lock();
        Application["VM"] = VM;
        Application.UnLock();
       
    }
   
    void Application_End(object sender, EventArgs e)
    {
        //  在应用程序关闭时运行的代码

    }
       
    void Application_Error(object sender, EventArgs e)
    {
        // 在出现未处理的错误时运行的代码

    }

    void Session_Start(object sender, EventArgs e)
    {
        // 在新会话启动时运行的代码

    }

    void Session_End(object sender, EventArgs e)
    {
        // 在会话结束时运行的代码。
        // 注意: 只有在 Web.config 文件中的 sessionstate 模式设置为
        // InProc 时,才会引发 Session_End 事件。如果会话模式设置为 StateServer
        // 或 SQLServer,则不会引发该事件。

    }
      
</script>  

第二,建立SystemVM.cs驱动模型类,包括一些相关属性和装载相关Template模板:

 

部分逻辑流程如下:

简略代码如下: 
    public class SystemVM
    {
        //角色模板
        private SystemService m_system = null;
        private OrderService m_order = null;
        private QueryService m_query = null;
        private FoundationService m_found = null;

        /// <summary>
        ///
        /// </summary>
        public XmlNode XmlDimension
        {
            get
            {
                if (HttpContext.Current.Cache["dimension"] == null)
                {
                    LoadXmlDimension();
                }
                return (XmlNode)HttpContext.Current.Cache["dimension"];
            }
        }
        /// <summary>
        /// 查询模板
        /// </summary>
        public XmlNode XmlQueryList
        {
            get
            {
                if (HttpContext.Current.Cache["querylist"] == null)
                {
                    LoadXmlQueryList();
                }
                return (XmlNode)HttpContext.Current.Cache["querylist"];
            }
        }

        /// <summary>
        /// JavaScript模板
        /// </summary>
        public XmlNode XmlJavaScript
        {
            get
            {
                if (HttpContext.Current.Cache["javascript"] == null)
                {
                    LoadXmlJavaScript();
                }
                return (XmlNode)HttpContext.Current.Cache["javascript"];
            }
        }
        /// <summary>
        /// 省分模板
        /// </summary>
        public XmlNode XmlProvince
        {
            get
            {
                if (HttpContext.Current.Cache["province"] == null)
                {
                    LoadXmlProvince();
                }
                return (XmlNode)HttpContext.Current.Cache["province"];
            }
        }
        #region 多角色模板
        /// <summary>
        /// 系统角色模板
        /// </summary>
        public XmlNode XmlTemplate
        {
            get
            {
                XmlNode xmlNode = null;
                if (HttpContext.Current.Request.Cookies["user"] != null)
                {
                    string sWebSiteType = HttpContext.Current.Request.Cookies["user"]["WebSiteType"];

                    if (sWebSiteType == "0")
                    {
                        xmlNode = XmlCenterTemplate;
                    }
                    if (sWebSiteType == "1")
                    {
                        xmlNode = XmlProvinceTemplate;
                    }
                    if (sWebSiteType == "2")
                    {
                        xmlNode = XmlCityTemplate;
                    }

                }
                return xmlNode;
            }
        }

        public XmlNode XmlCenterTemplate
        {
            get
            {
                if (HttpContext.Current.Cache["CenterTemplate"] == null)
                {
                    LoadXmlCenterTemplate();
                }
                return (XmlNode)HttpContext.Current.Cache["CenterTemplate"];
            }
        }
        public XmlNode XmlProvinceTemplate
        {
            get
            {
                if (HttpContext.Current.Cache["ProvinceTemplate"] == null)
                {
                    LoadXmlProvinceTemplate();
                }
                return (XmlNode)HttpContext.Current.Cache["ProvinceTemplate"];
            }
        }
        public XmlNode XmlCityTemplate
        {
            get
            {
                if (HttpContext.Current.Cache["CityTemplate"] == null)
                {
                    LoadXmlCityTemplate();
                }
                return (XmlNode)HttpContext.Current.Cache["CityTemplate"];
            }
        }
        /// <summary>
        /// 加栽角色权限模板
        /// </summary>
        private void LoadXmlCenterTemplate()
        {
            string strBasePath = AppDomain.CurrentDomain.BaseDirectory;
            XmlDocument doc = new XmlDocument();
            string sPath = strBasePath + @"Template/" + "CenterTemplate.Config";
            doc.Load(sPath);
            XmlNode xmlNode = doc.DocumentElement;
            HttpContext.Current.Cache.Insert("CenterTemplate", doc.DocumentElement,
              new CacheDependency(sPath));
        }
        private void LoadXmlProvinceTemplate()
        {
            string strBasePath = AppDomain.CurrentDomain.BaseDirectory;
            XmlDocument doc = new XmlDocument();
            string sPath = strBasePath + @"Template/" + "ProvinceTemplate.Config";
            doc.Load(sPath);
            XmlNode xmlNode = doc.DocumentElement;
            HttpContext.Current.Cache.Insert("ProvinceTemplate", doc.DocumentElement,
              new CacheDependency(sPath));
        }
        private void LoadXmlCityTemplate()
        {
            string strBasePath = AppDomain.CurrentDomain.BaseDirectory;
            XmlDocument doc = new XmlDocument();
            string sPath = strBasePath + @"Template/" + "CityCenterTemplate.Config";
            doc.Load(sPath);
            XmlNode xmlNode = doc.DocumentElement;
            HttpContext.Current.Cache.Insert("CityTemplate", doc.DocumentElement,
              new CacheDependency(sPath));
        }
        #endregion
        /// <summary>
        /// 系统服务
        /// </summary>
        public SystemService SystemService
        {
            get
            {
                return m_system;
            }
        }
        /// <summary>
        /// 查询服务
        /// </summary>
        public QueryService QueryService
        {
            get
            {
                return m_query;
            }
        }
        /// <summary>
        /// 基础信息
        /// </summary>
        public FoundationService FoundationService
        {
            get
            {
                return m_found;
            }
        }
        /// <summary>
        /// 订单管理
        /// </summary>
        public OrderService OrderService
        {
            get
            {
                return m_order;
            }
        }
        public SystemVM()
        {
            LoadBusinessObj();
        }
        /// <summary>
        /// 根据模板类型,返回系统可以选择的模板种类。
        /// </summary>
        /// <param name="sType"></param>
        /// <returns></returns>
        public XmlNodeList GetXmlJavaScriptByType(string sType)
        {
            XmlNodeList xmlNodeList = XmlJavaScript.SelectNodes("//项[@类型='" + sType + "']");
            if (xmlNodeList.Count<0)
            {
                throw new Exception("找不到类型为["+sType+"]的节点!");
            }
            return xmlNodeList;
        }
        /// <summary>
        /// 根据模板名称,获取JavaScript模板
        /// </summary>
        /// <param name="sName"></param>
        /// <returns></returns>
        public string GetXmlJavaScriptTpl(string sName)
        {
            StringBuilder sJsTemplate = new StringBuilder("");
            XmlNode xmlNode = XmlJavaScript.SelectSingleNode("//项[@名称='" + sName + "']");
            if (xmlNode == null)
            {
                throw new Exception("找不到名称为[" + sName + "]的节点!");
            }
            string sPath = ToolFunc.GetXmlString(xmlNode, "@模版");
            sPath = AppDomain.CurrentDomain.BaseDirectory + sPath;
            using (TextReader sr = File.OpenText(sPath))
            {
                String line;
                while ((line = sr.ReadLine()) != null)
                {
                    sJsTemplate.AppendLine(line);
                }
            }
            return sJsTemplate.ToString();
        }
        public string GetUrlFromJavaScript(string sName)
        {
            string sUrl = "#";
            XmlNode xmlNode = XmlJavaScript.SelectSingleNode("//项[@名称='" + sName + "']");
            if (xmlNode == null)
            {
                throw new Exception("找不到名称为[" + sName + "]的节点!");
            }
            XmlElement el = (XmlElement)xmlNode;
            sUrl = el.GetAttribute("Url");
            return sUrl;
        }
        private void LoadXmlProvince()
        {
            string strBasePath = AppDomain.CurrentDomain.BaseDirectory;
            XmlDocument doc = new XmlDocument();
            string sPath = strBasePath + @"Template/" + "Province.Config";
            doc.Load(sPath);
            XmlNode xmlNode = doc.DocumentElement;
            HttpContext.Current.Cache.Insert("province", doc.DocumentElement,
               new CacheDependency(sPath));
        }
        private void LoadXmlJavaScript()
        {
            string strBasePath = AppDomain.CurrentDomain.BaseDirectory;
            XmlDocument doc = new XmlDocument();
            string sPath = strBasePath + @"Template/" + "JavaScript.Config";
            doc.Load(sPath);
            HttpContext.Current.Cache.Insert("javascript", doc.DocumentElement,
                new CacheDependency(sPath));
        }
        private void LoadXmlDimension()
        {
            string strBasePath = AppDomain.CurrentDomain.BaseDirectory;
            XmlDocument doc = new XmlDocument();
            string sPath = strBasePath + @"Template/" + "Dimension.Config";
            doc.Load(sPath);
            HttpContext.Current.Cache.Insert("dimension", doc.DocumentElement,
                new CacheDependency(sPath));
        }
        /// <summary>
        ///
        /// </summary>
        private void LoadXmlQueryList()
        {
            string strBasePath = AppDomain.CurrentDomain.BaseDirectory;
            XmlDocument doc = new XmlDocument();
            string sPath = strBasePath + @"Template/" + "QueryList.config";
            doc.Load(sPath);
            HttpContext.Current.Cache.Insert("querylist", doc.DocumentElement,
                new CacheDependency(sPath));
        }

        /// <summary>
        /// 加载业务对象
        /// </summary>
        private void LoadBusinessObj()
        {
            m_system = new SystemService(this);
            m_order = new OrderService(this);
            m_found = new FoundationService(this);
            m_query = new QueryService(this);
        }

此时可以根据数据库的角色记录,通过元数据模型进行权限与模板匹配,从而达到非常棒的架构设计。

 

 

———————————————————————
任何美好的事物只有触动了人们的心灵才变的美好;
孤独的时候看看天空里的雨,其实流泪的不只是你。

———————————————————————
 

Meta.Net:Meta.Net是一个C#.NET框架,用于从Sql Server和MySql中提取数据库元数据。 目前,不要使用Meta.Net.Sync库中的任何内容。 我在一次重大重写中故意中断了此操作,因为我现在还不希望任何人与它同步数据库 元网 Meta.Net是一个C#.NET框架,用于从Sql Server和MySql中提取数据库元数据。 查看Meta.Net.TestConsole项目的Program.cs-GetCatalogs()方法以了解当前用法。 目前,不要使用Meta.Net.Sync库中的任何内容。 我在一次重大重写中故意破坏了Sync库,因为我现在还不想让任何人与它同步数据库。 我刚刚完成了一个序列化和反序列化的大型重构,使用DataContract和DataMember属性装饰所有Meta对象和基础对象,以便与DataContractSerializer一起使用。 这有助于我保留对象引用以用于深度克隆和WCF。 查看SerializationExtensions类中提供的扩展方法,该类还具有一些Json.NET扩展方法,因此我可以将其从Meta对象类中剔除。 适配器已经用TAP模式(异步/等待)进 立即下载

相关推荐

硬件原理图:从软件思维到硬件接口的嵌入式开发破局指南

本文为软件开发者提供了读懂硬件原理图的嵌入式开发破局指南。文章将硬件原理图类比为“硬件系统的架构图”,引导读者将软件API调用思维迁移到硬件接口理解上,详细解析了电阻、电容、二极管等常见元器件的“硬件API”功能与选型逻辑,并通过实战电路拆解,阐述了从原理图分析到驱动代码编写的完整思维链条,帮助开发者建立软硬件协同的系统级视角。

lg888的博客 497

实现一个SORM基本框架

一、ORM介绍 ORM(Object-Relationl Mapping)对象关系映射,一种为了解决面向对象与关系数据库存在的互不匹配的现象的技术。它的作用是在关系型数据库和对象之间作一个映射,这样,我们在具体的操作数据库的时候,就不需要再去和复杂的SQL语句打交道,只要像平时操作对象一样操作它就可以了 。 基本思想: 表结构和类结构对应 表中字段属性和类的属性对应 表中的记录与对象对应 SO...

左耳依然的博客 1719

卡诺图化简法注意事项+竞争冒险知识点总结

今天反思以下卡诺图化简法中的注意事项。 卡诺图看起来简单,但如果不熟悉的话很容易出错,因此要对画圈的规则比较熟悉。

weixin_42415266的博客 1万+

基于元数据驱动的ETL

2016-07-03 朱洁    元数据的定义元数据(Metadata),为描述数据的数据(data about data),主要是描述数据属性(property)的信息,用来支持如指示存储位置、历史数据、资源查找、文件记录等功能。  ETL的定义 ETL,是英文 Extract-Transform-Load 的缩写,用来描述将数据从来源端经过抽取(extract)、...

人生重要的不是所站的位置,而是所朝的方向。 639

国产化软件设计:遵循信创要求,助力信息技术自主创新

支持国产操作系统、CPU、数据库和中间件。确保网络通信的身份鉴别、数据传输机密性和完整性。实现应用和数据层的身份鉴别、数据传输机密性完整性、数据存储机密性完整性。依托法院密码服务平台提供的商用密码能力。

qq_41186565的博客 3373

RT-Thread littefs控制GD32F4xx片内Flash

GD32F4xx RT-Thread下使用littefs 控制片内flash 调试记录

madao1234的博客 995

ASP.NET Core模型元数据:反射信息封装

在ASP.NET Core框架中,模型元数据(Model Metadata)是一个核心概念,它封装了类型反射信息,为模型绑定、验证、显示等场景提供统一的元数据抽象。本文将深入探讨ASP.NET Core模型元数据的设计原理、核心组件及其在实际开发中的应用。 ## 模型元数据核心架构 ### 核心接口与抽象类 ASP.NET Core模型元数据系统建立在几个核心接口和抽象类之上: ```cs...

gitblog_00718的博客 685

MNI152 坐标空间和 fsaverage 坐标空间相互转换, 如已知fsaverage空间的坐标如何求MNI152 坐标?aparc.a2009s.annot转化到MNI152空间?

大多数神经影像学研究的结果是在体积(例如,MNI152)或表面(例如,fsaverage)坐标系中报告的。体积坐标系和表面坐标系之间的准确映射可以促进许多应用,例如将 fMRI 组分析从 MNI152 投影到 fsaverage 以进行可视化或从 fsaverage 投影静息状态 fMRI 分区对 MNI152进行新数据的体积分析。Wu et al., 2018 评估了三种在 MNI152通过模拟上述应用的 Colin27 和 fsaverage 坐标系:将组平均数据从 MNI152/Colin27 投影到

从事脑科学核磁共振方法学研究,在Nature communications等权威期刊发表研究论文,熟练掌握磁共振处理方法和统计学方法,欢迎大家和我交流。 2968

ASP.NET Core模型元数据提供器:元数据定制

在ASP.NET Core MVC框架中,模型元数据(Model Metadata)是连接模型对象与视图渲染、数据验证、模型绑定等核心功能的关键桥梁。你是否曾经遇到过这样的场景: - 需要为特定属性自定义显示名称或描述信息? - 想要控制某个字段在表单中的渲染方式? - 需要根据运行时条件动态调整模型元数据? 这些需求都可以通过ASP.NET Core强大的模型元数据提供器(Model Met...

gitblog_00624的博客 704

CloudCompare 和 PCL:点云网格化分析与处理

点云网格化是将点云数据转化为规则网格的过程,其主要思想是将离散的点云投影到一个平面上,然后对该平面进行划分,形成一系列小区域。在点云网格化方面,PCL 提供了各种算法和工具,可以实现高效的点云网格化操作。以上示例代码中,首先加载了输入的点云数据,然后通过设置合适的网格化算法参数,如搜索半径和最大三角形边长等,执行了网格化操作,最后将网格化结果保存到输出文件中。以上示例代码中,首先加载了输入的点云数据,然后通过设置合适的网格化参数,如分辨率等,执行了网格化操作,最后将网格化结果保存到输出文件中。

TechPulseZ的博客 1296

Windows 11 WSL2环境下OpenClaw部署的兼容性问题分析与解决方案研究

本文研究了OpenClaw在Windows 11 WSL2环境下的部署方案。WSL2通过无缝集成Linux与Windows系统,为OpenClaw提供了良好的运行环境,支持GPU加速和跨平台开发。文章详细分析了硬件配置要求(推荐8核CPU/16GB内存/NVMe SSD)、系统选择(Windows 11 Pro+Ubuntu 22.04)以及部署步骤,包括WSL2启用、Linux发行版安装、Python/Node.js/Redis等依赖配置。通过优化.wslconfig文件参数(如内存分

博客 2284

关于ASP.NET和.NET的区别和联系

关于ASP.NET和.NET的区别和联系 对于一个新手,往往会被这些名字给搞蒙了,对不起(笨小孩我也被搞蒙过,见笑啦),这归根结底还是怪自己对知识掌握和了解的不够,废话不多,直接到主题。 ASP.NET和.NET的区别和联系 .NET 一般所说的.NET指的是.NET框架即为(.Net Framework),他是微软提供的开发平台框架,可以做以下事情 Windows

u012092924的博客 8186

C2000ware介绍

C2000的下载安装指南C2000目录。

小柚子的博客 2798

【笔记】ASP.NET MVC Model元数据

问题1:什么叫Model元数据?   Model元数据,是针对数据类型的一种描述信息。由于复杂类型(或者说类型嵌套的存在,比如CustomerModel中有一个属性为复杂类型Address)的存在,因此Model 元数据为树形结构: 1 //namespace:System.Web.Mvc 2 public class ModelMetadata 3 { 4 ...

diyunfang1930的博客 225

蓝牙模块HM-10手册

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

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

关于.NET、ASP.NET和ASP

发展历程 1996年,ASP 1.0(Active Server Pages,即ASP)版本出现了,它引起了Web开发的新革命,降低了动态网页开发的难度。以前开发动态网页需要编写大量繁杂的C代码,编程效率非常低下,而且需要Web网页开发者掌握非常高的编程技巧。而ASP使用简单的脚本语言,能够将代码直接嵌入HTML,使设计Web网页变得简单。 虽然ASP非常简单,但却能够实现非常强大的功能,这一切得益于其组件。特别是ADO组件,使得在网页中访问数据库易如反掌。这一切推动了动态网页的快速发展与建设,同时使A

荒唐的博客 3082

计算机控制技术及应用

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

ASP.NET MVC Model元数据(二)

在上篇中,给大家留个对Model元数据的印象,并没有对Model元数据有过多的讲解,而在本篇中也不会对Model元数据的本身来解释,而是针对于它的生成过程,让大家能够清楚的了解到系统框架是在什么时候生成Model元数据的,对于Model元数据生成篇幅初定为两篇,本篇为它的整体的生成过程,下篇则为详细的生成过程并且会对它本身做一个粗略的介绍,希望大家看完能够有所收获

金源 1840

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

ASP.NET Core 6.0 端点名称元数据变更解析

在ASP.NET Core 6.0的开发过程中,你是否遇到过这样的场景:精心设计的API端点突然无法被正确识别,路由匹配出现异常,或者Swagger文档显示不完整?这些问题很可能源于ASP.NET Core 6.0中对端点名称元数据(Endpoint Name Metadata)的重大变更。 传统的端点命名方式在复杂应用中逐渐暴露出局限性,特别是在微服务架构和API版本化管理中。ASP.NET ...

gitblog_00437的博客 485

ASP.NET应用技巧:非托管COM组件的使用

众所周知,asp.net是基于通用语言运行库创建的,也就是所谓的托管执行环境。生成的代码称为托管代码。编译器能够从源代码的描述中产生元数据信息,而运行库又从元数据中获得托管代码的信息。而我们编写的组件一般是在非托管环境下创建的,这些组件往往不包含元数据信息,那么我们怎么在托管代码

kafeiwuzhuren的专栏 568

ASP.NET MVC Model元数据(三)

在上篇中我们大概的讲解了Model元数据的生成过程,并没有对Model元数据本身和详细的生成过程有所描述,本篇将会对详细的生成过程进行讲解,并且会对Model元数据本身的结构稍作讲解,读完本篇过后你将会对Model元数据的结构有个很清晰的印象。

金源 1454
上一篇: 基于MVP架构设计ASP.Net的应用研究
下一篇: Visual Studio 2008和ASP.NET 3.5的最新技术探索
Developernet
博客等级 码龄22年 324粉丝 52原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值