0

我正在使用 Masayuki Tanaka 在以下链接https://www.mathworks.com/matlabcentral/fileexchange/42853-deep-neural-network开发的深度神经网络工具箱。

现在我正在尝试使用深度信念网络来进行函数逼近。但结果不是很好。以下是我的脚本代码。有谁可以弄清楚可以修改哪个部分以改善拟合结果?

%% Environment Settings
clear all;
close all;
clc;

rng(42);

addpath DBNLib

%% Define function to be learned and generate test and training data
num_points = 1000;

lower_bound = -2*pi;
upper_bound = 2*pi;
X_all = (upper_bound-lower_bound).*rand(num_points, 1) + lower_bound;
Y_all = cos(X_all) + 0.1*randn(num_points, 1);
Y_all = Y_all;

train_split = 0.8;
train_size  = train_split*num_points;
X_train = X_all(1:train_size);
Y_train = Y_all(1:train_size);
X_test  = X_all(train_size+1:end);
Y_test  = Y_all(train_size+1:end);

% Plot train and test data
scatter(X_train, Y_train, 'g', 'filled'),hold on
scatter(X_test, Y_test, 'r', 'filled'), grid minor
drawnow;

%% Construct deep belif network model
nodes = [1 64 64 1];
dnn = randDBN( nodes , 'GBDBN' );
nrbm = numel(dnn.rbm);

opts.MaxIter = 200;
opts.BatchSize = train_size/8;
opts.Verbose = true;
opts.StepRatio = 0.01;
opts.DropOutRate = 0.5;
opts.Object = 'Squares';

% opts.Layer = nrbm-1;
dnn = pretrainDBN(dnn, X_train, opts);
dnn= SetLinearMapping(dnn, X_train, Y_train);

opts.Layer = 0;
dnn = trainDBN(dnn, X_train, Y_train, opts);
rmse = CalcRmse(dnn, X_train, Y_train);
rmse

estimate = v2h( dnn, X_all);
scatter(X_all, estimate, 'b', 'filled')
legend('train', 'test', 'DBN Fit')

DBN学习结果:

DBN学习结果

4

1 回答 1

0

是否有可能您已经扩展了输入和目标来训练您的网络,而您忘记在输出时重新扩展预测?

于 2018-01-03T06:06:00.347 回答