时域和频域的麦克斯韦方程组MATLAB
麦克斯韦方程组是用来描述电磁波产生和传播的微分方程。时域和频域麦克斯韦方程组都有各自适用的场景,需要根据不同情况选择相应方法进行处理。
在MATLAB中,我们可以使用PDE工具箱中的模块来求解麦克斯韦方程组。下面给出一个求解TE模式下的矩形波导的示例代码:
% 此处插入图片 te-mode.png
% 定义波导尺寸和参数
a = 5; b = 2; t = 0.01;
mu0 = pi*
墨衍会员
·
AI 创作全网分发
墨衍智能分发
本文由作者通过墨衍一键同步至各平台
1分发平台
900+累计阅读
934平均单平台
已同步平台
CSDN
微信公众号
微博
知乎
掘金
百家号
博客园
抖音
小红书
你的文章也可以这样分发
墨衍会员 ¥399起/年,写一次发全网
我也要 →
码龄4年
时域和频域的麦克斯韦方程组MATLAB
麦克斯韦方程组是用来描述电磁波产生和传播的微分方程。时域和频域麦克斯韦方程组都有各自适用的场景,需要根据不同情况选择相应方法进行处理。
在MATLAB中,我们可以使用PDE工具箱中的模块来求解麦克斯韦方程组。下面给出一个求解TE模式下的矩形波导的示例代码:
% 此处插入图片 te-mode.png
% 定义波导尺寸和参数
a = 5; b = 2; t = 0.01;
mu0 = pi*
时域和频域的麦克斯韦方程组(Matlab 实现)
时域的求解通过差分格式进行迭代计算,而频域的求解则利用傅里叶变换将时域中的场量转换为频域中的复数形式。本文将介绍如何使用 Matlab 对时域和频域的麦克斯韦方程组进行数值求解,并提供相应的源代码。时域的麦克斯韦方程组包括四个方程:两个关于电场的方程和两个关于磁场的方程。频域的麦克斯韦方程组通过将时域中的场量转换为频域中的复数形式来表示。通过以上代码,我们可以在时域内求解麦克斯韦方程组,并获得电场和磁场的时域分布。通过以上代码,我们可以在频域内求解麦克斯韦方程组,并获得电场和磁场的频域分布。
时域和频域的麦克斯韦方程组
时域和频域的麦克斯韦方程组,并通过一组势函数来求解麦克斯韦方程组,然后对核磁共振探测的基本原理进行了概述。然后本文介绍大地网格划分,FFT快速傅里叶变换以及Hankel变换基本原理,基于这些原理,并通过Nabighian推导得到水平电偶极子在地下任意网格位置的磁场以及回线源在网格位置的磁场。 最后,通过MATLAB软件对推导得到水平电偶极子在地下任意网格位置以及回线源在网格位置的磁场的数学公式Hx,Hy,Hz进行数值仿真。通过数值仿真结果可知,本文的推导结果可以获得精度较高的数值仿真结果。...
MATLAB 时域和频域的麦克斯韦方程组
麦克斯韦方程组是描述电磁场的基本方程,包括时域和频域两种形式。时域麦克斯韦方程组描述电磁场随时间的变化,而频域麦克斯韦方程组描述电磁场随频率的变化。麦克斯韦方程组是电磁场仿真的基础,具有广泛的应用前景。MATLAB 提供了丰富的工具和函数,可以方便地进行时域和频域麦克斯韦方程组的求解和仿真。
MATLAB FDTD电磁仿真:从Yee网格到PEC圆柱散射的完整实现
时域有限差分法(FDTD)是计算电磁学领域的核心数值方法,它通过将连续的麦克斯韦方程组离散化,直接在时域中模拟电磁波的传播、散射及与复杂结构的相互作用。其核心在于Yee网格的空间-时间交错设计,以及满足CFL条件的显式更新迭代,这保证了算法的数值稳定性。FDTD的技术价值在于能够直观地可视化电磁现象,并一次性获得宽频带响应,是天线设计、雷达散射截面分析和高速电路信号完整性研究的强大工具。本文以二维TM波在自由空间传播并遭遇理想导体圆柱散射这一典型场景为例,详细阐述了如何在MATLAB环境中,从网格划分、参数
MATLAB实现的无穷小偶极子辐射电场传播模拟
一个无穷小偶极子是指在空间中非常小的电荷对,其线度远小于它所发射电磁波的波长。这个模型对于理论分析和简化计算非常有用。一个典型的偶极子可以被视为一个理想化的振荡电流元,它在每个时间点产生的电磁场可以被用于计算远场区域的辐射。偶极子的特性在于它产生的电磁波具有明确的极化方向,并且在不同的方向上辐射强度是不同的。这种方向性使得偶极子模型在分析天线辐射、电磁干扰以及在某些情况下无线通信系统的设计中变得极为重要。
FDTD3维matlab程序
%*********************************************************************** % 3-D FDTD code with PEC boundaries %*********************************************************************** % % Program author: Susan C. Hagness % Department of Electrical and Computer Engineering % University of Wisconsin-Madison % 1415 Engineering Drive % Madison, WI 53706-1691 % 608-265-5739 % hagness@engr.wisc.edu % % Date of this version: February 2000 % % This MATLAB M-file implements the finite-difference time-domain % solution of Maxwell's curl equations over a three-dimensional % Cartesian space lattice comprised of uniform cubic grid cells. % % To illustrate the algorithm, an air-filled rectangular cavity % resonator (充气矩形空腔谐振器) is modeled. The length, width, and height of the % cavity are 10.0 cm (x-direction), 4.8 cm (y-direction), and % 2.0 cm (z-direction), respectively. % % The computational domain is truncated using PEC boundary % conditions: % ex(i,j,k)=0 on the j=1, j=jb, k=1, and k=kb planes % ey(i,j,k)=0 on the i=1, i=ib, k=1, and k=kb planes % ez(i,j,k)=0 on the i=1, i=ib, j=1, and j=jb planes % These PEC boundaries form the outer lossless walls of the cavity. % % The cavity is excited by an additive current source oriented % along the z-direction. The source waveform is a differentiated % Gaussian pulse given by % J(t)=-J0*(t-t0)*exp(-(t-t0)^2/tau^2), % where tau=50 ps. The FWHM ( 半最大值全宽度(full width at half maximum)) % spectral bandwidth of this zero-dc- % content pulse is approximately 7 GHz. The grid resolution (分辨率) % (dx = 2 mm) was chosen to provide at least 10 samples per % wavelength up through 15 GHz. % % To execute this M-file, type "fdtd3D" at the MATLAB prompt. % This M-file displays the FDTD-computed Ez fields at every other % time step (第一个时间步), and records those frames in a movie matrix, M, which % is played at the end of the simulation using the "movie" command. % %*********************************************************************** clear %*********************************************************************** % Fundamental constants %*********************************************************************** cc=2.99792458e8; %speed of light in free space muz=4.0*pi*1.0e-7; %permeability of free space epsz=1.0/(cc*cc*muz); %permittivity of free space %*********************************************************************** % Grid parameters %*********************************************************************** ie=50; %number of grid cells in x-direction je=24; %number of grid cells in y-direction ke=10; %number of grid cells in z-direction ib=ie+1; jb=je+1; kb=ke+1; is=26; %location of z-directed current source js=13; %location of z-directed current source kobs=5; dx=0.002; %space increment of cubic lattice dt=dx/(2.0*cc); %time step nmax=500; %total number of time steps %*********************************************************************** % Differentiated Gaussian pulse excitation %*********************************************************************** rtau=50.0e-12; tau=rtau/dt; ndelay=3*tau; srcconst=-dt*3.0e+11; %*********************************************************************** % Material parameters %*********************************************************************** eps=1.0; %相对介电常数 epsz,真空介电常数 sig=0.0; %相对电阻率 %*********************************************************************** % Updating coefficients %*********************************************************************** ca=(1.0-(dt*sig)/(2.0*epsz*eps))/(1.0+(dt*sig)/(2.0*epsz*eps)); cb=(dt/epsz/eps/dx)/(1.0+(dt*sig)/(2.0*epsz*eps)); da=1.0; db=dt/muz/dx; %*********************************************************************** % Field arrays %*********************************************************************** ex=zeros(ie,jb,kb); ey=zeros(ib,je,kb); ez=zeros(ib,jb,ke); hx=zeros(ib,je,ke); hy=zeros(ie,jb,ke); hz=zeros(ie,je,kb); %*********************************************************************** % Movie initialization %*********************************************************************** tview(:,:)=ez(:,:,kobs); sview(:,:)=ez(:,js,:); subplot('position',[0.15 0.45 0.7 0.45]), pcolor(tview'); %shading flat; %caxis([-1.0 1.0]); %colorbar; %axis image; title(['Ez(i,j,k=5), time step = 0']); xlabel('i coordinate'); ylabel('j coordinate'); subplot('position',[0.15 0.10 0.7 0.25]), pcolor(sview'); %shading flat; %caxis([-1.0 1.0]); %colorbar; %axis image; title(['Ez(i,j=13,k), time step = 0']); xlabel('i coordinate'); ylabel('k coordinate'); rect=get(gcf,'Position'); rect(1:2)=[0 0]; M=moviein(nmax/2,gcf,rect); %*********************************************************************** % BEGIN TIME-STEPPING LOOP %*********************************************************************** for n=1:nmax %*********************************************************************** % Update electric fields %*********************************************************************** ex(1:ie,2:je,2:ke)=ca*ex(1:ie,2:je,2:ke)+... cb*(hz(1:ie,2:je,2:ke)-hz(1:ie,1:je-1,2:ke)+... hy(1:ie,2:je,1:ke-1)-hy(1:ie,2:je,2:ke)); ey(2:ie,1:je,2:ke)=ca*ey(2:ie,1:je,2:ke)+... cb*(hx(2:ie,1:je,2:ke)-hx(2:ie,1:je,1:ke-1)+... hz(1:ie-1,1:je,2:ke)-hz(2:ie,1:je,2:ke)); ez(2:ie,2:je,1:ke)=ca*ez(2:ie,2:je,1:ke)+... cb*(hx(2:ie,1:je-1,1:ke)-hx(2:ie,2:je,1:ke)+... hy(2:ie,2:je,1:ke)-hy(1:ie-1,2:je,1:ke)); ez(is,js,1:ke)=ez(is,js,1:ke)+... srcconst*(n-ndelay)*exp(-((n-ndelay)^2/tau^2)); % J(t)=-J0*(t-t0)*exp(-(t-t0)^2/tau^2) %*********************************************************************** % Update magnetic fields %*********************************************************************** hx(2:ie,1:je,1:ke)=hx(2:ie,1:je,1:ke)+... db*(ey(2:ie,1:je,2:kb)-ey(2:ie,1:je,1:ke)+... ez(2:ie,1:je,1:ke)-ez(2:ie,2:jb,1:ke)); hy(1:ie,2:je,1:ke)=hy(1:ie,2:je,1:ke)+... db*(ex(1:ie,2:je,1:ke)-ex(1:ie,2:je,2:kb)+... ez(2:ib,2:je,1:ke)-ez(1:ie,2:je,1:ke)); hz(1:ie,1:je,2:ke)=hz(1:ie,1:je,2:ke)+... db*(ex(1:ie,2:jb,2:ke)-ex(1:ie,1:je,2:ke)+... ey(1:ie,1:je,2:ke)-ey(2:ib,1:je,2:ke)); %*********************************************************************** % Visualize fields %*********************************************************************** if mod(n,2)==0; timestep=int2str(n); tview(:,:)=ez(:,:,kobs); sview(:,:)=ez(:,js,:); subplot('position',[0.15 0.45 0.7 0.45]), pcolor(tview'); % shading flat; % caxis([-1.0 1.0]); % colorbar; % axis image; title(['Ez(i,j,k=5), time step = ',timestep]); xlabel('i coordinate'); ylabel('j coordinate'); subplot('position',[0.15 0.10 0.7 0.25]), pcolor(sview'); % shading flat; % caxis([-1.0 1.0]); % colorbar; % axis image; title(['Ez(i,j=13,k), time step = ',timestep]); xlabel('i coordinate'); ylabel('k coordinate'); nn=n/2; M(:,nn)=getframe(gcf,rect); end; %*********************************************************************** % END TIME-STEPPING LOOP %*********************************************************************** end movie(gcf,M,0,10,rect);
matlab的egde源代码-maxwellfdfd:基于FDFD方法的基于MATLAB的麦克斯韦方程组求解器包
matlab的egde源代码麦克斯韦FDFD MaxwellFDFD是基于MATLAB的Maxwell方程求解器软件包。 它通过有限差分频域(FDFD)方法求解方程,因此命名为MaxwellFDFD。 有关安装说明,请参见INSTALL.md 。 有关更详细的介绍和用法,请参见MATLAB或任何网络浏览器中的doc/index.html 。
matlab解多项式方程代码-MIT_Forward:麻省理工学院问题的hp-FEM前向求解器
matlab解说式代码代码MIT 正向求解器 此代码用于求解时谐麦克斯韦方程的涡流近似。 它以任意多项式顺序使用符合 H(curl) 的 hp 有限元方法。 运行此代码需要deal.II 库。 假设deal.II 8.3 安装和配置正确,那么代码应该可以成功运行。 但是,我们建议使用日期为 7 月 6 日的 deal.II 开发分支(SHA 哈希 79583e56)以确保完全兼容性。 用法: 作为使用示例,我们参考了在均匀背景场中的导电球的情况,如 [1] 中所述。 要运行球体基准测试代码: $ cd benchmark/sphere_benchmark $ mkdir build $ cd build $ cmake ../ $ make $ ./sphere_benchmark -i ../input_files/sphere_team6_dealmesh.prm -m 2 -h 1 -p 1 这将在多项式阶数为 1 的粗网格(具有二阶映射的原始处理网格的 1 次全局细化)上运行 TEAM 6 基准测试,并生成一个 .vtk 文件,该文件可以使用 PARAVIEW 等软件进行可视化
麦克斯韦方程组讲解
麦克斯韦方程组讲解 。
基于傅里叶的磁化率张量快速磁场扰动计算方法:一种以张量形式实现麦克斯韦方程组傅里叶变换的算法-matlab开发
# 方法: 该算法以张量形式实现麦克斯韦方程的傅立叶变换,允许从 3D 中已知磁化率的圆柱体向前计算感应场。 在 MRI 中,麦克斯韦方程组(Marques 和 Bowtell,2005 年和 Salomir 等人,2003 年)的傅立叶变换允许在磁化率分布和场图之间进行转换。 虽然人体组织中的大多数结构表现出各向同性的磁化率,但一些生物分子被认为具有磁化率各向异性 - 例如,大脑中的髓鞘。 这种各向异性可以用 2 阶张量来表征。 适应这种磁化率张量公式的麦克斯韦方程的傅立叶变换在 Liu 2010 年的方程 9 中导出,磁化率张量成像。 此例程将磁化率的张量公式结合到 3D 实心圆柱体的场畸变前向计算中。 #输入输出: 函数 [A]= sus_tensor(PHI,THETA,B0,sus, AA,BB,CC) 输入(在适用的球坐标中): Φ,0-> pi / 2,外加磁场与圆柱
IROS 2025机器人技术解析:从诡异设计到硬核应用
机器人技术正从传统的结构化环境应用,迈向复杂非结构化场景的深度交互。其核心原理在于通过仿生设计、多模态感知与智能控制算法,赋予机器人类似生物的适应性与交互能力。这一技术演进的价值在于突破传统机器人在极端环境、精密操作和自然交互中的瓶颈。例如,结合深度强化学习的全身动力学控制,使机器人能在废墟、管道等复杂地形中自主导航;而软体机器人技术则通过材料变形实现安全、柔顺的抓取操作。这些技术最终服务于极端环境巡检、精密装配和高端陪护等刚性应用场景,推动机器人从功能实现迈向与环境、人进行深度、智能交互的新阶段。
Arduino程序设计(十四)舵机控制实验(SG90)
本文介绍SG90舵机控制原理及实验,主要内容有:1、介绍SG90舵机;2、舵机0°~180°来回转动;3、串口控制舵机转动固定角度。(1)舵机是一种位置(角度)伺服的驱动器。舵机只是一种通俗的叫法,其实质是一个伺服马达。在需要角度不断变化并可以保持的控制系统中应用广泛。如遥控机械人、飞机模型等。(2)舵机的转动角度为0~180°,其内部结构包括电机,控制电路和机械结构三部分。电机有三根线引出,分别接VCC、GNG和信号线。
STM32串口DMA双缓冲机制实战:提升数据传输效率的终极方案
本文深入解析了STM32串口DMA双缓冲机制的核心原理与实战配置。通过对比传统中断方式,阐述了双缓冲如何实现数据接收与处理的“无缝接力”,从而在工业传感器数据采集等高负载场景下,将CPU占用率降至极低水平并彻底避免数据丢失。文章提供了基于标准外设库的详细配置步骤、中断处理逻辑及性能实测数据,是提升嵌入式系统串口通信效率和可靠性的终极方案。
Vue项目实战:海康WebControl插件从安装到预览功能全流程(附RSA加密避坑指南)
本文详细介绍了在Vue项目中集成海康威视WebControl插件的全流程,从环境准备、插件部署到核心功能实现。重点解析了使用JS_RequestInterface获取RSA公钥并进行加密参数初始化的关键步骤与常见避坑指南,帮助开发者高效完成监控视频预览功能的开发与调试。
unity打包流程整理-Windows/Mac/Linux平台
1.Platform(平台)功能: 选择目标构建的目标平台选项PC, Mac & Linux Standalone: 适用于 Windows、Mac 和 Linux 平台2.Target Platform(目标平台)功能: 选择具体的操作系统版本选项Windows: 针对 Windows 操作系统Mac: 针对 macOS 操作系统Linux: 针对 Linux 操作系统3.Architecture(架构)功能: 选择应用程序的目标处理器架构选项x86: 针对 32 位系统。
【清风数学建模笔记】第十一讲:时间序列分析
【清风数学建模笔记】第十一讲:时间序列分析
YOLOv11改进 | 集成FEM、FFM与SCAM即插即用模块:特征增强、融合与空间上下文建模新范式
FEM解决特征表达不足问题,增强关键特征响应FFM优化多尺度融合,提升小目标检测精度SCAM建模空间上下文,改善目标交互预测在保持YOLOv11实时性优势的同时,实现mAP+8.1%的显著提升,特别在复杂光照、密集目标、交互预测场景表现突出。其模块化设计使开发者可根据需求灵活组合,为各种复杂场景提供定制化解决方案。未来,随着跨模态扩展与神经架构搜索的深入,YOLOv11-FSC将进一步推动目标检测技术向更智能、更高效的方向发展。
微信小程序 - error_msg:net::ERR_CONNECTION_RESET“(“errno“:600001,“errMsg“:“uploadFile:fail errcode:-101)
"errno":600001,"errMsg":"uploadFile:fail errcode:-101 cronet_error_code:-101 error_msg:net::ERR_CONNECTION_RESET"微信小程序,微信小程序wx.uploadFile报错,uniapp微信小程序uni.uploadFile上传文件报错,微信小程序调用wx.uploadFile返回错误ERR_CONNECTION_RESET,如何解决这个问题,上传图片出现报错,小程序上传视频报错,上传文件出现报错,如何
visio安装包
Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。
深度学习工具包 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');```[](https://bitdeli.com/free "Bitdeli Badge")
精雕软件(JDpaint) 5.5 绿色版
精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版
怀旧版电脑GBC模拟器
再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。
1万+
5440

被折叠的 条评论
为什么被折叠?



