Вы находитесь на странице: 1из 2

% % % Reference webpage:http://in.mathworks.

com/help/nnet/ug/create-and-
train-custom-neural-network-architectures.html
% % % Reference webpage:http://in.mathworks.com/help/nnet/ug/neural-network-
subobject-properties.html
input_peri(1,:)=[1:36];
input_peri(2,:)=[37:72];
input_peri(3,:)=[8:43];
input_peri(4,:)=[12:47];
output_peri(1,:)=[0:35];
tic
% % % Creating the network named net
net=network;
% % % Specifying number of input vectors in the network
net.numInputs=4;
% % % Specifying number of layers in the network
net.numLayers=2;
% % % Specifying that bias is connected to both first and second layer
net.biasConnect(1)=1;
net.biasConnect(2)=1;
% % % Specifying first to fourth input vectors are connected to layer one
net.inputConnect(1,1)=1;
net.inputConnect(1,2)=1;
net.inputConnect(1,3)=1;
net.inputConnect(1,4)=1;
% % % Specifying output of first (hidden) layer are connected to input of 2nd
layer
net.layerConnect(2,1)=1;
% % % Specifying second layer is connected to output
net.outputConnect=[0 1];
% % % Specifying values and preprocessed functions to each four input
% % % vectors. These are taken to be removeconstantrows and mapminmax for all
% % % for vectors.
% % % % % First input vector comprise distance of all intersecting points
from
% % % neutral axis. Second input vector is distance of all intersecting
points
% % % from centroid. Third input vector comprises values of normal strain at
% % % all intersecting points. Fourth input vector comprises values of shear
% % % strain at all intersecting points. These inputs are for periosteal
% % % surface only
net.inputs{1}.exampleInput = input_peri(1,:);
net.inputs{1}.processFcns = {'removeconstantrows','mapminmax'};
net.inputs{2}.exampleInput = input_peri(2,:);
net.inputs{2}.processFcns = {'removeconstantrows','mapminmax'};
net.inputs{3}.exampleInput = input_peri(3,:);
net.inputs{3}.processFcns = {'removeconstantrows','mapminmax'};
net.inputs{4}.exampleInput = input_peri(4,:);
net.inputs{4}.processFcns = {'removeconstantrows','mapminmax'};
% % Specifying number of neurons in first layer
net.layers{1}.size = 5;
% % % Specifying transfer function for first layer
net.layers{1}.transferFcn = 'tansig';
% % % Specifying initialization function of weights and biases for first
layer
net.layers{1}.initFcn = 'initnw';
% % % Specifying number of neurons in second layer
net.layers{2}.size =1;
% % % Specifying transfer function for second layer
net.layers{2}.transferFcn = 'purelin';
% % % Specifying initialization function of weights and biases for second
layer
net.layers{2}.initFcn = 'initnw';
% % % Specifying output vector and its preprocessed functions

net.outputs{2}.exampleOutput = output_peri(1,:);
net.outputs{2}.processFcns = {'removeconstantrows','mapminmax'};
%
% % % Set the initialization function to initlay so the network
% % % initializes itself according to the layer initialization functions
% % % already set to initnw
net.initFcn = 'initlay';
%
% % % % Dividing data randomly
net.divideFcn = 'dividerand';
net.divideMode = 'sample'; % Divide up every sample
net.divideParam.trainRatio = 97/100;
net.divideParam.valRatio = 0/100;
net.divideParam.testRatio = 3/100;
% % % % Set the performance function to mse (mean squared error) and
% % % % the training function to trainlm (Levenberg-Marquardt
backpropagation)
% % % % to meet the final requirement of the custom network
net.performFcn = 'mse';
net.trainFcn = 'trainlm';
% % % % Set the plot functions to plotperform (plot training, validation
% % % % and test performance) and plottrainstate (plot the state of the
training
% % % % algorithm with respect to epochs).
net.plotFcns =
{'plotperform','plottrainstate','ploterrhist','plotregression', 'plotfit'};
% % % % Initializing the network
net = init(net);
X=[input_peri(1,:);input_peri(2,:);input_peri(3,:);input_peri(4,:)];
T=output_peri(1,:);

net = train(net,X,T);
Y=sim(net,X)
net
view(net)
error=Y-T
plot(Y,T)
toc

Вам также может понравиться