[RLlib] Minimal ParamNoise PR. (#7772)

This commit is contained in:
Sven Mika
2020-03-28 16:16:30 -07:00
committed by GitHub
parent 5cebee68d6
commit e4bd5db4d8
17 changed files with 552 additions and 86 deletions
+6 -1
View File
@@ -134,7 +134,12 @@ def get_variable(value, framework="tf", tf_name="unnamed-variable"):
"""
if framework == "tf":
import tensorflow as tf
return tf.compat.v1.get_variable(tf_name, initializer=value)
dtype = getattr(
value, "dtype", tf.float32
if isinstance(value, float) else tf.int32
if isinstance(value, int) else None)
return tf.compat.v1.get_variable(
tf_name, initializer=value, dtype=dtype)
# torch or None: Return python primitive.
return value