- Increase number of Layers
- Increase number of Parameters
- add an Activation layer to handle nonlinearity
- you might also give more iterate to network for learning , maxepoch=2000 since your data and network are small.
How to use deep learning for interpolation properly
13 views (last 30 days)
Alexey Kozhakin on 29 Nov 2021
What I do wrong? I try to apply deep learning for interpolation function sin. And It learns not good. Insted of sin its just show line function. This is my code
%----- normalization ---------------
%---------- end normalization -----
layers = [
options = trainingOptions('adam', ...
[net inf] = trainNetwork(x',y',layers,options);
y1 = predict(net,x');
figure(2); hold on;
Abolfazl Chaman Motlagh on 30 Nov 2021
The Sin(x) function is a complete nonlinear function, on the other hand your network is too simple to handle such a nonlinearity. for overcoming this problem you can:
here a simple solution for your model:
layers = [
the result is (5 fully connected layer with 20 parameters)
here are some other examples:
(2 fully connected layer each with 200 parameters) ( you can see still not converge correctly)
(3 fully connected layer each with 5 parameters)
so you can change this parameters (even change layers parameters indivisually) to see what is best option for your application.