Pregunta

I have a deterministic neural network and I want to make it stochastic.

Two questions:

  1. I'm not sure if it means that I need to use the result of the sigmoid to determine the probabilities for the output, or if the probabilities are simply the neurons input, and a sigmoid function is now redundant.
  2. How to do that efficiently with numpy? I know how to generate random bits, but how do you do that with given probabilities inside a large array? (My current sigmoid function is tanh if it matters)
¿Fue útil?

Solución

  1. The sigmoid function is still required, as the backpropagation works on computing the derivative of the sigmoid function, and not whether or not the neuron fired.
  2. 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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top