[rllib] Pull out shared models for evolution strategies and policy gradient. (#719)

* wip

* works with cartpole

* lint

* fix pg

* comment

* action dist rename

* preprocessor

* fix test

* typo

* fix the action[0] nonsense

* revert

* satisfy the lint

* wip

* works with cartpole

* lint

* fix pg

* comment

* action dist rename

* preprocessor

* fix test

* typo

* fix the action[0] nonsense

* revert

* satisfy the lint

* Minor indentation changes.

* fix merge

* add humanoid

* fix linting

* more 4 space

* fix

* fix linT

* oops

* es parity
This commit is contained in:
Eric Liang
2017-07-17 08:58:54 +00:00
committed by Philipp Moritz
parent 8fc7dc3ed4
commit 420013774c
19 changed files with 333 additions and 239 deletions
+28
View File
@@ -0,0 +1,28 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
class Model(object):
"""Defines an abstract network model for use with RLlib.
Models convert input tensors to a number of output features. These features
can then be interpreted by ActionDistribution classes to determine
e.g. agent action values.
"""
def __init__(self, inputs, num_outputs):
self.inputs = inputs
self.outputs = self._init(inputs, num_outputs)
def _init(self):
"""Initializes the model given self.inputs and self.num_outputs."""
raise NotImplementedError
def inputs(self):
"""Returns the input placeholder for this model."""
return self.inputs
def outputs(self):
"""Returns the output tensor of this model."""
return self.outputs