Error emojify implementation

I got the tests past for the model() function but when I try to use it I get the following message including some debugging of mine:

n_y or num classes:5
Y shape:(132,)
Y_oh shape:(132, 5)
Y_oh[i] shape:(5,)
avg[i] shape:(50,)

ValueError Traceback (most recent call last)
1 np.random.seed(1)
----> 2 pred, W, b = model(X_train, Y_train, word_to_vec_map)
3 print(pred)

in model(X, Y, word_to_vec_map, learning_rate, num_iterations)
57 print(‘avg[i] shape:’ + str(avg.shape))
—> 59 cost = np.sum(np.multiply(Y_oh[i], np.log(avg)))
60 ### END CODE HERE ###

ValueError: operands could not be broadcast together with shapes (5,) (50,)

Obviously the problem is:

Y_oh[i] shape:(5,)
avg[i] shape:(50,)
I don’t understand why in this formula:

the two vectors have so different dimensions. What am I missing?


Hi @Edu4rd ,

Please look at the formula carefully, and read the hint regarding image
below. Besides, don’t forget the minus sign.

1 Like