I am getting the following error in model_test(model) error inside propagate function in
Programming Assignment: Logistic Regression with a Neural Network Mindset
I am getting the ValueError: operands could not be broadcast together with shapes (1,3) (1,7)
I printed out different values in cost function and it seems that sometimes the the parameter A is of different shape than th shape of Y
Following is prints I am getting
w [[ 0.08483675]
[-0.08073906]
[-0.11582744]
[ 0.12636363]]
B -0.0389675014823217
shape m ()
shape Y (1, 7)
shape A (1, 7)
shape log A (1, 7)
w [[ 0.08639757]
[-0.08231268]
[-0.11798927]
[ 0.12866053]]
B -0.03983236094816321
shape m ()
shape Y (1, 3)
shape A (1, 3)
shape log A (1, 3)
w [[ 0.09027857]
[-0.0801878 ]
[-0.12002229]
[ 0.13012181]]
B -0.03855751694083141
shape m ()
shape Y (1, 3)
shape A (1, 3)
shape log A (1, 3)
w [[ 0.09414372]
[-0.07807089]
[-0.12204824]
[ 0.1315738 ]]
B -0.037289601637241196
shape m ()
shape Y (1, 3)
shape A (1, 3)
shape log A (1, 3)
w [[ 0.08639757]
[-0.08231268]
[-0.11798927]
[ 0.12866053]]
B -0.03983236094816321
shape m ()
shape Y (1, 3)
shape A (1, 7)
shape log A (1, 7)
---------------------------------------------------------------------------ValueError Traceback (most recent call last)
in 1 from public_tests import * 2
----> 3 model_test(model)
~/work/release/W2A2/public_tests.py in model_test(target) 113 y_test = np.array([0, 1, 0]) 114
→ 115 d = target(X, Y, x_test, y_test, num_iterations=50, learning_rate=0.01) 116
117 assert type(d[‘costs’]) == list, f"Wrong type for d[‘costs’]. {type(d[‘costs’])} != list"
in model(X_train, Y_train, X_test, Y_test, num_iterations, learning_rate, print_cost) 47 # Predict test/train set examples (≈ 2 lines of code) 48 Y_prediction_test = predict(w, b, X_test)—> 49 Y_prediction_train = predict(w, b, X_train) 50
51 # YOUR CODE ENDS HERE
in predict(w, b, X) 53 # Cost and gradient calculation (≈ 1-4 lines of code) 54 ### START CODE HERE ###—> 55 grads, cost = propagate(w, b, X, Y) 56 ### END CODE HERE ### 57
in propagate(w, b, X, Y) 33 print(‘shape A’, np.shape(A)) 34 print(‘shape log A’, np.shape(np.log(A)))—> 35 cost = (1/m)np.sum(-Ynp.log(A)-(1-Y)*np.log(1-A)) 36 ### END CODE HERE ### 37