Question

I'm trying to create the neural network shown below. It has 3 inputs, 2 outputs, and 2 hidden layers (so 4 layers altogether, or 3 layers of weight matrices). In the first hidden layer there are 4 neurons, and in the second hidden layer there are 3. There is a bias neuron going to the first and second hidden layer, and the output layer.

enter image description here

I have tried using the "create custom neural network" function in MATLAB, but I can't get it to work how I want it to.

This is how I used the function

net1=network(3,3,[1;1;1],[1,1,1;0,0,0;0,0,0],[0,0,0;1,0,0;0,1,0],[0,0,0])
view(net1)

And it gives me the neural network shown below:

enter image description here

As you can see, this isn't what I want. There are only 3 weights in the first layer, 1 in the second, 1 in the output layer, and only one output. How would I fix this?

Thanks!


Just to clarify how I want this network to work:

  • The user will input 3 numbers into the network.
  • Each one of the 3 inputs is multiplied by 4 different weights, and then these numbers are sent to the 4 neurons in the first hidden layer.
  • The bias node acts the same as one of the inputs, but it always has a value of 1. It is multiplied by 4 different weights, and then sent to the 4 neurons in the first hidden layer.
  • Each neuron in the first hidden layer sums the 4 numbers going into it, and then passes this number through the sigmoid activation function.
  • The neurons in the first hidden layer then output 4 numbers that are each multiplied by 3 different weights, and sent to the 3 neurons in the second hidden layer.
  • The bias node going to the second hidden layer works the same as the first bias node
  • Each neurons in the second hidden layer sums up the 5 numbers going into it and passes it through the sigmoid activation function.
  • The neurons in the second layer then output two numbers that are again multiplied by weights and go to each of the outputs
  • The output layer also sums all of its inputs, including its bias input, and then passes this through the sigmoid activation function to get the final two values.
Was it helpful?

Solution

After some time playing around I've figured out how to do it. The code I needed to use is:

net = newff([0 1; 0 1; 0 1],[4,3 2],{'logsig','logsig','logsig'})
view(net)

This creates the network I was looking for.

enter image description here

I was originally mistaken about the matlab representation of neural networks. The green arrows show the path of all of the numbers, not just a single number.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top