No validation and test set in feedforwardnet
Mostrar comentarios más antiguos
Hello. I'm training a feedforwardnet to approximate y = sin(x^2) and I've noticed something strange going on. When I use con2seq, the data is not automatically split in train, validation and test sets, so the network overfits easily (see pictures below). This happens for all training algorithms. Without con2seq there are 3 sets, but the training accuracy is always much worse. Any ideas as to what may be causing this? Thanks!
Code with con2seq:
x = 0:0.1:3*pi;
y = sin(x.^2);
x = con2seq(x);
y = con2seq(y);
net = feedforwardnet(30,'trainlm');
net.trainParam.epochs = 200;
[net, tr] = train(net, x, y);
targets_hat = sim(net, inputs);

Same, but without con2seq:
x = 0:0.1:3*pi;
y = sin(x.^2);
net = feedforwardnet(30,'trainlm');
net.trainParam.epochs = 200;
[net, tr] = train(net, x, y);
targets_hat = sim(net, inputs);

3 comentarios
Greg Heath
el 13 de Mzo. de 2018
1. Always begin with the function examples
help feedforwardnet
doc feedforwardnet
2. Always initialize the RNG at the beginning of the code.
rng('default')
[x,t] = simplefit_dataset;
net = feedforwardnet(10);
net = train(net,x,t);
view(net)
y = net(x);
perf = perform(net,t,y)
perf =
1.4639e-04
3. Check to make sure you know what the performance function is
e = t-y ; % error
MSE = mse(e) % 1.4639e-04
4. Normalize the mse by comparing with the simple model where the output is assumed to be the average of the target rows and the corresponding mse is just the mean of the the target row variances:
y0 = mean(t,2) % 5.7254
MSE0 = mse(t-y0) % 8.3378
check = MSE0 - mean(var(t',1)) % 0
NMSE = MSE/MSE0 % 1.7558e-05
5. NOTE: Rsquare = 1 - NMSE (See Wikipedia)
6. Now repeat with your own data.
7. In general, I use a double for loop over a. number of hidden nodes (outer loop) b. random initial weights (inner loop)
The goal is to minimize the number of hidden nodes subject to an upper bound NMSE <= 0.01 (Rsquare >= 0.99)
I have posted zillions of examples in both the NEWSGROUP (comp.soft-sys.matlab) and ANSWERS.
Hope this helps.
Greg
Olga Kravchenko
el 13 de Mzo. de 2018
Osama Tabbakh
el 20 de Mzo. de 2019
I have the same problem, there is no test and validation, when I use con2seq.
p %% input
p = con2seq (p);
t %% target or output
t = con2seq (t);
net = newff(p,t,[2 2]);
net.divideParam.trainRatio=0.7;
net.divideParam.testRatio=0.15;
net.divideParam.valRatio=0.15;
net.trainParam.lr=0.01;
net.trainParam.min_grad=1e-20;
net.trainParam.goal=1e-30;
net.trainParam.epochs=200;
net = train(net,p,t);
Unfortunately, I can't train without con2seq, because the Input and the target have different size.
Respuestas (0)
Categorías
Más información sobre Deep Learning Toolbox en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!