MATLAB Answers

Is it necessary to set net.inputs​{i}.proces​sFcns when the network is created using netwok command?

34 views (last 30 days)
Vishakha Ranade
Vishakha Ranade on 20 Aug 2020
Answered: Pranav Verma on 27 Aug 2020
I have created a network using following code-
net10_1 = network;
net10_1.numInputs = 2; %2 inputs
net10_1.numLayers = 3; %3 layers
net10_1.biasConnect(2) = 1; %bias for second hidden layer
net10_1.inputConnect = [1 1;0 1;0 0]; %second input to both hidden layers
net10_1.layerConnect = [0 0 0;1 0 0;0 1 0];
net10_1.outputConnect = [0 0 1]; %output from last layer
net10_1.layers{1}.size = 5; %5 neurons in first hidden layer
net10_1.layers{1}.transferFcn = 'tansig';
net10_1.layers{1}.initFcn = 'initnw';
net10_1.layers{2}.size = 5; %5 neurons in second hidden layer
net10_1.layers{2}.transferFcn = 'tansig';
net10_1.layers{2}.initFcn = 'initnw';
net10_1.layers{3}.size = 2;
%set the range of inputs to 0-1
net10_1.inputs{1}.exampleInput = [0 100 499];
net10_1.inputs{2}.exampleInput = [0 10 117];
net10_1.inputs{1}.ProcessFcns = {'mapminmax'};
net10_1.inputs{1}.ProcessParams{1}.ymin = 0;
net10_1.inputs{1}.ProcessParams{1}.ymax = 1;
net10_1.inputs{2}.ProcessFcns = {'mapminmax'};
net10_1.inputs{2}.ProcessParams{1}.ymin = 0;
net10_1.inputs{2}.ProcessParams{1}.ymax = 1;
net10_1.outputs{3}.exampleOutput = [0 100 428;0 15 34];
net10_1.outputs{3}.ProcessFcns = {'mapminmax'};
net10_1.outputs{3}.ProcessParams{1}.ymin = 0;
net10_1.outputs{3}.ProcessParams{1}.ymax = 1;
net10_1.initFcn = 'initlay';
net10_1.performFcn = 'mse';
net10_1.trainFcn = 'trainlm';
net10_1.divideFcn = 'dividerand';
net10_1.divideParam.trainRatio = 0.75;
net10_1.divideParam.valRatio = 0.15;
net10_1.divideParam.testRatio = 0.10;
net10_1.trainParam.goal = 0.01;
I am training the network using
'trainlm'
. My question is -
  1. Is it necessary to set the net.inputs{i}.processFcns and similarly for outputs or will it be done automatically by MATLAB training procedure?
  2. The readonly variable inputs{i}.processSettings doesn't show me any function or value though I have initialized exampleInput. Why is that?
  3. How to verify that internally the data is being pre and post processed?

  0 Comments

Sign in to comment.

Answers (1)

Pranav Verma
Pranav Verma on 27 Aug 2020
Hi Vishakha,
Answering to the questions in order,
  1. Yes, it is required to set the net.inputs{i}.processFcns value in your network since you are setting the ProcessParams{1}.ymin & ProcessParams{1}.ymax and hence you will be needed to specify the processFcns to the appropriate processing function. For feed forward networks, the default input processing functions are removeconstantrows and mapminmax. For outputs, the default processing functions are also removeconstantrows and mapminmax.
  2. If you set the exampleInput property, the range, size, processedSize, and processedRange properties will automatically be updated to match the properties of the value of exampleInput. After setting the exampleInput property, the processSettings property will be converted to a "1x1 cell array". If you still see it as "0x0 cell array", try re running the code and then checking the properties by typing net10_1.inputs{1}.processSettings.
  3. Preprocessing and postprocessing will be done automatically. If no processFcns value is defined, default processing functions are used for the same.
To see the properties associated with the ith input, type:
net10_1.inputs{1} %for 1st network input
To specifically see the processSettings, type:
net10_1.inputs{1}.processSettings %for 1st network input
Please refer to the below documentations to read about the properties of the networks and input output functions.
Defining the properties of custom networks:
Choosing the input output functions:
Network subobject properties:

  0 Comments

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by