How to apply neural networks for multiple experimental data

3 次查看(过去 30 天)
Hi all,
I am trying fit multiple experimental curves simultaneously by keeping the parameters constant for all the curves. This is a sample of code from Abaqus2matlab toolbox tutorial which I am modifying for my problem. Please see the attched code. I am using cell arrays for inputs ans targets because I have multiple experimental data which I feed into targets. Each cell element represents one set of experimental data. The Inputs are same for all the targets.
trainFcn = 'trainbr';
hiddenLayerSize = 10;
net = fitnet(hiddenLayerSize,trainFcn);
[net,tr] = train(net,INPUTS,Stress_direction);
% The dimensions are INPUTS{{8*10},{8*10}} I have 8 inputs with 10 samples
% Stress_direction{{12*10},{12*10}} The outputs are 12 with 10 samples
y = net(INPUTS);
e = gsubtract(Stress_direction,y);
performance = perform(net,Stress_direction,y);
funt=@(GT) (sum((net([GT(1);GT(2);GT(3);GT(4);GT(5);GT(6);GT(7);GT(8)])-Stress_exp_points1').^2)...
+sum((net([GT(1);GT(2);GT(3);GT(4);GT(5);GT(6);GT(7);GT(8)])-Stress_exp_points2').^2))...
/(sum(Stress_exp_points111.^2)+sum(Stress_exp_points123.^2));
% The objective function is the cummulative sum of errors in all experimental data sets
LB=[0.05,0.05,0.3,0.2,0.1,0.2,10,0.8E-05];
UB=[0.25,0.25,0.8,0.5,0.25,0.6,35,2.5E-05];
% LB and UB are the lower and upper bound for the 8 input parameters/values.
% x0_() is the some input value which is given to objective function for minimization
% Optimal_values are the optimized parameters
[Optimal_values,~]=fminsearchbnd(funt,x0_(Nsamples,:),LB,UB);
Can anyone give me suggestion for the following issues I am facing?
  1. Is my objective function correct? or do I need to use separate objective functions for all the experiments and optimize them simultaneously.
  2. Since the INPUTS are cell array the y is also a cell array. All the elements in y are same. How is it possible? Since their target cell arrays are different y also must vary right. Please correct me if I am wrong.
Thanks in advace.
Regards,
Bharat

回答(1 个)

George Papazafeiropoulos
编辑:George Papazafeiropoulos 2019-6-28
Dear Bharat,
I have checked your code segment and I have assigned arbitrary values to the variables that are undefined in it. I have also changed the optimization functions to fmincon with the appropriate modifications since fminsearchbnd is not part of the Matlab optimization toolbox. The modified code segment runs perfectly and is shown below:
global Stress_exp_points1 Stress_exp_points2 net
Stress_exp_points1=(1:12);
Stress_exp_points2=(13:24);
% The dimensions are INPUTS{{8*10},{8*10}} I have 8 inputs with 10 samples
% Stress_direction{{12*10},{12*10}} The outputs are 12 with 10 samples
INPUTS=reshape(1:80,8,10);
INPUTS={INPUTS,INPUTS};
Stress_direction=reshape(1:120,12,10);
Stress_direction={Stress_direction,Stress_direction};
trainFcn = 'trainbr';
hiddenLayerSize = 10;
net = fitnet(hiddenLayerSize,trainFcn);
[net,tr] = train(net,INPUTS,Stress_direction);
y = net(INPUTS);
y{1,1}
y{1,2}
e = gsubtract(Stress_direction,y);
performance = perform(net,Stress_direction,y);
% The objective function is the cumulative sum of errors in all experimental data sets
funt=@objfun;
LB=zeros(1,8);
UB=80*ones(1,8);
% LB and UB are the lower and upper bound for the 8 input parameters/values.
% Optimal_values are the optimized parameters
x0_=LB+(UB-LB).*rand(1,8);
funt(x0_)
[Optimal_values,fval,exitflag,output]=fmincon(funt,x0_,[],[],[],[],LB,UB);
result1=net(Optimal_values')
funt(Optimal_values)
In addition, the function objfun.m is needed the source code of which is as follows:
function y = objfun(GT)
global Stress_exp_points1 Stress_exp_points2 net
y=(sum((net([GT(1);GT(2);GT(3);GT(4);GT(5);GT(6);GT(7);GT(8)])-...
Stress_exp_points1').^2)...
+sum((net([GT(1);GT(2);GT(3);GT(4);GT(5);GT(6);GT(7);GT(8)])-Stress_exp_points2').^2))...
/(sum(Stress_exp_points1.^2)+sum(Stress_exp_points2.^2));
end
I would like to highlight the following:
1) The objective function that you have defined works perfectly, since exitflag=1 after the code has executed. Also, it seems that Optimal_values takes values within the upper and lower bounds, and fval is relatively small as well.
2) y should take the values contained in Stress_direction, and it indeed does. The entries in the arrays contained in y are not identical.
3) You can define alternative objective functions by appropriately modifying the code in the function objfun.m. Any alternative objective function definition should lead to minimization of the function funt.
Best regards,
George

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by