0
votes

I am very new to MatLab. I got a task for modelling non-linear regression using neural network in MatLab.

I need to create a two-layer neural network where:

  1. The first layer is N neurons with sigmoid activation function.

  2. The second layer is layer with one neuron and a linear activation function.

Here is how I implemented the network:

net = network(N, 2);
net.layers{1}.transferFcn = 'logsig';
net.layers{1}.size = N
net.layers{2}.size = 1;

Is this implementation correct? How should I assign the linear activation function to the second layer?

2

2 Answers

0
votes

A quick reading of the Matlab help on the nntransfer function gives you the list of all possible transfer functions you can use. In your case I think you should either try the poslin (positive linear) or the purelin one (pure linear).

When you have such questions, the best way is actually to 'ask' Matlab the possibilities you have. In this case, I just typed net.layers{2} in the Matlab console window. This displays the list of the parameters of the 2nd layer. Then, you just click on the link TransferFcn and the Matlab help with the possible options for this parameter value automatically opens. This works for any parameter of your neural network ;)

0
votes

You didn't determine the transfer function for the second layer.

net.layers{2}.transferFcn='pureline'

The rest is OK.