Skip to content

Commit

Permalink
Fix SAC target network parameters (#871)
Browse files Browse the repository at this point in the history
* Fix SAC target network to include any CNN parameters for target updates

* Update changelog
  • Loading branch information
Miffyli committed May 28, 2020
1 parent c4c31cb commit 257ab9c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/misc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Bug Fixes:
- Partially fix tensorboard indexing for PPO2 (@enderdead)
- Fixed potential bug in ``DummyVecEnv`` where ``copy()`` was used instead of ``deepcopy()``
- Fixed a bug in ``GAIL`` where the dataloader was not available after saving, causing an error when using ``CheckpointCallback``
- Fixed a bug in ``SAC`` where any convolutional layers were not included in the target network parameters.

Deprecations:
^^^^^^^^^^^^^
Expand Down
6 changes: 3 additions & 3 deletions stable_baselines/sac/sac.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ def setup_model(self):
value_optimizer = tf.train.AdamOptimizer(learning_rate=self.learning_rate_ph)
values_params = tf_util.get_trainable_vars('model/values_fn')

source_params = tf_util.get_trainable_vars("model/values_fn/vf")
target_params = tf_util.get_trainable_vars("target/values_fn/vf")
source_params = tf_util.get_trainable_vars("model/values_fn")
target_params = tf_util.get_trainable_vars("target/values_fn")

# Polyak averaging for target variables
self.target_update_op = [
Expand Down Expand Up @@ -304,7 +304,7 @@ def setup_model(self):

# Retrieve parameters that must be saved
self.params = tf_util.get_trainable_vars("model")
self.target_params = tf_util.get_trainable_vars("target/values_fn/vf")
self.target_params = tf_util.get_trainable_vars("target/values_fn")

# Initialize Variables and target network
with self.sess.as_default():
Expand Down

0 comments on commit 257ab9c

Please sign in to comment.