Learner

class pytorchrl.learner.Learner(scheme, target_steps, log_dir=None)[source]

Bases: object

Task learner class. Class to manage the training process. It pushes forward the training process by calling the update workers and tracks progress.

Parameters
  • scheme (Scheme) – Training scheme class instance, handling coordination of workers.

  • target_steps (int) – Number of environment steps to reach to complete training.

  • log_dir (str) – Target directory for model checkpoints and logs.

done()[source]

Return True if training has finished (target_steps reached).

Returns

flag – True if training has reached the target number of steps.

Return type

bool

get_metrics(add_algo_metrics=True, add_episodes_metrics=False, add_scheme_metrics=False, add_time_metrics=False)[source]

Returns current value of tracked metrics.

print_info(add_algo_info=True, add_episodes_info=True, add_scheme_info=False, add_time_info=False)[source]

Print relevant information about the training process

save_model(fname='model.state_dict')[source]

Save currently learned actor_critic version.

Returns

save_name – Path to saved file.

Return type

str

step()[source]

Takes a logical synchronous optimization step.

stop()[source]

Stop all threads.

update_algorithm_parameter(parameter_name, new_parameter_value)[source]

If parameter_name is an attribute of the algorithm used for training, change its value to new_parameter_value value.

Parameters
  • parameter_name (str) – Worker.algo attribute name

  • new_parameter_value (int or float) – New value for parameter_name.