hugodecasta - 1 year ago 198

Python Question

I'm developing a model based on neural network principals.

I have an entry layer, weights and an output layer:

`[1,2] -- [ [1,1] , [1,1] ] --> [3,3]`

My question is whether Python has a simple way (with numpy) to compute the output layers without doing loops and loops.

The current implementation is:

`for i in range(0,number_of_out_neurons):`

out_neuron_adder_toWrap = weights[i] * all_input_layer

out_neuron[i] = sum(out_neuron_adder) <-- wrapping

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

Answer Source

You can implement this with `numpy.dot`

```
In [1]: import numpy as np
In [2]: a
Out[2]: array([1, 2])
In [3]: b
Out[3]:
array([[1, 1],
[1, 1]])
In [4]: np.dot(a,b)
Out[4]: array([3, 3])
```

Here is more Reference about `numpy.dot`

Recommended from our users: **Dynamic Network Monitoring from WhatsUp Gold from IPSwitch**. ** Free Download**