Open fuhaoda opened 3 years ago
@fuhaoda yeah, if you use the vectorized version on single values, it will of course be slower (although I didn't expect 100x to be fair). but the point of vectorizing is that, well, we want to apply this to a vector (the result of the feed-forward layer). Have you tried replacing the vectorized version with the standard one in the actual network training code? you should see that fail.
Max - Thanks for the reply.
As you see from the above example, both functions can be applied to vectors (x
is a vector in above example, i.e although sigmoid_d is defined on a single value, it can automatically applied to a vector). In addition, I also tried the codes as you suggested, codes run OK.
oh, I misread your code. you're right!
now I wonder why I did that originally, probably an earlier version that got refactored that needed the vectorized version. hard to reconstruct.
Hi,
I was trying to understand the codes in Chapter 5. Why do we need
np.vectorize(sigmoid_double)(z)
in the layers.py file? It seems that it is about 100x slower than directly broadcasting the function. Here is a simple comparison, please let me know if I missed something here.Output