メインからclassへ引数を渡す際にTypeエラーが出てしまいました。
エラー文は
error
1TypeError: unbound method __init__() must be called with step instance as first argument (got ndarray instance instead)
渡した引数はリスト型なのですが、何がいけないのかわかりません。
型エラーをどのように解決すればよいかおしえてください。
参考URLあると幸いです。以下は、メインとクラスコードです。
python
1from step_function import step 2 3import matplotlib.pyplot as plt 4import numpy as np 5 6x=np.arange(-5.0,5.0,0.1) 7m=step.__init__(x) 8y=m.step.step_funtion() 9plt.plot(x,y) 10plt.ylim(-0.1,1.1) 11plt.show() 12 13z=m.step.sigmoid() 14plt.plot(x,z) 15plt.ylim(-0.1,1.1) 16plt.show() 17 18w=m.step.relu() 19plt.plot(x,w) 20plt.ylim(-0.1,1.1) 21plt.show()
python
1import numpy as np 2 3 4class step: 5 6 def __init__(self, x): 7 self.x = x 8 9 def step_funtion(self): 10 return np.array(self.x > 0, dtype=np.int) 11 12 def sigmoid(self): 13 return 1 / (1 + np.exp(-self.x)) 14 15 def relu(self): 16 return np.maximum(0, self.x) 17

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/11/23 12:20 編集
2018/11/23 12:22
2018/11/23 12:56