刀兄写的IIS管理类(C#)

C#开发通用类_配置文件帮助类 配置文件也是每个项目中离不开的选项,基本上或多或少都会在配置中写入一些项目自定义的东西,甚至有些多站点管理的,要求去动态更改配置文件,重启IIS站点让其热部署生效;微软已经提供了Config内的配置相关操作,然而我们还是对其进行了一系列的封装; using System.Configuration; /// <summary> /// 配置文件帮助类 /// </summary> public class ConfigHelperUtil { 阅读详情

///***********************************************************  

  ///************** IIS控制管理类 1.0 Beta **************  

  ///************** Author: 飞刀 **************  

  ///************** http://www.aspcn.com **************  

  ///************** feidao@aspcn.com **************  

  ///***********************************************************  

using System;  

using System.Data;  

using System.DirectoryServices;  

using System.Collections;  

namespace Aspcn.Management  

{  

     /// <summary>  

     /// IISManager 的摘要说明。  

     /// </summary>  

     public class IISManager  

     {  

         //定义需要使用的  

          private string _server,_website;  

          private VirtualDirectories _virdirs;  

          protected System.DirectoryServices.DirectoryEntry rootfolder;  

          private bool _batchflag;  

         public IISManager()  

         {  

              //默认情况下使用localhost,即访问本地机  

              _server = "localhost";  

              _website = "1";  

              _batchflag = false;  

         }  

         public IISManager(string strServer)  

         {  

              _server = strServer;  

              _website = "1";  

              _batchflag = false;  

         }  

         /// <summary>  

         /// 定义公共属性  

         /// </summary>  

    

          //Server属性定义访问机器的名字,可以是IP与计算名  

         public string Server  

         {  

              get{ return _server;}  

              set{ _server = value;}  

         }  

          //WebSite属性定义,为一数字,为方便,使用string  

         //一般来说第一台主机为1,第二台主机为2,依次类推  

         public string WebSite  

         {  

              get{ return _website; }  

              set{ _website = value; }  

         }  

    

         //虚拟目录的名字  

         public VirtualDirectories VirDirs  

         {  

              get{ return _virdirs; }  

              set{ _virdirs = value;}  

         }  

          ///<summary>  

         ///定义公共方法  

          ///</summary>  

    

         //连接服务器  

         public void Connect()  

         {  

              ConnectToServer();  

         }  

         //为方便重载  

         public void Connect(string strServer)  

         {  

              _server = strServer;  

              ConnectToServer();  

         }  

         //为方便重载  

         public void Connect(string strServer,string strWebSite)  

         {  

              _server = strServer;  

              _website = strWebSite;  

              ConnectToServer();  

         }  

         //判断是否存这个虚拟目录  

         public bool Exists(string strVirdir)  

         {  

              return _virdirs.Contains(strVirdir);  

         }  

         //添加一个虚拟目录  

         public void Create(VirtualDirectory newdir)  

         {  

              string strPath = "IIS://" + _server + "/W3SVC/" + _website + "/ROOT/" + newdir.Name;  

              if(!_virdirs.Contains(newdir.Name) || _batchflag )  

              {  

                   try  

                   {  

                       //加入到ROOT的Children集合中去  

                        DirectoryEntry newVirDir = rootfolder.Children.Add(newdir.Name,"IIsWebVirtualDir");  

                        newVirDir.Invoke("AppCreate",true);  

                        newVirDir.CommitChanges();  

                        rootfolder.CommitChanges();  

                       //然后更新数据  

                        UpdateDirInfo(newVirDir,newdir);  

                   }  

                   catch(Exception ee)  

                   {  

                       throw new Exception(ee.ToString());  

                   }  

              }  

              else  

              {  

                   throw new Exception("This virtual directory is already exist.");  

              }  

         }  

         //得到一个虚拟目录  

         public VirtualDirectory GetVirDir(string strVirdir)  

         {  

              VirtualDirectory tmp = null;  

              if(_virdirs.Contains(strVirdir))  

              {  

                   tmp = _virdirs.Find(strVirdir);  

                   ((VirtualDirectory)_virdirs[strVirdir]).flag = 2;  

              }  

              else  

              {  

                   throw new Exception("This virtual directory is not exists");  

              }  

              return tmp;  

         }  

    

         //更新一个虚拟目录  

         public void Update(VirtualDirectory dir)  

         {  

              //判断需要更改的虚拟目录是否存在  

              if(_virdirs.Contains(dir.Name))  

              {  

                   DirectoryEntry ode = rootfolder.Children.Find(dir.Name,"IIsWebVirtualDir");  

                   UpdateDirInfo(ode,dir);  

              }  

              else  

              {  

                   throw new Exception("This virtual directory is not exists.");  

              }  

         }  

     

         //删除一个虚拟目录  

         public void Delete(string strVirdir)  

         {  

              if(_virdirs.Contains(strVirdir))  

              {  

                   object[] paras = new object[2];  

                   paras[0] = "IIsWebVirtualDir"; //表示操作的是虚拟目录  

                   paras[1] = strVirdir;  

                   rootfolder.Invoke("Delete",paras);  

                   rootfolder.CommitChanges();  

              }  

              else  

              {  

                   throw new Exception("Can''t delete " + strVirdir + ",because it isn''t exists.");  

              }  

         }  

         //批量更新  

         public void UpdateBatch()  

         {  

              BatchUpdate(_virdirs);  

         }  

         //重载一个:-)  

         public void UpdateBatch(VirtualDirectories vds)  

         {  

              BatchUpdate(vds);  

         }  

     

          ///<summary>  

         ///私有方法  

          ///</summary>  

    

         //连接服务器  

          private void ConnectToServer()  

         {  

              string strPath = "IIS://" + _server + "/W3SVC/" + _website +"/ROOT";  

              try  

              {  

                   this.rootfolder = new DirectoryEntry(strPath);  

                   _virdirs = GetVirDirs(this.rootfolder.Children);  

              }  

              catch(Exception e)  

              {  

                   throw new Exception("Can''t connect to the server ["+ _server +"] ...",e);  

              }  

         }  

         //执行批量更新  

          private void BatchUpdate(VirtualDirectories vds)  

         {  

              _batchflag = true;  

              foreach(object item in vds.Values)  

              {  

                   VirtualDirectory vd = (VirtualDirectory)item;  

                   switch(vd.flag)  

                   {  

                       case 0:  

                            break;  

                       case 1:  

                            Create(vd);  

                            break;  

                       case 2:  

                            Update(vd);  

                            break;  

                   }  

              }  

              _batchflag = false;  

         }  

         //更新东东  

          private void UpdateDirInfo(DirectoryEntry de,VirtualDirectory vd)  

         {  

              de.Properties["AnonymousUserName"][0] = vd.AnonymousUserName;  

              de.Properties["AnonymousUserPass"][0] = vd.AnonymousUserPass;  

              de.Properties["AccessRead"][0] = vd.AccessRead;  

              de.Properties["AccessExecute"][0] = vd.AccessExecute;  

              de.Properties["AccessWrite"][0] = vd.AccessWrite;  

              de.Properties["AuthBasic"][0] = vd.AuthBasic;  

              de.Properties["AuthNTLM"][0] = vd.AuthNTLM;  

              de.Properties["ContentIndexed"][0] = vd.ContentIndexed;  

              de.Properties["EnableDefaultDoc"][0] = vd.EnableDefaultDoc;  

              de.Properties["EnableDirBrowsing"][0] = vd.EnableDirBrowsing;  

              de.Properties["AccessSSL"][0] = vd.AccessSSL;  

              de.Properties["AccessScript"][0] = vd.AccessScript;  

              de.Properties["DefaultDoc"][0] = vd.DefaultDoc;  

              de.Properties["Path"][0] = vd.Path;  

              de.CommitChanges();  

         }  

    

         //获取虚拟目录集合  

          private VirtualDirectories GetVirDirs(DirectoryEntries des)  

         {  

              VirtualDirectories tmpdirs = new VirtualDirectories();  

              foreach(DirectoryEntry de in des)  

              {  

                   if(de.SchemaClassName == "IIsWebVirtualDir")  

                   {  

                        VirtualDirectory vd = new VirtualDirectory();  

                        vd.Name = de.Name;  

                        vd.AccessRead = (bool)de.Properties["AccessRead"][0];  

                        vd.AccessExecute = (bool)de.Properties["AccessExecute"][0];  

                        vd.AccessWrite = (bool)de.Properties["AccessWrite"][0];  

                        vd.AnonymousUserName = (string)de.Properties["AnonymousUserName"][0];  

                        vd.AnonymousUserPass = (string)de.Properties["AnonymousUserName"][0];  

                        vd.AuthBasic = (bool)de.Properties["AuthBasic"][0];  

                        vd.AuthNTLM = (bool)de.Properties["AuthNTLM"][0];  

                        vd.ContentIndexed = (bool)de.Properties["ContentIndexed"][0];  

                        vd.EnableDefaultDoc = (bool)de.Properties["EnableDefaultDoc"][0];  

                        vd.EnableDirBrowsing = (bool)de.Properties["EnableDirBrowsing"][0];  

                        vd.AccessSSL = (bool)de.Properties["AccessSSL"][0];  

                        vd.AccessScript = (bool)de.Properties["AccessScript"][0];  

                        vd.Path = (string)de.Properties["Path"][0];  

                        vd.flag = 0;  

                        vd.DefaultDoc = (string)de.Properties["DefaultDoc"][0];  

                        tmpdirs.Add(vd.Name,vd);  

                   }  

              }  

              return tmpdirs;  

         }  

    

     }  

     /// <summary>  

     /// VirtualDirectory类  

     /// </summary>  

     public class VirtualDirectory  

     {  

          private bool _read,_execute,_script,_ssl,_write,_authbasic,_authntlm,_indexed,_endirbrow,_endefaultdoc;  

          private string _ausername,_auserpass,_name,_path;  

          private int _flag;  

          private string _defaultdoc;  

         /// <summary>  

         /// 构造函数  

         /// </summary>  

         public VirtualDirectory()  

         {  

              SetValue();  

         }  

         public VirtualDirectory(string strVirDirName)  

         {  

              _name = strVirDirName;  

              SetValue();  

         }  

          private void SetValue()  

         {  

              _read = true;_execute = false;_script = false;_ssl= false;_write=false;_authbasic=false;_authntlm=false;  

              _indexed = false;_endirbrow=false;_endefaultdoc = false;  

              _flag = 1;  

              _defaultdoc = "default.htm,default.aspx,default.asp,index.htm";  

              _path = "C://";  

              _ausername = "";_auserpass ="";_name="";  

         }  

          ///<summary>  

         ///定义属性,IISVirtualDir太多属性了  

         ///我只搞了比较重要的一些,其它的大伙需要的自个加吧。  

          ///</summary>  

    

         public int flag  

         {  

              get{ return _flag;}  

              set{ _flag = value;}  

         }  

         public bool AccessRead  

         {  

              get{ return _read;}  

              set{ _read = value;}  

         }  

         public bool AccessWrite  

         {  

              get{ return _write;}  

              set{ _write = value;}  

         }  

         public bool AccessExecute  

         {  

              get{ return _execute;}  

               set{ _execute = value;}  

         }  

         public bool AccessSSL  

         {  

              get{ return _ssl;}  

              set{ _ssl = value;}  

         }  

         public bool AccessScript  

         {  

              get{ return _script;}  

              set{ _script = value;}  

         }  

         public bool AuthBasic  

         {  

              get{ return _authbasic;}  

              set{ _authbasic = value;}  

         }  

         public bool AuthNTLM  

         {  

              get{ return _authntlm;}  

              set{ _authntlm = value;}  

         }  

         public bool ContentIndexed  

         {  

              get{ return _indexed;}  

              set{ _indexed = value;}  

         }  

         public bool EnableDirBrowsing  

         {  

              get{ return _endirbrow;}  

              set{ _endirbrow = value;}  

         }  

         public bool EnableDefaultDoc  

         {  

              get{ return _endefaultdoc;}  

              set{ _endefaultdoc = value;}  

         }  

         public string Name  

         {  

              get{ return _name;}  

              set{ _name = value;}  

         }  

         public string Path  

         {  

              get{ return _path;}  

              set{ _path = value;}  

         }  

         public string DefaultDoc  

         {  

              get{ return _defaultdoc;}  

               set{ _defaultdoc = value;}  

         }  

         public string AnonymousUserName  

         {  

              get{ return _ausername;}  

              set{ _ausername = value;}  

         }  

         public string AnonymousUserPass  

         {  

              get{ return _auserpass;}  

              set{ _auserpass = value;}  

         }  

     }  

     /// <summary>  

     /// 集合VirtualDirectories  

     /// </summary>  

    

     public class VirtualDirectories : System.Collections.Hashtable  

     {  

         public VirtualDirectories()  

         {  

         }  

         //添加新的方法  

         public VirtualDirectory Find(string strName)  

         {  

              return (VirtualDirectory)this[strName];  

         }  

     }  

}

基于C#的IIS多站点管理源码解析与应用 本文还有配套的精品资源,点击获取 简介:IIS是微软的Web服务器,支持在同一台服务器上运行多个独立网站。本文档深入介绍了一个使用C#编写的IIS多站点管理系统源码,包括站点的创建、停止、删除和重启操作。源码利用了.NET框架的System.DirectoryServices.Protocols和System.Management命名空间下的API,允许开发者进行IIS的编... 阅读详情

相关推荐

C#IIS管理器(开源) IISManager

C#IIS管理器(开源) IISManager 本人收藏了3年的资源 现放出 都是总结了很多系统 软件项目实施过程中的经验的 慢慢积累的

用C# 代码咋管理IIS呢?

通常来说网站管理工具可以完成一些不通过IIS就可以在Windows服务器上创建网站,创建应用程序池,绑定域名,建立虚拟目录,应用程序等,以及数据库的相关管理工作,这样的工具就是方便小白用户管理网站。

网络大杂烩 879

C# IIS自动部署工具及源码

利用C#语言实现的IIS自动部署工具及源码,请使用的时候以管理员的身份打开。

C# IIS应用程序池辅助类 分类: C# Help...

using System.Collections.Generic; using System.DirectoryServices; using System.Linq; using Microsoft.Web.Administration;//位于:C:\Windows\System32\inetsrv\Microsoft.Web.Administration.dll namespace...

weixin_34167819的博客 197

C#IIS管理器(开源)

C#IIS管理器(开源),对IIS创建,删除站点,虚拟目录

用ASP.NET管理IIS站点,源码提供

通过ASP.NET 2.0(C#)管理IIS站点。可以通过ASP.NET页面添加删除修改IIS站点,就像在IIS管理器当中单击属性一样。主要用于虚拟主机提供商的客户通过WEB管理自己的网站。主要技术是用了ASP.NET的身份模拟技术,App_Code/imp.cs构造函数中的用户名和密码是对应当前操作系统的管理员用户名和密码。代码粗糙简单,仅供参考交流。

Asp.net操作IIS(调试通过)

本程序调用刀兄写的IIS管理类(C#),完成虚拟目录的添加删除判断虚拟目录是否存在刀兄写的IIS管理类(C#)代码:///*********************************************************** ///************** IIS控制管理类 1.0 Beta ************** ///************** ...

weixin_30396699的博客 110

AI算力网络与通信领域流量分析:优化策略探讨_副本

今天的AI就像一个"超级吃货",每天要"吃"掉海量数据、“消耗"巨量算力——训练一个千亿参数的大模型,可能需要上万块GPU同时工作数周,其间产生的数据传输量足以填满数百万个1TB硬盘。这些GPU和计算节点通过网络连接形成"AI算力网络”,而数据在节点间的流动就是"通信流量"。如果把算力比作AI的"肌肉",那流量就是"血液"——血液不通畅,肌肉再强也使不上劲。

AI天才研究院 1199

使用C#操作IIS7的辅助类

using Microsoft.Web.Administration; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace BaseUtil {     public clas

马立弘 1181

SCS 43. 利用Scissor算法从单细胞数据中挖掘临床表型关联的细胞亚群

本文详细介绍了Scissor算法在单细胞转录组数据分析中的应用,该算法能够精准挖掘与临床表型关联的细胞亚群。通过建立单细胞RNA测序数据与临床预测模型的直接关联,Scissor避免了传统聚类方法的局限性,为疾病机制研究和个性化医疗提供了新工具。文章还涵盖了数据预处理、模型选择、结果验证等实战技巧。

weixin_28736335的博客 493

手把手教你用运放和基准源,把±10V信号变成ADC能吃的0-4V(附完整计算过程)

本文详细介绍了如何利用OP07运放和REF5040基准源设计工业级信号调理电路,将±10V传感器信号转换为0-4V ADC可接受范围。通过七步流程,包括需求分析、元器件选型、电路设计、理论计算、PCB布局、实测验证与性能优化,帮助工程师解决信号不匹配问题,提升系统精度与稳定性。

weixin_28731223的博客 468

C# 操作IIS方法集合

如果在win8,win7情况下报错:未知错误(0x80005000) 见http://blog.youkuaiyun.com/ts1030746080/article/details/8741399     using System; using System.Collections; using System.Collections.Generic; using System.Direct...

weixin_34341229的博客 158

UG\NX二次开发 获取对象的引用集

获取对象的引用集,一个对象可能有多个引用集,下面这个封装函数可以获取对象的所有引用集。

王牌飞行员_里海的博客 489

asp.net,IIS控制管理类(c#)(一)

using System;using System.DirectoryServices;namespace Com.Net{ ///  /// IISUtil 的摘要说明。 ///*********************************************************** ///************** IIS控制管理类 ************** ///***

帽子Lee的专栏 689

YOLOv8改进 | 融合篇,YOLOv8改进主干网络为MobileNetV3+CA注意机制+添加小目标检测层(全网独家首发,实现极限涨点)

小目标检测难点众多,导致很多算法对小目标的检测效果远不如大中型目标。影响算法性能的主要原因如下:第一,小目标分辨率低、信息量不足,导致神经网络提取到的有效特征较少。第二,小目标在图像中所占的区域较小,易受背景干扰,这对算法的定位性能要求较高。第三,小物体标注困难,训练数据有限,导致模型泛化能力差。例如多尺度学习、无锚机制和生成对抗学习等方法,都能提高小目标检测的准确性和鲁棒性。为了改善小目标漏检现象严重的问题,我在 YOLOv8 中增加了 P2 检测头,相当于有四个检测头,使网络能检测到更小的目标。

在职AI算法工程师,擅长计算机视觉,YOLO目标检测、分割等,擅长web、pyqt界面可视化,好内容持续更新中,来这里跟大家一起学习,共同进步 2858

fast-lio运行步骤(使用velodyne数据)

使用fast-lio运行velodyne数据

ericdowney 4769

第6章第4节:自定义分词器

本节详解Elasticsearch自定义分词器,解析analyzer三段式结构(char_filter→tokenizer→filter),掌握常用组件如ik_max_word、synonym_graph、ngram等。通过_analyze API调试分词效果,实现“索引时扩展同义词、搜索时不带”的生产级方案,提升中文搜索与智能提示体验。

啊渊的专栏 781

银行统一监管报送系统

依据《银行业金融机构数据治理指引》,银行业金融机构应当建立适应监管数据报送工作需要的信息系统,实现流程控制的程序化,提高监管数据加工的自动化程度。银行业金融机构应当将监管数据纳入数据治理,建立工作机制和流程,确保监管数据报送工作有效组织开展,监管数据质量持续提升。银行通常要对接报送EAST5.0、1104、CRSS等近40个监管应用,涉及近1000张报表。表13-01是主要的监管报送应用、报送依据、报送规范、监管机构名称。

银行信息系统应用架构详解 4350

C#使用opencv和Yolo模型识别车牌号

本文基于OpenCVSharp与OnnxRuntime,结合YoloV8n-pose_plate模型(检测车牌位置)和OCR模型(识别车牌文字),实现高效车牌识别。通过预处理、目标检测、NMS筛选及文字识别流程,最终输出车牌框位置与识别文本。代码封装良好,支持自定义路径与置信度阈值,具备实际应用价值。

lweiyue的专栏 185

【用unity实现100个游戏之1】制作类元气骑士、挺进地牢——俯视角射击游戏多种射击效果(二)(附源码)

这篇文章我们将继续实现曲线射击与两种不需要实体子弹的射击方式 源码在文章末尾。

向宇的博客,专注php/web全栈 unity游戏开发,欢迎大家评论纠错 5061

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

C# NAFNet 图片去模糊

基于NAFNet与ONNX Runtime的C# WinForms图片去模糊工具,支持DirectML GPU加速与CPU回退,实现一键去模糊、大图分块处理、并排对比及拖拽打开。具备高DPI适配、自绘圆角界面、命令行批量处理等功能,适用于Windows 10/11系统,可灵活配置模型路径与分块大小,解决显存不足与边缘接缝问题。

hixiong123的博客 263

IEM模型,地表粗糙度模拟

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

使用C#代码提取、修改或删除 Excel 中的超链接

通过 C# 和 VB.NET,可以方便地管理 Excel 文件中的超链接,包括提取、修改和删除等操作。提取超链接: 获取工作表中的超链接集合,读取每个超链接的地址和类型,并将相关信息保存到文本文件中。修改超链接: 更新超链接的显示文本和目标地址,确保链接信息准确。删除超链接: 移除指定的超链接,同时可以选择保留单元格中的原有显示文本,或清除单元格的全部内容。这些操作可以帮助开发人员更高效地管理 Excel 文档中的链接信息,减少重复的手动操作,也便于在数据迁移、文档维护和自动化报表处理等场景中使用。

2501_93070778的博客 238

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

C#: 控件不支持透明的背景色

把透明度固定为255。

海天鹰 49
上一篇: 一段找出URL的代码(C#)
下一篇: 索引服务调用代码(C#)
iwebsms
博客等级 码龄22年 5粉丝 50原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值