Python AttributeError:列表没有属性点

Python AttributeError:列表没有属性点,python,list,numpy,Python,List,Numpy,我正在尝试测试一个神经网络。我已经创建了一个权重列表,并尝试使用输入数组对产品进行点画。但是点积似乎有问题。代码的粗体部分显示错误 类别网络: layerCount = 0 shape = None weights = [[[ 0.03049199, -0.04634491, 0.0405433 , -0.03799513, 0.04094929, -0.09666186, 0.07161143, 0.11686911, -0.1212281 ], [ 0.00747107

我正在尝试测试一个神经网络。我已经创建了一个权重列表,并尝试使用输入数组对产品进行点画。但是点积似乎有问题。代码的粗体部分显示错误

类别网络:

layerCount = 0
shape = None
weights = [[[ 0.03049199, -0.04634491,  0.0405433 , -0.03799513,  0.04094929,
    -0.09666186,  0.07161143,  0.11686911, -0.1212281 ],
   [ 0.00747107, -0.02739591,  0.16988383,  0.04748638, -0.02052043,
    -0.09041263,  0.01091398, -0.10341986,  0.10367971],
   [-0.00769936,  0.00212671, -0.05626757, -0.06102786,  0.05239374,
     0.17320473,  0.14166611,  0.12951726, -0.04147583],
   [ 0.17410716,  0.14625286, -0.08257581,  0.09635945, -0.04103847,
    -0.05811309, -0.01397631, -0.07126624, -0.03091246],
   [-0.08190238, -0.03037191, -0.0212364 ,  0.17238552,  0.1533649 ,
    -0.01982297, -0.00579448,  0.00125691,  0.01950781]],
  [[ 0.03982875,  0.09886628, -0.10354473, -0.01145922, -0.34038487, -0.0297971 ]]]


def __init__(self, layerSize):

    self.layerCount = len(layerSize) - 1
    self.shape = layerSize

    self._layerInput = []
    self._layerOutput = []

def Run(self, input):

    lnCases = input.shape[0]

    self._layerInput = []
    self._layerOutput = []

    for index in range(self.layerCount):

        #determine layer input

        **if index == 0:
            layerInput = self.weights[0].dot(np.vstack([input.T, np.ones([1, lnCases])]))
        else:
            layerInput = self.weights[index].dot(np.vstack([self._layerOutput[-1], np.ones([1, lnCases])]))**

        self._layerInput.append(layerInput)
        self._layerOutput.append(self.sgm(layerInput))

    return self._layerOutput [-1].T              

正如其他人之前所指出的,
self.weights
是一个
列表,而不是numpy数组

例如,将
\uuuu init\uuuu
功能代码更改为:

def __init__(self, layerSize):

    self.layerCount = len(layerSize) - 1
    self.shape = layerSize

    self._layerInput = []
    self._layerOutput = []

    # convert weights list to numpy array
    self.weights = np.array(self.weights, dtype=np.float)

如果没有看到
input
的结构,任何人都很难帮助你。你试过调试这些行吗?错误意味着你认为的
数组实际上是一个
列表。您需要识别该对象,并查看它是如何创建的。您可以在列表的顶部设置权重。如果该
weights
变量与
self.weights
相同,并且您从未将其包装到
numpy.array
中,则无法对其执行任何numpy功能。