码迷,mamicode.com
首页 > 其他好文 > 详细

神经网络rbf

时间:2016-12-05 23:12:28      阅读:285      评论:0      收藏:0      [点我收藏+]

标签:gen   div   atl   tin   mesh   com   data   row   .com   

clc;
clear;
close all;

ld=400; %定义学习样本的数量
x=rand(2,ld); %得到一个2 * 400的一个矩阵,每个元素在0-1之间
x=(x-0.5)*1.5*2; %-1.5, 1.5
x1=x(1,:); %得到矩阵的第1行
x2=x(2,:); %得到矩阵的第2行
F=20+x1.^2-10*cos(2*pi*x1)+x2.^2-10*cos(2*pi*x2); %定义样本输出


%训练网络
net=newrb(x,F);

%generate the testing data
interval=0.1;
[i, j]=meshgrid(-1.5:interval:1.5);
row=size(i); 
tx1=i(:); %列矩阵
tx1=tx1‘; %变为行矩阵
tx2=j(:);
tx2=tx2‘;
tx=[tx1;tx2]; %2 * n的矩阵 ,作为测试网络的输入数据

%testing
ty=sim(net,tx); %调用网络,得到对应的输出结果
% 画出网络得到的结果
v=reshape(ty,row);
figure
subplot(1,3,2)
mesh(i,j,v);
zlim([0,60])

%plot the original function
interval=0.1;
[x1, x2]=meshgrid(-1.5:interval:1.5);
F = 20+x1.^2-10*cos(2*pi*x1)+x2.^2-10*cos(2*pi*x2);
subplot(1,3,1)
mesh(x1,x2,F);
zlim([0,60])

%plot the error
subplot(1,3,3)
mesh(x1,x2,F-v);
zlim([0,60])

 技术分享

神经网络rbf

标签:gen   div   atl   tin   mesh   com   data   row   .com   

原文地址:http://www.cnblogs.com/TheoryDance/p/6135627.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!