learner

class xuance.mindspore.learners.learner.Learner(config: Namespace, policy: mindspore.nn.Cell, callback)[source]

Bases: ABC

estimate_total_iterations()[source]

Estimated total number of training iterations

get_grad_reducer(optimizer: dict | list | mindspore.nn.Optimizer | None) mindspore.nn.DistributedGradReducer | None[source]
load_model(path, model=None)[source]
save_model(model_path)[source]
abstractmethod update(*args)[source]
class xuance.mindspore.learners.learner.LearnerMAS(config: Namespace, model_keys: List[str], agent_keys: List[str], policy: mindspore.nn.Cell, callback)[source]

Bases: ABC

build_training_data(sample: dict | None, use_parameter_sharing: bool | None = False, use_actions_mask: bool | None = False, use_global_state: bool | None = False)[source]

Prepare the training data.

Parameters:
  • sample (dict) – The raw sampled data.

  • use_parameter_sharing (bool) – Whether to use parameter sharing for individual agent models.

  • use_actions_mask (bool) – Whether to use actions mask for unavailable actions.

  • use_global_state (bool) – Whether to use global state.

Returns:

The formatted sampled data.

Return type:

sample_Tensor (dict)

estimate_total_iterations()[source]

Estimated total number of training iterations

get_joint_input(input_tensor, output_shape=None)[source]
load_model(path, model=None)[source]
save_model(model_path)[source]
abstractmethod update(*args)[source]
update_rnn(*args)[source]