You also need an element-wise multiplication (*) in this too.
Hint: if you have S=\sum_{i=1}^{m}a_i \log (b_i), and you have A be a vector \{a_1, a_2, ..., a_m\} and B be a vector \{b_1, b_2, ..., b_m\}, your code should be:
Thanks. I was thinking the vectorized cost function is A-Y but that is not the case.
Anyway implementing the cost function J worked, and all tests are passing.