Neural Network Activation function

45 views (last 30 days)
I have 3 input hidden layer and 1 output layer.
I want to set the activation function for input layer as purelin
and output layer as tansig/purelin in 2 different models.
How can I set the above conditions?

Accepted Answer

Chunru
Chunru on 5 Jul 2022
net = feedforwardnet([10 20]); % 2 hidden, 1 output layers
% specify the transfer function as you want
% Usually, layer1 will not be pureli
net.layers{1}.transferFcn = 'tansig'; % hidden layer 1
net.layers{2}.transferFcn = 'tansig'; % hidden layer 2
net.layers{3}.transferFcn = 'purelin'; % output layer
net
net = Neural Network name: 'Feed-Forward Neural Network' userdata: (your custom info) dimensions: numInputs: 1 numLayers: 3 numOutputs: 1 numInputDelays: 0 numLayerDelays: 0 numFeedbackDelays: 0 numWeightElements: 230 sampleTime: 1 connections: biasConnect: [1; 1; 1] inputConnect: [1; 0; 0] layerConnect: [0 0 0; 1 0 0; 0 1 0] outputConnect: [0 0 1] subobjects: input: Equivalent to inputs{1} output: Equivalent to outputs{3} inputs: {1x1 cell array of 1 input} layers: {3x1 cell array of 3 layers} outputs: {1x3 cell array of 1 output} biases: {3x1 cell array of 3 biases} inputWeights: {3x1 cell array of 1 weight} layerWeights: {3x3 cell array of 2 weights} functions: adaptFcn: 'adaptwb' adaptParam: (none) derivFcn: 'defaultderiv' divideFcn: 'dividerand' divideParam: .trainRatio, .valRatio, .testRatio divideMode: 'sample' initFcn: 'initlay' performFcn: 'mse' performParam: .regularization, .normalization plotFcns: {'plotperform', 'plottrainstate', 'ploterrhist', 'plotregression'} plotParams: {1x4 cell array of 4 params} trainFcn: 'trainlm' trainParam: .showWindow, .showCommandLine, .show, .epochs, .time, .goal, .min_grad, .max_fail, .mu, .mu_dec, .mu_inc, .mu_max weight and bias values: IW: {3x1 cell} containing 1 input weight matrix LW: {3x3 cell} containing 2 layer weight matrices b: {3x1 cell} containing 3 bias vectors methods: adapt: Learn while in continuous use configure: Configure inputs & outputs gensim: Generate Simulink model init: Initialize weights & biases perform: Calculate performance sim: Evaluate network outputs given inputs train: Train network with examples view: View diagram unconfigure: Unconfigure inputs & outputs

More Answers (0)

Categories

Find more on Deep Learning Toolbox in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!