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

[Feature Request/Proposal] use MLFlow option or best practice of experiments management #94

Open
Chachay opened this issue Nov 19, 2020 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@Chachay
Copy link
Contributor

Chachay commented Nov 19, 2020

Thank you for the excellent RL library. PFRL makes my life so much easy.

As the management of the experiment becomes complicated, I have tried PFRL with MLFlow. And I'm satisfied with the initial implementation (see code below). MLFlow helps to compare the performances of algorithms, to manage trained models and to monitor training results remotely.

On the other hand, if PFRL natively supports MLFlow, it would be even easier to use and I can expect the wisdom of various experiment management efforts from other users. At the moment, Tensorboard support was just added a few months ago, and I'm sure that each wants to use different tools, so I've listed this as an issue to discuss.

The motivations for native support:

  • to reduce overlapped logging functions
  • to give more detailed evaluation score access to MLFlow

An alternative instead of MLFlow native support:

  • to update record_tb_stats(self.tb_writer, agent_stats, eval_stats, t) to more general implementation (like eval_hooks)

More general question about the management..:

  • to log the history of reward shaping and observation feature engineering on custom environments (git diff is a bit hard to read through)

How to use PFRL and MLFLOW together

        existing_exp = mlflow.get_experiment_by_name(args.env)
        if not existing_exp:
            mlflow.create_experiment(args.env)
        mlflow.set_experiment(args.env)

        def log_mlflow(env, agent, evaluator, step, eval_score):
            mlflow.log_metric("R_mean", eval_score, step=step)

        try:
            with mlflow.start_run():
                mlflow.log_param("Algo", "SAC")
                mlflow.log_artifacts(args.outdir)
                mlflow.log_param("OutDir", args.outdir)

                experiments.train_agent_with_evaluation(
                        agent=agent,
                        env=make_env(0, False),
                        eval_env=make_env(0, True),
                        outdir=args.outdir,
                        steps=args.steps,
                        eval_n_steps=None,
                        eval_n_episodes=args.eval_n_runs,
                        eval_interval=args.eval_interval,
                        save_best_so_far_agent=True,
                        evaluation_hooks=(log_mlflow,),
                )
        finally:
            mlflow.log_artifacts(args.outdir)
            mlflow.end_run()
@prabhatnagarajan
Copy link
Contributor

Thanks! I'm glad to hear you like our library and that it makes your life easier :)

Thanks for taking the time to produce the example and outline this proposal. We'll discuss this internally and get back to you.

@prabhatnagarajan prabhatnagarajan added the enhancement New feature or request label Nov 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants