[rllib] Add self-supervised loss to model (#3291)

# What do these changes do?

Allow self-supervised losses to be easily defined in custom models. Add this to the reference policy graphs.
This commit is contained in:
Eric Liang
2018-11-12 18:55:24 -08:00
committed by Richard Liaw
parent ce6e01b988
commit d90f365394
8 changed files with 47 additions and 20 deletions
+12
View File
@@ -144,6 +144,18 @@ class Model(object):
return tf.reshape(
linear(self.last_layer, 1, "value", normc_initializer(1.0)), [-1])
def loss(self):
"""Builds any built-in (self-supervised) loss for the model.
For example, this can be used to incorporate auto-encoder style losses.
Note that this loss has to be included in the policy graph loss to have
an effect (done for built-in algorithms).
Returns:
Scalar tensor for the self-supervised loss.
"""
return tf.constant(0.0)
def _restore_original_dimensions(input_dict, obs_space):
if hasattr(obs_space, "original_space"):