# In a single neuron output layer should the output be a scalar?

Given a neural network with 3 inputs, 4 hidden layers, and 1 output, should the output neuron be a vector or a scalar? I thought that at the end of the summation only one number between 0 and 1 would be left over for each neuron in the last output layer but my program returns a 1x4 vector.

class Network:
def __init__(self, inputs, layers):
# each neuron has n weights attached
# each neuron has a bias
self.weights = []
self.biases = [np.random.randn(y,1) for y in layers[1:]]
# did this to connect neurons excluding input layer and last neuron
# because last neuron isn't connecting anything in front
for x,y in zip(layers[:-1], layers[1:]):
self.weights.append(np.random.randn(y,x))

# add bias vector to previous vector matrix product
def forward(self, inputs):
for b,w in zip(self.biases, self.weights):
inputs = sigmoid(np.dot(w, inputs) + b)
print("layer",inputs)
self.output = inputs
print("output",self.output)

input = [random.randrange(256),random.randrange(256),
random.randrange(256)]

net = Network(input, [3,4,4,1])
net.forward(input)


Output

layer [[7.80671510e-176 2.86955013e-159 1.00000000e+000 9.10681919e-004]
[8.91574010e-176 3.27719954e-159 1.00000000e+000 1.03991921e-003]
[3.44313504e-176 1.26560896e-159 1.00000000e+000 4.01858875e-004]
[1.43702955e-175 5.28215553e-159 1.00000000e+000 1.67506508e-003]]
layer [[0.79051612 0.79051612 0.91469971 0.79084515]
[0.80073915 0.80073915 0.70932703 0.80058277]
[0.35187686 0.35187686 0.00982275 0.35113385]
[0.51881022 0.51881022 0.55334083 0.5188783 ]]
layer [[0.26291072 0.26291072 0.16592316 0.26264314]]
output [[0.26291072 0.26291072 0.16592316 0.26264314]]


If my output is supposed to decide whether the neuron fires, how could I use the vector to determine this?

Look, your code says your network has many outputs. Look at the two lines below. This two lines says the output depends on the dimension of np.dot(w, inputs). In your case it's 4 diminutional vector. And in the last line you are assigning them as output. You can write self.output = sigmoid(np.dot(new_weihts, inputs)) instead of self.output = inputs. Must ensure that new_weights is a vector and has same shape as previous layer's output.
inputs = sigmoid(np.dot(w, inputs) + b)

• Why would I create a variable new_weights if w is the new weight from the loop? – yemi.JUMP Mar 20 at 1:57