HELP
Simple Neural Network with only numpy. the code returns an error
CODE
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
OUTPUT
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'
VALUES TYPES
- I1: 124264 INT
- OUTPUT Y TYPE: 5.343
- OUTPUT Y_PREAD TOTAL VALUE EX: 10.24236
- LOSS TYPE: 1.5771358927e 18
MORE I need a correct finction to classificate OUTPUT in values up to 0.5 or down to 0.5
CodePudding user response:
Try converting X
(or is it x
?) to a numpy array instead of a list:
X = np.array([i0, i1, i2 .... i23])