0
我想測試一個神經網絡。我創建了一個權重列表並試圖用輸入數組來標記產品。但是,點積似乎存在問題。代碼的粗體部分顯示錯誤。AttributeError:列表沒有屬性點
類BPNetwork:
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
這將是非常困難的人幫你沒有至少看到input'的'結構。 – vincentmajor
您是否嘗試過調試這些行? – vincentmajor
這個錯誤意味着你認爲'array'實際上是一個'list'。您需要識別該對象,並檢查它是如何創建的。 – hpaulj