ray.rllib.evaluation.rollout_worker.RolloutWorker.set_weights#

RolloutWorker.set_weights(weights: Dict[str, dict], global_vars: Optional[Dict] = None, weights_seq_no: Optional[int] = None) None[source]#

Sets each policies’ model weights of this worker.

Parameters
  • weights – Dict mapping PolicyIDs to the new weights to be used.

  • global_vars – An optional global vars dict to set this worker to. If None, do not update the global_vars.

  • weights_seq_no – If needed, a sequence number for the weights version can be passed into this method. If not None, will store this seq no (in self.weights_seq_no) and in future calls - if the seq no did not change wrt. the last call - will ignore the call to save on performance.

Examples

>>> from ray.rllib.evaluation.rollout_worker import RolloutWorker
>>> # Create a RolloutWorker.
>>> worker = ... 
>>> weights = worker.get_weights() 
>>> # Set `global_vars` (timestep) as well.
>>> worker.set_weights(weights, {"timestep": 42})