Now the question is how can you express this formula in python:
\displaystyle \sum_{i = 1}^{m}y^{(i)}log(a^{(i)})
if the inputs are given as 1 x m row vectors? I can think of at least two ways:
- Elementwise multiply of the two vectors followed by a sum.
- A dot product, but you have to transpose the second one in order for the dimensions to work and to give you a scalar output.
1 x m dotted with m x 1 gives you a 1 x 1 (scalar) output. If you do the transpose the other way, you get a completely different result, which is just a multiplication table. If you add that up, it’s got no relationship to the correct answer. Here’s a thread with some concrete examples that are relevant.