8 .NET 配置

【.Net8教程】(一)读取配置文件全面总结 .net8.0读取json配置文件 阅读详情

word文档地址:https://github.com/IceEmblem/LearningDocuments/tree/master/%E5%AD%A6%E4%B9%A0%E8%B5%84%E6%96%99/Windows%20%E5%B9%B3%E5%8F%B0/Net

涉及概念

本文主要介绍IConfiguration、ConfigurationBuilder、IConfigurationSource的之间的关系和用法,如果你已经了解其用途,可以跳过
IConfiguration:配置,其包含整个程序的配置数据
IConfigurationSource:配置源,其有多种实现,包括Json、ini、xml等
ConfigurationBuilder:配置生成器,其利用IConfigurationSource生成IConfiguration

基本示例

// IConfiguration使用 : 来分隔层次结构,如下配置结构为
// {
//     format:{
//         dateTime:{
//             longDatePattern: "dddd, MMMM d, yyyy",
//             longTimePattern: "h:mm:ss tt"
//             ...
//         }
//     }
// }
Dictionary<string, string> source = new Dictionary<string, string>
{
    ["format:dateTime:longDatePattern"] = "dddd, MMMM d, yyyy",
    ["format:dateTime:longTimePattern"] = "h:mm:ss tt",
    ["format:dateTime:shortDatePattern"] = "M/d/yyyy",
    ["format:dateTime:shortTimePattern"] = "h:mm tt",
};

// 配置
IConfiguration config =
    // 新建ConfigurationBuilder
    new ConfigurationBuilder()
    // 添加内存配置源
    .Add(new MemoryConfigurationSource { InitialData = source })
    // 添加Json配置源
    .AddJsonFile("./appsettings.json")
    // 生成Configuration
.Build();

// 使用 GetSection 获取数据
var longDatePattern = config.GetSection("format").GetSection("dateTime").GetValue<string>("longDatePattern");
Console.WriteLine(longDatePattern);

// 当然,你也可以直接获取数据, : 代表层次结构
var longDatePattern2 = config["format:dateTime:longDatePattern"];
Console.WriteLine(longDatePattern2);

配置源

.net core 提供的配置源有下面几种

1.内存配置源
内存配置源的实现为MemoryConfigurationSource,其提供了2个扩展方法将源快速添加到ConfigurationBuilder中

public static IConfigurationBuilder AddInMemoryCollection(
this IConfigurationBuilder configurationBuilder);
public static IConfigurationBuilder AddInMemoryCollection(
this IConfigurationBuilder configurationBuilder,  
IEnumerable<KeyValuePair<string, string>> initialData);

2.环境变量配置源
环境变量配置源的实现为EnvironmentVariablesConfigurationSource
包:Microsoft.Extensions.Configuration.EnvironmentVariables

public static IConfigurationBuilder AddEnvironmentVariables(
    this IConfigurationBuilder configurationBuilder);
public static IConfigurationBuilder AddEnvironmentVariables(
    this IConfigurationBuilder configurationBuilder, 
    string prefix);

3.命令行参数
命令行参数配置源的实现为CommandLineConfigurationSource
包:Microsoft.Extensions.Configuration.CommandLine

public static IConfigurationBuilder AddCommandLine(
    this IConfigurationBuilder configurationBuilder, 
    string[] args);
public static IConfigurationBuilder AddCommandLine(
    this IConfigurationBuilder configurationBuilder, 
    string[] args, 
    IDictionary<string, string> switchMappings);

4.Json文件
其实现的配置源为JsonConfigurationSource
包:Microsoft.Extensions.Configuration.Json
包提供的添加Json配置源的扩展

public static class JsonConfigurationExtensions
{
    public static IConfigurationBuilder AddJsonFile(
        this IConfigurationBuilder builder, 
        Action<JsonConfigurationSource> configureSource);

    public static IConfigurationBuilder AddJsonFile(
        this IConfigurationBuilder builder, 
        string path);

    public static IConfigurationBuilder AddJsonFile(
        this IConfigurationBuilder builder, 
        string path, 
        bool optional);

    public static IConfigurationBuilder AddJsonFile(
        this IConfigurationBuilder builder, 
        string path,            // 配置源路径
        bool optional,          // 是否可选配置源
        bool reloadOnChange);   // 改变是否重新载入
}

5.Xml文件
其实现为XmlConfiguationSource
包:Microsoft.Extensions.Configuration.Xml
包提供的XML配置源的扩展

public static class XmlConfigurationExtensions
{
    public static IConfigurationBuilder AddXmlFile(
        this IConfigurationBuilder builder, 
        string path, 
        bool optional, 
        bool reloadOnChange);

    ...
}

XML文件示例

<Profiles>
  <Foo Gender="Male" Age="18">
    <ContactInfo EmailAddress ="foobar@outlook.com" PhoneNo="123"/>
  </Foo>
  <Bar Gender="Male" Age="25">
    <ContactInfo EmailAddress ="foobar@outlook.com" PhoneNo="123"/>
  </Bar>
  <Baz Gender="Male" Age="18">
    <ContactInfo EmailAddress ="baz@outlook.com" PhoneNo="789"/>
  </Baz>
</Profiles>

6.ini文件
其实现为IniConfigurationSource
包:Microsoft.Extensions.Configuration.Ini
包提供的扩展

public static class IniConfigurationExtensions
{
    public static IConfigurationBuilder AddIniFile(
        this IConfigurationBuilder builder, 
        string path, 
        bool optional, 
        bool reloadOnChange);

    ...
}

INI文件示例

Gender = "Male"
Age = "18"
ContactInfo:EmailAddress = "foobar@outlook.com"
ContactInfo:PhoneNo = "123456789"

Asp.net core

1.添加配置源
我们可以在IHostBuilder.ConfigureHostConfiguration中添加配置源

Host.CreateDefaultBuilder(args)
    .ConfigureHostConfiguration((config) => {
        Dictionary<string, string> source = new Dictionary<string, string>
        {
            ["format:dateTime:longDatePattern"] = "dddd, MMMM d, yyyy",
            ["format:dateTime:longTimePattern"] = "h:mm:ss tt",
            ["format:dateTime:shortDatePattern"] = "M/d/yyyy",
            ["format:dateTime:shortTimePattern"] = "h:mm tt",
        };
        config.AddInMemoryCollection(source);
    })

2.使用配置
我们可以在任何地方使用依赖注入获取IConfiguration

public Startup(IConfiguration configuration)
{
    var longDatePattern2 = configuration["format:dateTime:longDatePattern"];
}
.NET8配置组件 包装自定义配置文件。例如:包装自定义配置文件的路径。:读取 解析 存储 赋值自定义配置文件。例如:读取 解析 存储 赋值自定义配置中的内容。(2)、创建appsettings.txt(3)、创建TextConfigurationSource.cs/// 文本文件 配置源/// 定义appsettings.txt 路径get;(4)、创建TextConfigurationProvider.cs类/// 2、文本文件 提供者:读取 解析 存储 赋值get;// 4、存储配置内容。 阅读详情

相关推荐

使用 .NET 设置环境变量

在 .NET 应用程序中,可以使用环境变量来存储和访问配置信息、敏感数据和其他运行时参数。本文将介绍如何在 .NET 应用程序中设置和使用环境变量,并提供相应的源代码示例。在 .NET 应用程序中,设置和使用环境变量是一种常见的方式来存储和访问配置信息和其他运行时参数。希望本文能够帮助你理解在 .NET 中设置环境变量的过程。方法来设置环境变量。方法访问环境变量的值,可以轻松地在应用程序中进行配置和参数管理。一旦设置了环境变量,就可以在应用程序中访问它们。在实际应用中,你可以根据需要设置不同的变量名和值。

library_git106的博客 1091

ASP.NET Core 8 的配置类 Configuration

app的Configuration优先级更高,host Configuration作为替补配置,因为app运行在host之上。每种方式都提供了非常丰富的配置选择,可用于各种场景,以便在开发环境和产品环境时使用。

gnimgnot 2736

ASP.NET Core 8 社交登录配置指南

ASP.NET Core 8 提供了丰富的身份验证机制,其中包括与社交登录提供者的集成。通过上述步骤,您可以在ASP.NET Core 8的Blazor Web应用中配置和实现多种社交登录方式,从而提升用户体验,简化注册流程,并增加用户信任度。在开始配置之前,您需要确保已安装ASP.NET Core 8的开发环境,并且您的项目是基于Blazor的Web应用程序模板,并且选择了使用个人账户认证。完成上述步骤后,启动您的应用,尝试使用不同的社交登录选项进行登录,确保流程顺畅且用户可以成功注册和登录。

m0_74337424的博客 106

.net环境变量 的设置

昨天读《C#高级编程第六版》的时侯 讲到 使用csc.exe 编译器的时候 需要设置一下环境变量 如果没有设置环境变量有两种解决办法 第一种方法:在命令行上运行批处理文件%Microsoft VisualStudio 2008%\Common7\Tools\vcvars32.bat 其中%Microsoft VisualStudio 2008% 是安装Visual Studio 2...

weixin_30446197的博客 654

安装Anaconda和Labelme的教程

1 登录Anaconda官网,选择Download https://www.anaconda.com/distribution/ 2 选择你想下载的Python版本,选择你的操作系统和位数,然后点击Download按钮就开始下载了 3 开始安装 下面两个框框都勾选 点击next,等待安装成功 打开Anaconda Navigator 点击红色圈圈的按钮 在cmd中输入 (1)创建虚拟环境 conda create -n labelme python=3.6 (2)激活虚拟环境 conda activa

qq_42178122的博客 3811

2.6 SST的核心性能指标体系

本文构建了固态变压器(SST)的核心性能指标体系,涵盖电气性能、可靠性、经济性和环境适配性四大类指标。电气性能指标包括运行效率(≥97%)、功率密度(≥900kVA/m³)、谐波畸变率(≤3%)等关键参数;可靠性指标设定MTBF≥43800h、年均故障率≤1.2次/年等标准;经济性指标对比分析了初始购置成本(45-55万元)和全生命周期成本(48-55万元);环境适配性指标则明确了温度、海拔等工况要求。该体系采用量化公式和国标限值,为SST的性能测试、选型和优化提供了统一标准。

技术工作者 602

ASP.NET Core 8 的运行环境 Environment

运行时环境变量可以用于根据不同的开发阶段运行不同的逻辑,比如在开发阶段的某些功能或保密信息不暴露在正式上线的代码中。可以在 Properties\launchSettings.json 文件中设置 ASPNETCORE_ENVIRONMENT 变量来标识。

gnimgnot 1820

S32DS 3.5.8离线包怎么用?保姆级教程教你手动安装S32K3开发环境(附资源下载)

本文详细介绍了S32DS 3.5.8离线包的安装方法,适用于S32K3开发环境的手动搭建。从资源获取、完整性验证到分步安装指南,提供了全面的离线部署解决方案,特别适合军工/车企内网开发等场景。文章还包含版本选择建议、常见问题排查及团队协作方案,帮助开发者高效完成环境配置。

weixin_30471561的博客 477

.NET 8 组件之配置选项组件

配置选项组件是一种将应用程序配置与代码分离的设计模式。通过使用此模式,可以将配置项封装在强类型类中,并通过依赖注入(Dependency Injection, DI)机制将配置注入到应用程序的各个部分。此方式使配置更加模块化、易于管理,并且减少了硬编码的风险。在 .NET 8 中,配置选项组件得到了进一步的优化和增强,为开发者提供了更好的体验和更高的灵活性。首先,需要定义一个类来表示配置项。这个类通常会对应于配置文件中的某个配置节。// 定义一个表示配置项的类,属性对应配置文件中的键值对set;

hy_4377的博客 811

USRP N210与MATLAB连接实战:从驱动安装到信号接收

本文详细介绍了USRP N210与MATLAB连接的完整流程,涵盖驱动安装、网络配置、支持包安装及信号接收实战。重点解决了安装过程中的常见错误和硬件连接问题,并通过MATLAB代码示例展示了如何配置接收器、处理信号数据,帮助用户快速实现从设备对接到信号分析的全过程。

blue的专栏 821

钢铁雄心4存档修改全攻略:从基础设置到高级玩法(附国家代码表)

本文详细解析《钢铁雄心4》存档修改技巧,从基础设置到高级玩法全覆盖。包括存档文件位置、格式转换、国家实力调整、国际关系修改等实用内容,并附赠国家代码表。掌握存档修改技能,解锁游戏全部潜力,实现精细参数控制,超越控制台指令的局限。

weixin_29233857的博客 1433

.NET 8 运行时更新 GC 配置

.NET 8 运行时更新 GC 配置Intro为了更好的云原生的支持,.NET 8 支持了运行时更新 GC 的配置,我们可以在运行时修改 GC 的配置了,在之前的版本中需要通过反射来调用,在 RC2 版本中直接新增了一个 public 方法可以直接调用,无需再通过反射调用了SamplepublicstaticclassGCSample { publicstaticvoidMai...

dotNET跨平台 354

UDS(三)网络层时间参数

网络层定义了N_Ar、N_As、N_Br、N_Bs、N_Cr、N_Cs六个时间参数。 网络层在检测到错误的时间传递至上层使用者 1.当N_As 超时时,即发送方没有及时发送出N_PDU,系统将放弃信息的接收并传递<N_Result> = <N_TIMEOUT_A>的N_USData.comfirm指示 2.当N_Ar超时时,即接收方没有及时发送出N_PDU,系统将放弃信息的接收并传递<N_Result> = <N_TIMEOUT_A>的N_USData.co

weixin_44522306的博客 1万+

ASP.NET Core 8 轻松配置Serilog日志

与许多其他 .NET 库一样,Serilog 提供了将诊断日志输出到文件、控制台以及其他位置的功能。它易于设置,拥有简洁的 API,并且可以在最新的 .NET 平台之间进行移植。

baidu_39476236的博客 893

南 京 农 业 大 学 试 题 纸 附表(rape.csv)是25个油菜材料,测得每个材料的千粒重、亚油酸等的含量. (1) 对物质含量的八个指标作主成分分析,画出碎石图和主成分得分图; (2) 选

(1)请用n1

Mrrunsen的博客 498

【局部规划模块轨迹优化算法】EM_planner最大期望滚动优化算法

认知有限,望大家多多包涵,有什么问题也希望能够与大家多交流,共同成长!本文先对EM_planner最大期望滚动优化算法做个简单的介绍,具体内容后续再更,其他模块可以参考去我其他文章提示:以下是本篇文章正文内容。

qq_35635374的博客 760

CentOS8下安装Supervisior并为ASP.NET Core站点配置监控

  之前在Asp.Net Core 3.1 发布至Linux中已经成功的在CentOS8中运行了Asp.Net Core站点。但是,该站点是手动启动服务,因此有必要对ASP.NET Core网站应用进行监控,使网站可以持续运行,不然退出Shell后网站就停止了。官方推荐使用Supervisor进行监控。很多文章都已经写了如何安装Supervisor和配置Supervisor的文章,但参考之后却没那...

ldy的专栏 1698

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

【.NET core】教程之.NET 8 配置系统和 Options

如果你已经学过依赖注入,再来学配置系统和 Options 模式,会非常顺。“配置应该怎么优雅地管理和使用?怎么添加怎么创建类怎么用绑定配置怎么用注入服务虽然这几步不算复杂,但它们是现代 .NET 项目里非常基础的一套能力。你后面无论是学 Web API、学数据库连接、学第三方服务接入,几乎都会继续用到这套思路。所以这节内容,真的值得你自己多敲两遍。

Zy100Papa的博客 219

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

.Net 8.0之SQL Server读写分离的配置

最先考虑的肯定是配置不同的数据库连接,查询数据的就走 查询用的数据库A,增删改数据的就走 修改用的数据库B。专业点描述就是先将数据库配置发布订阅模式,实现了1主多从的模式,主数据库一般负责更新数据,从数据库会同步主数据库的数据过来。解决思路是在DBContext中去修改数据库连接,在具体使用DBContext查询数据或者新增数据时,指定具体的数据库配置去查询数据。将BaseService文件,注入IDbContextFactory对象,并在每个方法中,加入数据操作的类型,比如是查询还是更新数据。

wzl644的专栏 2911

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

linux安装net8并配置netcore项目网站运行

1.安装net8执行下面命令。从微软官方下载net8:然后进入linux,按照官方说明执行:除了上边的方法,还可以用snap install dotnet-sdk --classic:# 更新软件包列表# 安装snapd,如果尚未安装# 类似的,确保snapd服务正在运行# 安装snap包dotnet-sdk,可以加参数:--classic:2.临时运行dotnet先执行下面两行,这个只对当前打开的bash命令行终端有效,关了就失效了。要永久有效需要设置配置文件。

zhiqingcn的专栏 7341

【亲测免费】 Yolov8.Net 安装和配置指南

### 项目介绍 Yolov8.Net 是一个基于 .NET 6 的开源项目,旨在通过 ONNX Runtime 使用 Yolov5 和 Yolov8 模型进行对象检测。该项目提供了一个简洁的接口,使得开发者可以在 .NET 环境中轻松加载和使用这些先进的深度学习模型。 ### 主要编程语言 该项目主要使用 C# 编程语言进行开发。 ## 2. 项目使用的关键技术和框架 ### 关键技术 -...

gitblog_09608的博客 898

.NET 8 kestrel 配置PEM,实现内网https

mkcert 是一个简化本地 HTTPS 环境搭建的工具,能够快速生成本地信任的开发证书,无需复杂配置。通过 mkcert,用户可以轻松创建自签证书,并自动将根证书加入本地可信 CA 中,确保证书在本地环境中被信任。安装后,用户可以通过命令行生成自签证书,支持多个域名或 IP 地址。生成的证书可直接用于开发环境,如 NET8 的 Kestrel 服务器配置中。需要注意的是,PEM 格式证书在 Windows 环境下无法正常使用,需在 Linux 环境下使用,Windows 环境下应使用 PFX 格式证书。

sxy_student的博客 1133

CentOS7 Linux NET8网络自动配置

linux 网络设置

krb___的博客 867

.Net Core/.Net6/.Net8 ,启动配置/Program.cs 配置

.Net Core/.Net6/.Net8 ,启动配置/Program.cs 配置

weixin_42199478的博客 3162

NET8部署Kestrel服务配置TLS协议验证实战

TLS协议证书验证实战

morliz的博客 1733
上一篇: .NET RabbitMQ
下一篇: 9 .NET 日志
dabusidede
博客等级 码龄9年 84粉丝 208原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值