Implementation seem ok, but failing to get expected value.. please help

Are you sure that you followed the instructions in terms of which activation functions to use? It is tanh for the hidden layer and sigmoid for the output layer, right?

Update: I tried making that mistake and I don’t get the same results that you show. But the point is that there must be some way in which your code does not match the instructions, so please make a careful comparison to the various steps in the instructions for forward propagation.

The mistake is clear in the code you showed. The activation functions are correct, but the input to the layer 2 activation is not. But I guess you could say it’s an activation function problem: you effectively used no activation function at all for layer 1.

Thank you ! I realized that… now i am stuck in the next step

{moderator edit - solution code removed}

Take a closer look at the math formula for the cost. You’ve just used the sample code that they gave you as if it is the complete solution. It’s not. They even told you that in the instructions, although perhaps they were a bit too subtle about it.

Ask yourself two questions:

  1. What happened to the factor of \frac {1}{m}?
  2. Why is there only one term? What happened to the Y = 0 term?

Thank you for quick reply !! Now i see exactly what you mean and everything matches !