Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions brax/training/agents/bc/checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

"""Checkpointing for BC."""

from typing import Any, Union
from typing import Any, Optional, Union

from brax.training import checkpoint
from brax.training import types
Expand Down Expand Up @@ -64,24 +64,26 @@ def _get_bc_network(

def load_config(
path: Union[str, epath.Path],
config_fname: str = _CONFIG_FNAME
) -> config_dict.ConfigDict:
"""Loads BC config from checkpoint."""
path = epath.Path(path)
config_path = path / _CONFIG_FNAME
config_path = path / config_fname

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a better approach would be to allow the the parameter config_fname with the default _CONFIG_FNAME. This would make the code backwards compatible.

Copy link
Contributor Author

@Andrew-Luo1 Andrew-Luo1 Jul 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks I see how this could break stuff. Updated.

return checkpoint.load_config(config_path)


def load_policy(
path: Union[str, epath.Path],
network_factory: types.NetworkFactory[bc_networks.BCNetworks],
deterministic: bool = True,
config_fname: Optional[Union[str, epath.Path]] = _CONFIG_FNAME,
):
"""Loads policy inference function from BC checkpoint.

The policy is always deterministic.
"""
path = epath.Path(path)
config = load_config(path.parent)
config = load_config(path, config_fname=config_fname)
params = load(path)
bc_network = _get_bc_network(config, network_factory)
make_inference_fn = bc_networks.make_inference_fn(bc_network)
Expand Down