MCPcopy Create free account
hub / github.com/pytorch/tutorials / make_value_estimator

Function make_value_estimator

advanced_source/coding_ddpg.py:247–265  ·  view source on GitHub ↗
(self, value_type: ValueEstimators, **hyperparams)

Source from the content-addressed store, hash-verified

245
246
247def make_value_estimator(self, value_type: ValueEstimators, **hyperparams):
248 hp = dict(default_value_kwargs(value_type))
249 if hasattr(self, "gamma"):
250 hp["gamma"] = self.gamma
251 hp.update(hyperparams)
252 value_key = "state_action_value"
253 if value_type == ValueEstimators.TD1:
254 self._value_estimator = TD1Estimator(value_network=self.actor_critic, **hp)
255 elif value_type == ValueEstimators.TD0:
256 self._value_estimator = TD0Estimator(value_network=self.actor_critic, **hp)
257 elif value_type == ValueEstimators.GAE:
258 raise NotImplementedError(
259 f"Value type {value_type} it not implemented for loss {type(self)}."
260 )
261 elif value_type == ValueEstimators.TDLambda:
262 self._value_estimator = TDLambdaEstimator(value_network=self.actor_critic, **hp)
263 else:
264 raise NotImplementedError(f"Unknown value type {value_type}")
265 self._value_estimator.set_keys(value=value_key)
266
267
268###############################################################################

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected