Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for emitting hparam info from train_bc script #374

Merged
merged 1 commit into from
Sep 26, 2024
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
10 changes: 10 additions & 0 deletions compiler_opt/rl/train_bc.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
from compiler_opt.rl import registry
from compiler_opt.rl import trainer

from tensorflow import summary
from tf_agents.agents import tf_agent
from tf_agents.policies import tf_policy
from tensorboard.plugins.hparams import api as hp

from typing import Dict

Expand Down Expand Up @@ -87,6 +89,14 @@ def train_eval(agent_config_type=agent_config.BCAgentConfig,
# Save final policy.
saver.save(root_dir)

# Save (command line specified) hyperparameter information.
with summary.create_file_writer(_ROOT_DIR.value).as_default():
hparams = {}
for gin_binding in _GIN_BINDINGS.value:
param_name, param_value = gin_binding.split('=')
hparams[param_name] = param_value
hp.hparams(hparams)


def main(_):
gin.parse_config_files_and_bindings(
Expand Down