Deep Reinforcement

Hula has a variety of options when it comes to deep reinforcement.

Using the Hula.DeepRmodule, we can construct a Neural Network.

from hula.DeepR import Net, FeedForwardLayer
from hula.rlutils import sigmoid, softplus, tanh

ExampleNet = Net(
  FeedForwardLayer(2, 16, tanh),
  FeedForwardLayer(16, 6, softplus),
  FeedForwardLayer(6, 1, sigmoid)
)

Next, we need to generate a random action to perform on this network's weights.

ExampleNet.randomAct(0.01)

Next, we need to score the network based on how well it did. In this case, let's say we want the network to get closer to 0 for an input of [0, 1].

In hula, higher scores are valued and selected over lower scores. So, in cases where a lower score is preferred, you will have to negate it.

output = ExampleNet.activate([0, 1])[0]

ExampleNet.score(-output)

That's all there is to it!

Last updated