我不明白问题是什么
X = (([0, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0], [1, 0, 0, 0]))
y = (([0, 0], [0, 1], [1, 0], [1, 1]))
def back(self, x, h, output):
self.error = h-output
self.outputdelta = self.error *self.delta(output)
self.z2error=self.outputdelta.dot(self.w2.T)
self.z2delta = self.z2error * self.delta(self.z2)
self.w1 += x.T.dot(self.z2delta)
self.w2 += self.z2.T.dot(self.outputdelta)
AttributeError:'tuple'对象没有属性'T'
我假设您的输入应为NumPy数组。您正在传递元组(由括号()
表示)。这样做就足够了:
import numpy as np
X = np.array(([0, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0], [1, 0, 0, 0]))
y = np.array(([0, 0], [0, 1], [1, 0], [1, 1]))