C1 W4 exercise 1 - Error in cost function

Hi, I’ve been stuck for hours, all seems right, but I’m getting the following error:

"---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
in
----> 1 parameters, costs = two_layer_model(train_x, train_y, layers_dims = (n_x, n_h, n_y), num_iterations = 2, print_cost=False)
2
3 print("Cost after first iteration: " + str(costs[0]))
4
5 two_layer_model_test(two_layer_model)

in two_layer_model(X, Y, layers_dims, learning_rate, num_iterations, print_cost)
55 # cost = …
56 # YOUR CODE STARTS HERE
—> 57 logprobs = np.multiply(np.log(A2), Y) + np.multiply(np.log(1 - A2), 1 - Y)
58 cost = - np.sum(logprobs) / m
59 cost = float(np.squeeze(cost))

TypeError: unsupported operand type(s) for -: ‘int’ and ‘tuple’"

1 Like

Where exactly (which assignment is this code) found, I cant find it!

I figured out! All works now, thanks!

2 Likes

Great! I hope part of the answer was that you should be calling the cost function there, instead of writing out the code again.

1 Like