** 或 pow() 的 Py 操作数类型:'list' 和 'int'



HELP

只有numpy的简单神经网络。代码返回错误

代码

pe = [1,20,-15 ... 23]

learning_rate = 1e-6
#5 generations
for i in range(5):
#sess = 60 data/12
while srss <= sess:
i0 = np.iloc[t][0]
i1 = np.iloc[t][1]                      
i2 =  np.iloc[t][2]
...
...
i23 =  np.iloc[t][23]
X = [i0, i1, i2 .... i23]
y = np.sin(x)
y_pred = i0 * pe[0] + i1 * pe[1] ...... i23 * pe[23]
los = np.square(y_pred - y).sum
If srss == sess:

grad_y_pred = 2.0 * (y_pred - y)
gred_0 = gred_y_pred.sum()
gred_01 = (gred_y_pred * x).sum()
gred_02 = (gred_y_pred * x ** 2).sum()
gred_23 = (gred_y_pred * x ** 23).sum()                 
....
pe[0] -= learning_rate * grad_00
pe[1] -= learning_rate * grad_01
pe[2] -= learning_rate * grad_01
....
pe[23] -= learning_rate * grad_23
srss = srss + 1

输出

Traceback (most recent call last):
File "run.py", line 124, in <module>
grad_02 = (grad_y_pred * x ** 2).sum()                                    
TypeError: unsupported operand type(s) for ** or pow(): 'list' and 'int'

值类型

  • I1:124264 INT
  • 输出Y类型:5.343
  • 输出Y_PREAD总值EX:10.24236
  • 损失类型:1.5771358927e+18

更多我需要一个正确的fintion来将OUTPUT分类为高达0.5或低至0.5 的值

尝试将X(或者是x?(转换为numpy数组,而不是列表:

X = np.array([i0, i1, i2 .... i23])

最新更新