hugodecasta hugodecasta - 7 months ago 60
Python Question

Python - cross array multiplication

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]

Simple Neural Network based on two layers and one weight layer

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


You can implement this with

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

Here is more Reference about