深入了解 Microsoft.VisualBasic.Strings.StrConv 简繁转换

C#调用VB进行简繁转换的方法 本文实例讲述了C#调用VB进行简繁转换的方法。分享给大家供大家参考。具体分析如下: 首先在C#项目中引用Microsoft.VisualBasic.dll,版本自己选择合适的 然后在项目中添加引用:using Microsoft.VisualBasic; 转换: 转为繁体: outputText=Strings.StrConv(txt待转换文本, VbStrConv.TraditionalChinese); 转为简体: outputText=Strings.StrConv(txt待转换文本, VbStrConv.SimplifiedChinese); 另外还可以进行全角与半角转换,平假名 立即下载

转自:http://sanchen.blogspot.com/2007/12/microsoftvisualbasicstringsstrconv.html

 

 

 

先來觀察 Strings.StrConv 方法的簽名:

public static string StrConv(string str, VbStrConv Conversion, [Optional, DefaultParameterValue(0)] int LocaleID)

第三個參數和 MSDN 上的文件有點不同, 上面的簽名是從 Reflector 中摘出來的, 也是這篇文章要記錄的重點, 先來看一些範例:

    a1 = Strings.StrConv("书樂う반", VbStrConv.TraditionalChinese, 0x0404);    // a1 = "?樂??"
    a2 = Strings.StrConv("书樂う반", VbStrConv.SimplifiedChinese, 0x0404);     // a2 = "????"

    b1 = Strings.StrConv("书樂う반", VbStrConv.TraditionalChinese, 0x0804);    // b1 = "書樂う?"
    b2 = Strings.StrConv("书樂う반", VbStrConv.SimplifiedChinese, 0x0804);     // b2 = "书乐う?"

    c1 = Strings.StrConv("书樂う반", VbStrConv.TraditionalChinese, 0x0412);    // c1 = "?樂う반"
    c2 = Strings.StrConv("书樂う반", VbStrConv.SimplifiedChinese, 0x0412);     // c2 = "??う반"

    d1 = Strings.StrConv("书樂う반", VbStrConv.TraditionalChinese, 0x0009);    // d1 = "書樂う반"
    d2 = Strings.StrConv("书樂う반", VbStrConv.SimplifiedChinese, 0x0009);     // d2 = "书乐う반"

上面 8 個範例的第一個參數摻雜了簡中、繁中、日文和韓文, 第二個參數區分了轉簡體和轉繁體, 第三個參數是 localeID 的部分, 分別包含了 zh-TW (0x0404), zh-CN (0x0840), ko-KR (0x0412), en (0x0009), 讓我們來仔細觀察一下結果, 一切的玄機都在第三個 localeID 參數身上. 我們先假設第三個參數 localeID 是用來表示來源字串的字集, 所以如果這個假設成立的話..., 來看看結果:

  1. a1: 嗯, 一切如預期的結果, 第一步應該先將 "书樂う반" 轉成符合 zh-TW (0x0404) 的字集, 所以結果是 "?樂??", 然後再根據第二個參數 VbStrConv.TraditionalChinese 結果變成了 "?樂??", 正確!
  2. a2: 第一步同上, 然後再根據第二個參數 VbStrConv.SimplifiedChinese 結果應該要變成 "?乐??", 可是 a2 的結果卻得到了 "????", 不如預期!
  3. b1: 第一步應該先將 "书樂う반" 轉成符合 zh-CN 的字集, 所以結果是 "书樂う?", (簡體字集是有包含繁體形態 "樂" 這個字的), 第二個參數 VbStrConv.TraditionalChinese, 所以結果變成 "書樂う?", 正確!
  4. b2: 正確!
  5. c1: 韓文字集不太了解, 從結果推測韓文的漢字集如果沒有 "书" 這個字的話, 結果應該算是正確的!
  6. c2: 從 c1 的結果本來預期應該得到 "?乐う반", 可是結果卻是 "??う반", 不如預期!
  7. d1: 咦!!! 怎麼會這樣, 完全不如預期, 竟然得到如此漂亮的結果, 本來預期是 4 個 "?" 的!!!
  8. d2: 一樣得到令人搞不清楚為什麼美麗結果!!!

這到底是怎麼一回事? 是假設錯誤嗎? 可是還有什麼別的可能嗎? 為了解開這個謎團, 於是又祭出了殺手工具 "Reflector", 仔細觀察了 Microsoft.VisualBasic.dll 內的程式碼, 終於了解箇中奧秘!

先來看一下 StrConv 方法反向工程之後的一小部分程式碼(還沒到重點, 所以只節錄最後幾行),

image

再來追進 vbLCMapString 看一看, 也是看下半部就行了:

image

橘黃色是和 Encoding 相關的程式碼, 綠色和紅色底線的部分是 Win32 API 用來處理字碼轉換的函式, 綠色底線的函式有一個後綴字 A, 而且輸入的參數是 byte[], 而紅色底線部分的函式則沒有後綴字, 輸入的參數是 string.

看到這兒, 答案已經呼之欲出了, 之所以結果會不如預期都是因為 encoding.GetBytes() 和 encoding.GetString() 這兩個方法給弄砸的, 如果可以跳過它們直接叫用底下畫紅線的 UnsafeNativeMethods.LCMapString 的話, 就不會有那些討厭的問號產生了, 那要怎麼樣才能避過那段我們不想要的程式碼呢? 看一下那個底下有畫虛線的部分 "encoding.IsSingleByte", 嗯! 沒錯, 這就是為什麼 d1, d2 的結果這麼令人驚訝的原因了, 因為 en 的 Encoding 就是 SingleByte 所以會直接跳過 Unicode 和 MBCS 互轉的部分, 而直接進行 Unicode 的轉碼, 於是得到美麗的答案, 整個過程分析完畢!

雖然已經知道整個來龍去脈, 但是如果能再了解一下那個神奇的 Win32API: LCMapString 的話, 想必觀念又可以再更清楚一些. 所以我們再來看看 LCMapString 的重點吧! 嗯~~重點在哪兒咧? 以此篇文章的需求 "簡繁轉換" 來看的話, 只有第二個參數 dwMapFlags 值得我們注意, 打開 MSDN 的文件, 透過索引找到 LCMapString 的章節, 我們可以看到以下的內容,

image

針對 Windows NT 4.0 以後的作業系統, Microsoft 已經早就幫程式設計師們準備好了一個現成的系統函式來達成簡繁轉換的工作了(唉! 為什麼沒有早點知道!), 看你是要轉簡體 (LCMAP_SIMPLIFIED_CHINESE), 或是轉繁體 (LCMAP_TRADITIONAL_CHINESE), 只要給個參數, 一切就搞定了, 就是這麼簡單!

 

結論

如果您的需求和我一樣, 只是想把文字內容的簡繁部分轉換, 並不是想轉成 big5 或 gb, 整個輸出入都是 unicode, 而且也不想破壞其他非簡繁文字部分的話, 那麼結論就是照著本篇文章的一開始的 d1, d2 範例呼叫 VB 的 Strings.StrConv 帶上 0x0009 或是其他 SingleByte 字集的 localeID 當成第三個參數就可以啦!!!

如果不想引入 Microsoft.VisualBasic.dll (別問為什麼, 純屬個人偏好) 又想要做到相同的效果, 做法也很簡單, 請參考以下的範例程式碼!!!

public static class ChineseStringUtility
{
    internal const int LOCALE_SYSTEM_DEFAULT = 0x0800;
    internal const int LCMAP_SIMPLIFIED_CHINESE = 0x02000000;
    internal const int LCMAP_TRADITIONAL_CHINESE = 0x04000000;

    [DllImport("kernel32", CharSet = CharSet.Auto, SetLastError = true)]
    internal static extern int LCMapString(int Locale, int dwMapFlags, string lpSrcStr, int cchSrc, [Out] string lpDestStr, int cchDest);

    public static string ToSimplified(string source)
    {
        String target = new String(' ', source.Length);
        int ret = LCMapString(LOCALE_SYSTEM_DEFAULT, LCMAP_SIMPLIFIED_CHINESE, source, source.Length, target, source.Length);
        return target;
    }

    public static string ToTraditional(string source)
    {
        String target = new String(' ', source.Length);
        int ret = LCMapString(LOCALE_SYSTEM_DEFAULT, LCMAP_TRADITIONAL_CHINESE, source, source.Length, target, source.Length);
        return target;
    }
}

 

簡繁體互換

转自:http://charlesbc.blogspot.com/2007/03/wq.html

 

這個在 dotnet 上,需籍用 Microsort.VisualBasic.dll 的力量了
using Microsoft.VisualBasic;

string str = "中國"; str = Strings.StrConv(str, VbStrConv.SimplifiedChinese, 2052);
MessageBox.Show(str); //簡體的中國
str = Strings.StrConv(str, VbStrConv.TraditionalChinese, 1033);
MessageBox.Show(str); //繁體的中國

請參考 String.StrConv 的 msdn 說明
注意到:
第一個參數是待轉換的字串
第二個參數欲轉換成字體列舉值 (enum)
第三個參數(重要),是文字轉換完後,最後對應的編碼格式 (LocaleID)

1028 繁體中文
1033 ASCII
2052 簡體中文

為何第二次轉換回繁體時,不用 1028 而用 1033 呢?
首先,要先知道,有些簡體中文的編碼值是在繁體中文是對應不到任何字的。此時,顯示的字就會是 "?" 號。
因為 2052 的 「 国] 已經是簡體字了,轉回到繁體時,剛好其編碼對應不到1028 的編碼,因此會是問號。

最好的方法,是以 en-US 做為編碼格式。當以 en-US 做為最後的編碼格式時,又碰到亞洲字時,就會以 unicode 做為儲存編碼格式。此剛好與 dotnet 的 string 儲存格式相同。因此解決了所有問題。

因此,當我們在做簡繁轉換時,請將第三個參數都設成 1033

 

string str = "中國";
str = Strings.StrConv(str, VbStrConv.SimplifiedChinese, 1033);
Console.WriteLine(str); //簡體的中國
str = Strings.StrConv(str, VbStrConv.TraditionalChinese, 1033);
Console.WriteLine(str); //繁體的中國

str = Strings.StrConv(str, VbStrConv.SimplifiedChinese, 2052);
Console.WriteLine(str); //簡體的中國
str = Strings.StrConv(str, VbStrConv.TraditionalChinese, 2052);
Console.WriteLine(str); //繁體的中國

str = Strings.StrConv(str, VbStrConv.SimplifiedChinese, 1028);
Console.WriteLine(str); //簡體的中?
str = Strings.StrConv(str, VbStrConv.TraditionalChinese, 1028);
Console.WriteLine(str); //繁體的中?

深度学习优化算法解析(Momentum, RMSProp, Adam) 之前看了很多人介绍网络的优化器optimizer,无奈很多都把简单的东西讲的复杂化了,不容易让人懂,恰好之前看过吴恩达老师的最新的课程,这里结合老师讲的和个人想法写一下,方便别人同时也为自己以后回顾吧。 深度学习的优化算法主要有GD,SGD,Momentum,RMSProp和Adam算法吧,还有诸如Adagrad算法,不过大同小异,理解了前面几个,后面的也就引刃而解了。GD算法,SGD算法以及m 阅读详情

相关推荐

高速PCB设计中串扰的成因、影响与实战控制策略

在高速数字电路与硬件系统设计中,信号完整性是确保系统稳定可靠的核心基础。其核心原理在于,当信号在传输线上传播时,会伴随产生电场与磁场,若相邻导线距离过近,便会通过电磁场耦合产生不期望的能量转移,即串扰。这一现象会直接导致信号波形畸变、时序偏移和噪声裕量降低,严重影响系统性能。从技术价值看,深入理解并有效控制串扰,是提升数据传输速率、保障系统稳定性和降低误码率的关键。其应用场景广泛覆盖了从高速SerDes链路、DDR内存接口到高精度模拟电路等几乎所有现代电子系统。本文聚焦于高速PCB设计中的串扰问题,系统剖析

weixin_27625589的博客 576

数据库简繁转换

转换要求: 1、数据库表必须有主键 2、表之间有外键关系会报错 3、VS手动添加对Microsoft.VisualBasic的引用 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Syst

风轻云断的博客 1493

交通银行金融科技后端开发实习生面试经验

笔试之路的第一个脚印。不足的地方:基本功不扎实,得补。先补sql(先整理出一篇sql语句做题的文章,争取下次笔试拿下这一块),编程题中的SQL写不出来感觉很丢人。然后补八股文,结合一些网上项目教程,来理解常用的一些八股文(比如各种锁)。

T__TSZ的博客 1728

C#简体/繁体 互转

1、添加Microsoft.VisualBasic引用。 2、using Microsoft.VisualBasic; 简体转繁体:return Microsoft.VisualBasic.Strings.StrConv(简体 as String, Microsoft.VisualBasic.VbStrConv.TraditionalChinese, 0); 繁体转简体:r

477

篮球比赛24秒计时器改造指南:用Multisim实现可调式倒计时系统

本文详细介绍了如何使用Multisim软件改造篮球比赛24秒计时器,实现可调式倒计时系统。从脉冲信号发生器到声光报警模块,提供了完整的电路设计方案和调试技巧,帮助开发者快速掌握数字电路设计的核心原理,提升体育电子设备开发效率。

wood5的博客 211

泛微Ecology流程数据表结构解析:workflow_requestbase和workflow_currentoperator到底怎么关联查询?

本文深入解析泛微Ecology系统中workflow_requestbase和workflow_currentoperator表的结构与关联机制,提供SQL查询语句示例,帮助开发者高效查询流程数据。涵盖待办事项、已办事项、办结事项和流程监控等典型场景,并分享性能优化技巧和常见问题排查指南。

weixin_33738555的博客 812

C#使用Strings.StrConv进行简繁体转换

C#中StrConv的使用学习日记   熟悉VB的人都了解StrConv的功能,它可以实现字符的转化,如可以转化为半角或者全角、在VB.net中更是增加简繁体互相转换。  C#本身没提供这个函数的数据。似乎也没有提供类似的函数功能,只能使用Encode进行转化。  以下就介绍一下,如何使用C#调用StrConv函数。   1、命名空间:Microsoft.VisualBasic

hanfon的专栏 5843

从零开始:使用COLMAP与OpenMVS构建高精度三维Mesh模型

本文为零基础新手提供了使用COLMAP与OpenMVS构建高精度三维Mesh模型的完整实战指南。详细介绍了从环境配置、数据采集黄金法则,到COLMAP稀疏与稠密重建、OpenMVS网格生成与纹理映射的每一步操作,并分享了关键的避坑技巧与参数调优建议,帮助读者从二维照片中成功重建出属于自己的三维模型。

metal的博客 505

關於Micrsoft.VisualBasic.dll中Strings.StrConv的第三個參數LocaleID引起的問題

選上代碼: Code 1privatevoidbutton1_Click(objectsender,EventArgse) 2{ 3if(textBox1.Text=="") 4{ 5MessageBox.Show("請填入要轉換的文字","提示"); 6...

weixin_30621711的博客 227

GB28181 —— 1、Ubuntu20.04下使用ZLMediaKit+WVP搭建GB28181流媒体监控平台(连接带云台摄像机)

GB28181 —— Ubuntu20.04下使用ZLMediaKit+WVP搭建GB28181流媒体监控平台

5462

【CSP-S 提高组】考试大纲集合

【CSP-S提高组】考试大纲集合

weixin_42596089的博客 7255

C# 文字转换最简单的方法

引用Microsoft.VisualBasic string text=Strings.StrConv("需要转换的文字", VbStrConv.TraditionalChinese, 1); VbStrConv 枚举 转载于:https://www.cnblogs.com/codeyou/p/4956427.html...

a19790318的博客 188

保姆级YOLOv8改进 | 基于DWRSeg扩张式残差机制的小目标检测优化(附修改后的C2f与Bottleneck模块)

DWRSeg机制:通过动态权重调整和扩张卷积有效提升了小目标的检测能力。C2f和Bottleneck模块修改:通过集成DWRSeg模块,增强了特征提取和残差学习能力。实验结果:在多个应用场景中,改进后的YOLOv8展现了更高的检测精度,特别是在小目标检测中表现突出。

一键难忘的博客 3217

深入 Microsoft.VisualBasic.Strings.StrConv 簡繁轉換

 深入 Microsoft.VisualBasic.Strings.StrConv 簡繁轉換  昨天又遇到一個簡繁轉換的需求, 雖然這個問題以前已經處理過了, 但是以前是用自己建立的 b52gb 和 gb2b5 的對應表來完成這個需求(VB6 的話就用 StrConv 方法來達成), 在 .NET 環境中, Microsoft.VisualBasic.dll 裡也有提供 Strings

简单的快乐 5320

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

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

【转自优快云】深入 Microsoft.VisualBasic.Strings.StrConv 簡繁轉換

深入 Microsoft.VisualBasic.Strings.StrConv 簡繁轉換 昨天又遇到一個簡繁轉換的需求, 雖然這個問題以前已經處理過了, 但是以前是用自己建立的 b52gb 和 gb2b5 的對應表來完成這個需求(VB6 的話就用 StrConv 方法來達成), 在 .NET 環境中, Microsoft.VisualBasic.dll 裡也有提供 Strings.S...

weixin_30338743的博客 130

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

Microsoft.VisualBasic.dll的妙用(开发中肯定会用到哦)

前言 做过VB开发的都知道,有一些VB里面的好的函数在.NET里面都没有,而Microsoft.VisualBasic.dll却给我们提供使用这些函数的功能(没用过VB的这些功能一样可以使用,大同小异而已) 今天这里主要讲两个:一个是繁简转换,另一个是计算时间差,相信大家都有方法实现这两个功能,而我今天讲的却是只各需一句代码就实现这两个功能! 功能一:繁简转换 首先...

dianchenai7336的博客 420

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

C#简繁体转换方法(Microsoft.VisualBasic.dll)

1. 参考Microsoft.VisualBasic.dll2. 转简体代码private void btnCHS_Click(object sender, EventArgs e)        {            string src = txtSrcText.Text.Trim();            string des = Microsoft.Vis

边城骆驼 -- 每天进步百分之一 4199

C#简繁转换

添加 Microsoft.VisualBasic引用 /// <summary> /// 转换为简体中文 /// </summary> public static string ToSChinese(string str) { re...

weixin_30619101的博客 102

c#简繁转换示例

首先 添加Microsoft.VisualBasic.dll引用using Microsoft.VisualBasic;string gb2312 = "国营农场";string big5 = "";big5 = Strings.StrConv(gb2312, VbStrConv.TraditionalChinese, 0);Console.WriteLine(big5);

博客已转移至:http://www.cnblogs.com/wu-jian/ 1992

简繁转换

Public Shared Function Traditional2Simplified(ByVal str As String) As String '繁体转简体 Return (Microsoft.VisualBasic.Strings.StrConv(str, Microsoft.VisualBasic.VbStrConv.Simplified...

weixin_30512043的博客 82

分享 .net 簡繁轉換

//功能:简繁转换 //命名空间 (Namespace)∶Microsoft.VisualBasic //模组:Strings //组件 (Assembly):Visual Basic Runtime Library (in Microsoft.VisualBasic.dll) string targetString = "广东省"; string strsouce = Microsoft.VisualBasic.Strings.StrConv(targetString, Microsoft.

ShulingLiu的专栏 632

.net简繁体转换

记录下,免得用的时候到处找 方法一 /// <summary>/// 中文字符工具类/// </summary>public static class ChineseStringUtility { private const int LOCALE_SYSTEM_DEFAULT = 0x0800; private const int LCMAP_S...

weixin_30439031的博客 112

VB.net下有个函数strconv可以进行简体繁体转换(转载)

http://msdn.microsoft.com/zh-cn/library/cd7w43ec.aspx 有个简单的方法,VB.net下有个函数strconv可以进行简体繁体转换,添加引用Microsoft Visual Basic .Net Runtime string mStr=Microsoft.VisualBasic.S...

aiyinzhi8916的博客 429

指定形式字符串转化以及字符串编码转换

Strings.StrConv 方法  返回已转换为指定形式的字符串。 命名空间:Microsoft.VisualBasic using Microsoft.VisualBasic;  //引用Microsoft.VisualBasic命名空间 程序集:Microsoft.VisualBasic.Runtime(在 microsoft.visualbasic.dll 中)

程序人生,学海无涯 1375
上一篇: “网页无法显示”的错误代码说明(iis环境)
下一篇: 二叉树
boby16
博客等级 码龄21年 18粉丝 25原创
评论 3
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值