神经网络训练:
% 生成训练数据
x = 1 : 0.01 : 10
y = 1.1 * x.^3 + 2.1 * x.^2 + 3.1 * x + 1.2;
len = length(x);
% 训练数据归一化
min_x = min(x);
max_x = max(x);
min_y = min(y);
max_y = max(y);
normal_x = (x - repmat(min_x, len, 1)) ./ repmat((max_x - min_x), len, 1);
normal_x = normal_x';
normal_y = (y - repmat(min_y, len, 1)) ./ repmat((max_y - min_y), len, 1);
% 开始训练
Iterations = 1000;
Batch = 400;
lr = 0.8;
input = 1;
hide = 4;
output = 1;
% 权重参数初始化
w_ik = rand(input, hide);
bias1 = rand(1, hide);
w_km = rand(hide, output);
bias2 = rand(1, output);
grad_w_ik = zeros(input, hide);
grad_w_km = zeros(hide, o
|