add back sonnet dependency. If sonnet is not installed, fall back to simpleAgent that does not need sonnet.

This commit is contained in:
Jie Tan
2017-05-22 20:57:18 -07:00
parent 2f3844e5db
commit 671c4bf10e
7 changed files with 80 additions and 5 deletions

View File

@@ -0,0 +1,21 @@
"""An actor network."""
import tensorflow as tf
import sonnet as snt
class ActorNetwork(snt.AbstractModule):
"""An actor network as a sonnet Module."""
def __init__(self, layer_sizes, action_size, name='target_actor'):
super(ActorNetwork, self).__init__(name=name)
self._layer_sizes = layer_sizes
self._action_size = action_size
def _build(self, inputs):
state = inputs
for output_size in self._layer_sizes:
state = snt.Linear(output_size)(state)
state = tf.nn.relu(state)
action = tf.tanh(
snt.Linear(self._action_size, name='action')(state))
return action