1
0
mirror of https://github.com/gryf/coach.git synced 2025-12-18 19:50:17 +01:00

DDPG Critic Head Bug Fix (#344)

* A bug fix for DDPG, where the update to the policy network was based on the sum of the critic's Q predictions on the batch instead of their mean
This commit is contained in:
Gal Leibovich
2019-06-05 17:47:56 +03:00
committed by GitHub
parent 0aa5359d63
commit a1bb8eef89
4 changed files with 61 additions and 5 deletions

View File

@@ -16,6 +16,7 @@ from .sac_head import SACPolicyHead
from .sac_q_head import SACQHead
from .classification_head import ClassificationHead
from .cil_head import RegressionHead
from .ddpg_v_head import DDPGVHead
__all__ = [
'CategoricalQHead',
@@ -35,5 +36,6 @@ __all__ = [
'SACPolicyHead',
'SACQHead',
'ClassificationHead',
'RegressionHead'
'RegressionHead',
'DDPGVHead'
]

View File

@@ -0,0 +1,39 @@
#
# Copyright (c) 2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import tensorflow as tf
from rl_coach.architectures.tensorflow_components.heads import VHead
from rl_coach.architectures.tensorflow_components.layers import Dense
from rl_coach.base_parameters import AgentParameters
from rl_coach.spaces import SpacesDefinition
class DDPGVHead(VHead):
def __init__(self, agent_parameters: AgentParameters, spaces: SpacesDefinition, network_name: str,
head_idx: int = 0, loss_weight: float = 1., is_local: bool = True, activation_function: str='relu',
dense_layer=Dense, initializer='normalized_columns'):
super().__init__(agent_parameters, spaces, network_name, head_idx, loss_weight, is_local, activation_function,
dense_layer=dense_layer, initializer=initializer)
def _build_module(self, input_layer):
super()._build_module(input_layer)
self.output = [self.output, tf.reduce_mean(self.output)]
def __str__(self):
result = [
"Dense (num outputs = 1)"
]
return '\n'.join(result)