I have a deterministic neural network and I want to make it stochastic.
Two questions:
After computing the activation as before, I now run the result array x through this:
return numpy.random.ranf(x.shape) < x
My timing for this is 3.03323280772e-05
Also note that numpy treats boolean values as if they were 1 and 0 so no need to transfer the result back to int/float). Because this is now 0 and 1, I had to change my code a bit - before I used -1 and 1 for target values and inputs.