i have two function below with two for loops. in the first one i need the index [i] for both inputs a[i] * b[i], while in the second I need it next to output as well as next to matrix[i].
Why, what is the logic behind these indexing reference [i]?
If I do not index matrix with [i] I get this

def w_sum(a,b):
output = 0
assert(len(a) == len(b))
for i in range(len(a)):
output += (a[i] * b[i])
return output
def vec_mat_mul(vector, matrix):
output = [0, 0, 0]
assert(len(vector) == len(matrix))
for i in range(len(vector)):
output[i] = w_sum(vector, matrix[i])
return output
here are the input variables and dependent function w_sum:
#dataset at the beginning of a game
toes = [8.5, 9.5, 9.9, 9.0]
wlrec = [0.65, 0.8, 0.8, 0.9]
nfans = [1.2, 1.3, 0.5, 1.0]
#inserting one input datapoint of each variable
input = [toes[0], wlrec[0], nfans[0]]
#defining weights
weights = [[0.1, 0.2, -0.1],
[-0.1, 0.1, 0.9],
[0.1, .04, 0.1]]
Might be a very mundane question but I need to get the logic to move on.
Thanks!
vec_mat_mul?def nn_mul_in_out(input, weights): pred = vec_mat_mul(input,weights) return pred neural_output = nn_mul_in_out(input, weights) print(neural_output)matrix[i]