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: Trainer without argparse #105
Conversation
tf2rl/experiments/trainer.py
Outdated
args = policy.__class__.get_argument(Trainer.get_argument()) | ||
args = args.parse_args([]) | ||
for k, v in _args.items(): | ||
setattr(args, k, v) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this part overrides the arguments by specified dictionary.
Would it be possible to reject elements that are not defined in the args = policy.__class__.get_argument(Trainer.get_argument())
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long as argparse
guarantees that there exist all the possible parameters including parameters not specified by command line, we can check with hasattr(args, k)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
tests/experiments/test_trainer.py
Outdated
batch_size=32, | ||
n_warmup=10) | ||
trainer = Trainer(policy, env, {}, test_env=test_env) | ||
print(trainer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you printing trainer
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid linter error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you tell me why this avoids linter error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/ymd-h/tf2rl/runs/1047622916?check_suite_focus=true
F841 local variable 'trainer' is assigned to but never used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe there are more better solutions, but checking whether parameters are default is also problematic.
These parameters can change their default values in future, which will break unit test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. I found a solution.
I simply do not assign to local value. (12cfa48)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good!
This PR is related with #104
This PR enables
Trainer
to acceptdict
-typeargs
at constructor.User can pass parameters like followings;
This PR preserves backward compatibility, so that user still can pass
argparse.Namespace
(result ofparse_args()
).