Python 无Numpy的基本神经网络->;理解迭代步骤

Python 无Numpy的基本神经网络->;理解迭代步骤,python,neural-network,iteration,dot-product,Python,Neural Network,Iteration,Dot Product,我试着想象下面的神经网络代码所做的步骤。这是absolut basic,即使不使用Numpy也可以可视化和了解代码中发生的事情: 以下是到目前为止已注释的代码: weights = ([0.1, 0.1, -0.3], #first matrix weight´s [0.1, 0.2, 0.0], [0.0, 1.3, 0.1]) info1 = [8.5, 9.5, 9.9, 9.0] #second matrix info´s inf

我试着想象下面的神经网络代码所做的步骤。这是absolut basic,即使不使用Numpy也可以可视化和了解代码中发生的事情:

以下是到目前为止已注释的代码:

weights = ([0.1, 0.1, -0.3],   #first matrix weight´s
           [0.1, 0.2, 0.0],
           [0.0, 1.3, 0.1])

info1 = [8.5, 9.5, 9.9, 9.0]     #second matrix info´s
info2 = [0.65, 0.8, 0.8, 0.9]
info3 = [1.2, 1.3, 0.5, 1.0]

input = [info1[0], info2[0], info3[0]]

def w_sum(a, b):              #(weighted) sum function
    assert(len(a) == len(b))
    output = 0
    for i in range(len(a)):
        output += (a[i] * b[i])
    return output

def vect_mat_mul(vect, matrix):        #dot product function
    assert(len(vect) == len(matrix))
    output = [0, 0, 0]
    
    for i in range (len(vect)):
        output[i] = w_sum(vect, matrix[i])  # updates the output = [0,0,0] list with the 
                                            # result of w_sum(a,b) on position [i]
                                            # every iteration step i
    return output

def neural_network(input, weights):    #inputting the start values into the network
    pred = vect_mat_mul(input, weights)
    return pred

pred = neural_network(input, weights)  #calling the network --> the variable
                                       # 'output = [0, 0, 0] is now updated with the
                                       # values from the dot product
                                       # and 'transported outwards' by assigning the return of the network to "pred"

print(pred)
在这里,我试图想象发生了什么:

代码执行的第一个“迭代”步骤

代码正在执行的第二个“迭代”步骤

代码正在执行的第三个“迭代”步骤

最后是典型的神经网络图,包括所有步骤及其链接:

所以我现在的问题是:这是正确的吗?Python是否真的通过这两个函数对循环进行迭代,这两个函数在第三个函数(网络函数)中连接,并且正确地链接到一个3 x 3的矩阵点积

这就是开始时的全部魔力吗

问题:

  • 接下来的步骤是什么

  • 如何遍历info1、info2和info3列表中的输入值