资源简介
ANN程序 MATLAB语言 用于数据处理 只要换数据就能用
代码片段和文件信息
clc;clear;close all
disp(‘PLS预测的RMSECVRMSEP训练集及预测集的R‘)
load TenSesameAddSoybeanOil_NIR_20150121
meanornot = 1;
mean_method = 1;
switch mean_method
case 1
for i = 1:50
Spectra(i:)= mean(spectra(3*i-2:3*i:));
end
Target = target;
case 2
Spectra = spectra;
Target((3*i-2):(3*i)) = target(i);
end
for columm = 1;
name = ynames;
disp(name{columm});
%-----------------KS对数据划分,训练集2/3,预测集1/3-------------------------
[mn] = size(cal);
[modeltest] = kenstone(calfloor(2/3*m));
x_train = cal(model:);
x_pred = cal(test:);
y_train = caltar(modelcolumm);
y_pred = caltar(testcolumm);
[m_trainn_train] = size(x_train);
%———————————----——数据中心化—————————--------------------
pretreatment = 3;%对于ANN,采用第2个中心化最好
switch pretreatment;
case 1 %中心化
mean_x_train = mean(x_train);
x_train = x_train - repmat(mean_x_trainsize(x_train1)1);
x_pred = x_pred - repmat(mean_x_trainsize(x_pred1)1);
mean_y_train = mean(y_train);
y_train = y_train - repmat(mean_y_trainsize(x_train1)1);
case 2 %Normalize
std_x_train = std(x_train01);
mean_x_train = mean(x_train1);
std_y_train = std(y_train01);
mean_y_train = mean(y_train);
y_train = (y_train - repmat(mean_y_trainsize(y_train1)1))./repmat(std_y_trainsize(y_train1)1);
x_train = (x_train-repmat(mean_x_trainsize(x_train1)1))./repmat(std_x_trainsize(x_train1)1);
x_pred = (x_pred-repmat(mean_x_trainsize(x_pred1)1))./repmat(std_x_trainsize(x_pred1)1);
case 3 %最大最小归一化
[train_xps_x] = mapminmax(x_train‘);
[train_yps_y] = mapminmax(y_train‘);
x_train = train_x‘;
y_train = train_y‘;
pred_x = mapminmax(‘apply‘x_pred‘ps_x);
x_pred = pred_x‘;
y_pred = mapminmax(‘apply‘y_predps_y);
end
%-------------------------BP-ANN外部预测------------------------------------
disp(‘BP-ANN直接预测‘); %学习速率,动量项,隐含层节点数为nodenumber
net = newff(minmax(x_train‘)[nodenumber1]{‘tansig‘‘purelin‘}‘traingdm‘);
%训练函数trainlm使用的学习算法为Levenberg-Marquadt,优点收敛速度快
%训练函数traingd使用的学习算法是梯度下降法,收敛速度很慢
%动量BP算法:训练函数traingdm(Gradient descent with momentum backpropagation)
%弹性BP算法:训练函数traingrp()
%准牛顿BP算法:训练函数trainbfg()
inputWeights = net.IW{11};
inputbias = net.b{1};
layerWeights = net.LW{21};
layerbias = net.b{2};
%net.trainParam.show = 50; %训练显示间隔
net.trainParam.lr = 0.01; %学习速率Learning rate,默认值0.01
%net.trainParam.mc = 0.9; %动量项Momentum constant,默认值0.9
net.trainParam.epochs = 2000; %最大训练次数
net.trainParam.goal = 1e-3;
[nettr]
相关资源
- canny边缘检测的matlab程序
- Mann-Kendall趋势检验程序-Matlab代码
- 采用格子bolzmann方法MATLAB模拟圆柱绕流
- 边缘检测中的canny算法及其matlab实现
- ADRC controler using ANN 单神经元自抗扰控
- DIP 包含二值化、canny算子边缘检测、
- 基于改进的人工势场法的机器人路径
- Mann-mandall趋势检验 (Pettitt and Mk)
- 信号的功率谱香农熵和功率谱指数熵
- mann-kendall趋势检验和突变点分
- 解决含有运动力学约束的路径规划问
- matlab信道模型
- FBMC and OFDM channels-comparison FBMC和OFDM的
- 3DMIMOchannel--3DMIMO
- PSO-of-Robot-Path-planning PSO粒子群算法
- 路径规划matlab仿真程序-Q-Learing-path-
- channel-estimation 多径信道的mvu和mmse估计
- MIMO_SparseChannel 多发多收的稀疏信道估
- passage-3 本程序是mazen.O的经典论文:
- underwater-acoustic-channel-modeling 关于水声
- synchronization 利用matlab仿真实现载波的
- ANN_PID6
- darkchannel 用MATLAB实现的darkchannel算法
- canny 自己实现的canny边缘检测算子
- robot_motion_planning
- matlabpathplanning1
- pathplann-algorithm
- darkchannel 用matlab实现了暗通道图像增
- LTE_channel_estimation 基于3GPP LTE系统的
- PLC-simulation-matlab
评论
共有 条评论