以下是我的多类感知器算法代码。在这里,我试图更新列表列表给出的权重向量 - 权重。逻辑是正确的,它在 1 次迭代中正确执行。列表的权重列表初始化为全部 0。在第一个迭代中,权重列表会更新,但在后续迭代中,该列表不会更新。我不明白我做错了什么?请帮忙。谢谢代码: **import numpy as npdata = open("mnist_data_training.csv",'r')weights = [[0 for _ in range(784)] for _ in range(10)]for _ in range(0,3): for row in data: lst_row = (row.rstrip('\n').split(',')) list_row = lst_row[:-1] if (max_weight_index != (lst_row[784])): weights[lst_row[784]] = np.add(weights[lst_row[784]],list_row) **# Updating weight vector here** weights[max_weight_index] = numpy.subtract(weights[max_weight_index],list_row) **#Updating weight vector here**GitHub 链接 - https://github.com/sudhakosuri/Multi-Class-Perceptron.git
添加回答
举报
0/150
提交
取消