MATLAB 神经网络并行运算与神经网络基于CPUGPU的并行神经网络运算.docx

上传人:b****7 文档编号:23827508 上传时间:2023-05-21 格式:DOCX 页数:9 大小:70.70KB
下载 相关 举报
MATLAB 神经网络并行运算与神经网络基于CPUGPU的并行神经网络运算.docx_第1页
第1页 / 共9页
MATLAB 神经网络并行运算与神经网络基于CPUGPU的并行神经网络运算.docx_第2页
第2页 / 共9页
MATLAB 神经网络并行运算与神经网络基于CPUGPU的并行神经网络运算.docx_第3页
第3页 / 共9页
MATLAB 神经网络并行运算与神经网络基于CPUGPU的并行神经网络运算.docx_第4页
第4页 / 共9页
MATLAB 神经网络并行运算与神经网络基于CPUGPU的并行神经网络运算.docx_第5页
第5页 / 共9页
点击查看更多>>
下载资源
资源描述

MATLAB 神经网络并行运算与神经网络基于CPUGPU的并行神经网络运算.docx

《MATLAB 神经网络并行运算与神经网络基于CPUGPU的并行神经网络运算.docx》由会员分享,可在线阅读,更多相关《MATLAB 神经网络并行运算与神经网络基于CPUGPU的并行神经网络运算.docx(9页珍藏版)》请在冰豆网上搜索。

MATLAB 神经网络并行运算与神经网络基于CPUGPU的并行神经网络运算.docx

MATLAB神经网络并行运算与神经网络基于CPUGPU的并行神经网络运算

清空环境变量

clearall

clc

warningoff

打开matlabpool

matlabpoolopen

poolsize=matlabpool('size');

Startingmatlabpoolusingthe'local'profile...connectedto2workers.

加载数据

loadbodyfat_dataset

inputs=bodyfatInputs;

targets=bodyfatTargets;

创建一个拟合神经网络

hiddenLayerSize=10;%隐藏层神经元个数为10

net=fitnet(hiddenLayerSize);%创建网络

指定输入与输出处理函数(本操作并非必须)

net.inputs{1}.processFcns={'removeconstantrows','mapminmax'};

net.outputs{2}.processFcns={'removeconstantrows','mapminmax'};

设置神经网络的训练、验证、测试数据集划分

net.divideFcn='dividerand';%随机划分数据集

net.divideMode='sample';%划分单位为每一个数据

net.divideParam.trainRatio=70/100;%训练集比例

net.divideParam.valRatio=15/100;%验证集比例

net.divideParam.testRatio=15/100;%测试集比例

设置网络的训练函数

net.trainFcn='trainlm';%Levenberg-Marquardt

设置网络的误差函数

net.performFcn='mse';%Meansquarederror

设置网络可视化函数

net.plotFcns={'plotperform','plottrainstate','ploterrhist',...

'plotregression','plotfit'};

单线程网络训练

tic

[net1,tr1]=train(net,inputs,targets);

t1=toc;

disp(['单线程神经网络的训练时间为',num2str(t1),'秒']);

单线程神经网络的训练时间为0.93209秒

并行网络训练

tic

[net2,tr2]=train(net,inputs,targets,'useParallel','yes','showResources','yes');

t2=toc;

disp(['并行神经网络的训练时间为',num2str(t2),'秒']);

ComputingResources:

ParallelWorkers:

Worker1onWang_Matlab,MEXonPCWIN

Worker2onWang_Matlab,MEXonPCWIN

Lab1:

TrainingwithTRAINLM.

Epoch0/1000,Time0.096,Performance7115.2407/0,Gradient12833.5776/1e-07,Mu0.001/10000000000,ValidationChecks0/6

Epoch12/1000,Time0.397,Performance5.1658/0,Gradient3.4342/1e-07,Mu0.01/10000000000,ValidationChecks6/6

TrainingwithTRAINLMcompleted:

Validationstop.

并行神经网络的训练时间为2.2013秒

网络效果验证

outputs1=sim(net1,inputs);

outputs2=sim(net2,inputs);

errors1=gsubtract(targets,outputs1);

errors2=gsubtract(targets,outputs2);

performance1=perform(net1,targets,outputs1)

performance2=perform(net2,targets,outputs2)

performance1=

19.6247

 

performance2=

14.5379

神经网络可视化

figure,plotperform(tr1);

figure,plotperform(tr2);

figure,plottrainstate(tr1);

figure,plottrainstate(tr2);

figure,plotregression(targets,outputs1);

figure,plotregression(targets,outputs2);

figure,ploterrhist(errors1);

figure,ploterrhist(errors2);

matlabpoolclose

Sendingastopsignaltoalltheworkers...stopped.

 

 

 

 

 

 

 

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 初中教育 > 语文

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1