module moplayground.learning.inference


function get_all_models

get_all_models(run_dir) → list[pathlib.Path]

Checkpoint directories in run_dir, sorted by training step.

A checkpoint directory is a subdirectory whose name is an integer (the training step), e.g. 000050032640.


function get_last_model

get_last_model(run_dir) → Path

Most recent checkpoint directory in run_dir.


function load_mo_policy

load_mo_policy(
    algorithm: str,
    network_params: dict,
    num_objectives: int,
    run_dir,
    tradeoff: numpy.ndarray,
    network_factory=None,
    deterministic: bool = True
)

Load the latest multi-objective policy in run_dir.

Dispatches on algorithm ('morlax' or 'amor'). Returns a 2-arg callable policy(obs, key) -> (action, extras) with tradeoff baked in, so it is compatible with mm.eval.rollout_policy and other consumers.

For AMOR specifically, the underlying inference function natively accepts a directive at call time (so the tradeoff can change per step). To get that 3-arg form, call :func:load_amor_inference_fn directly instead of this function.


function load_hypernetworks

load_hypernetworks(
    network_params: dict,
    num_objectives: int,
    run_dir=None,
    path=None,
    network_factory=<function make_morlax_networks at 0x7ffa3c96b600>,
    quiet=True
) → tuple[moplayground.moppo.factory.MORLAXNetworks, dict]

Load MORLAX networks and hypernetwork params from a checkpoint.

Args:

  • network_params: MORLAX network-factory keyword arguments.
  • num_objectives: Number of objectives.
  • run_dir: Run directory; the latest checkpoint in it is used when path is not given.
  • path: Explicit checkpoint directory. Overrides run_dir.

function load_hypernetwork_inference_fn

load_hypernetwork_inference_fn(
    network_params: dict,
    num_objectives: int,
    run_dir=None,
    path=None,
    network_factory=<function make_morlax_networks at 0x7ffa3c96b600>
)

Loads policy inference function from PPO checkpoint.


function load_amor_networks

load_amor_networks(
    network_params: dict,
    num_objectives: int,
    run_dir=None,
    path=None,
    network_factory=<function make_amor_networks at 0x7ffa3c980220>,
    quiet=True
) → tuple

Load AMOR networks + saved (normalizer, policy, value) params.

Args:

  • network_params: AMOR network-factory keyword arguments.
  • num_objectives: Number of objectives.
  • run_dir: Run directory; the latest checkpoint in it is used when path is not given.
  • path: Explicit checkpoint directory. Overrides run_dir.

function load_make_amor_inference_fn

load_make_amor_inference_fn(
    network_params: dict,
    num_objectives: int,
    run_dir=None,
    path=None,
    network_factory=<function make_amor_networks at 0x7ffa3c980220>
)

Load the (call-time-directive) AMOR inference function from a checkpoint.

Returns (amor_inference_fn, saved_params) where amor_inference_fn has signature (params, deterministic) -> policy(obs, directive, key) and saved_params is the (normalizer, policy, value) 3-tuple from the checkpoint.


This site uses Just the Docs, a documentation theme for Jekyll.