Выдает такое:
Traceback (most recent call last):
File "nero.py", line 26, in <module>
probs = predict(x)
File "nero.py", line 21, in predict
t1 = x @ W1 + b1
ValueError: matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 5 is different from 4)
Из-за чего такое может быть? Где ошибся?
Вот код самого алгоритма:
import numpy as np
IND = 4
OUTD = 3
HD = 5
x = np.random.randn(IND)
W1 = np.random.randn(IND, HD)
b1 = np.random.randn(HD)
W1 = np.random.randn(HD, OUTD)
b1 = np.random.randn(OUTD)
def relu(t):
return np.maximum(t,0)
def softmax(t):
out = np.exp(t)
return out / np.sum(out)
def predict(x):
t1 = x @ W1 + b1
h1= relu(t1)
t2 = h1 @ W2 + b2
z = softmax(t2)
probs = predict(x)
pred_class = np.argmax(probs)
class_nam = ['Setosa','ersicolor', 'Virginica']
print(class_nam[pred_class])