-1
每當我運行它,我都會得到一個TypeError
,告訴我該操作數不支持Floats和Methods。我誰能給我一個想法,我做錯了什麼,以及如何解決這個問題?TypeError:*:'method'和'float'的不受支持的操作數類型
from numpy import random,array,dot
class neural():
def __init__(self):
self.weights=2*random.random(3).reshape((3,1))-1
def __sigmoid(self,x):
return 1/(1+exp(-x))
def predict(self,inputs):
print("called predict function successfully")
#pass inputs through our neural network (our single neuron)
return dot(input,self.weights)
if __name__=="__main__":
nn=neural()
print(nn.weights)
print(nn.predict(array([3,1,1])))
包括回溯唯一的例外是:
12 nn=neural()
13 print(nn.weights)
---> 14 print(nn.predict(array([3,1,1])))
8 print("called predict function successfully")
9 #pass inputs through our neural network (our single neuron)
---> 10 return dot(input,self.weights)
TypeError: unsupported operand type(s) for *: 'method' and 'float'