Change the transfer functions within the same layer for different neurons of a neural network?

13 次查看(过去 30 天)
I do know how to set the transfer function for a single hidden layer as a whole, my question if I can set the transfer function to individual neurons or a set of neurons in a hidden layer differently from the rest
For example : If I have 40 neurons in a hidden layer, can I set the transfer function for 10 of them as tansig and 15 of them as logsig and maybe keep the rest as pure linear or something?
I read in the book NN Design by Dr. Hagan that it is theoretically possible to do so
I was wondering if it can be done in MATLAB.
The above is the link to a similar question but unfrotunately, the answer did not get accepted
Any help would be appreciated
Thanks

回答(1 个)

Sai Sumanth Korthiwada
To set the transfer function for individual neurons or a set of neurons, there are no inbuilt functions which can leverage the functionality. However, a typical procedure can be followed to obtain a similar network. A separate hidden layer as an individual layer can be used by connecting two or more of these individual hidden layers parallelly to both the input and output layers. But, the number of output layers will be equal to the number of individual hidden layers with different transfer functions.
For example:
Consider the requirement is to set three different transfer functions for a single layer containing 40 neurons.
Create a neural network which contains a total of 1 input, 3 hidden, 3 output layers. The first hidden layer of 15 neurons is set with a transfer function as "tansig", the second hidden layer of 10 neurons is set with a transfer function as "logsig" and the third hidden layer of 15 neurons is set with a transfer function as "purelin". By connecting the input and output layers with these individual hidden layers parallelly i.e., hidden layers one below another, input to the left and outputs to the right of the network, it functions as a single hidden layer with 3 different transfer functions. But the hidden layers get connected to three different output layers.
The corresponding code is displayed below:
net = network;
net.numInputs = 1;
net.numLayers = 3;
% three layers with different transfer functions
net.layers{1}.transferFcn = 'tansig';
net.layers{2}.transferFcn = 'logsig';
net.layers{3}.transferFcn = 'purelin';
net.inputConnect(1,1)=1;
net.inputConnect(2,1)=1;
net.inputConnect(3,1)=1;
net.outputConnect([1,2,3])=1;
% to view the network
view(net)
Output:
So, if the requirement is to have a single output layer with different transfer functions in a single hidden layer, it is not possible to generate using "network" function.

类别

Help CenterFile Exchange 中查找有关 Sequence and Numeric Feature Data Workflows 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by