zoukankan      html  css  js  c++  java
  • 神经网络rbf

    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])
    

     

  • 相关阅读:
    声明式编程和命令式编程的比较
    函数式编程
    读《暗时间》
    动态语言和静态语言的比较
    2013第二次实训
    for惠普2013实习生
    bat的大数据
    android stduio优化
    当move手势太快,降低频率
    ANR没root的时候处理*(转)
  • 原文地址:https://www.cnblogs.com/TheoryDance/p/6135627.html
Copyright © 2011-2022 走看看