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

Docu fix: result = trainer.run() #1008

Closed
carlocagnetta opened this issue Dec 13, 2023 · 2 comments · Fixed by #1009
Closed

Docu fix: result = trainer.run() #1008

carlocagnetta opened this issue Dec 13, 2023 · 2 comments · Fixed by #1009

Comments

@carlocagnetta
Copy link
Contributor

carlocagnetta commented Dec 13, 2023

Issue Description

In the provided code examples, it appears that the training function is not being used properly. Specifically, in both cases cited by the code-line links, the variable named result is being assigned a trainer class which is never used.

Proposed Solution

To address this issue, I suggest changing the class instance from result to trainer and assign the ouput of its function run() to the variable result; using it as follows:

# Before
result = OnpolicyTrainer()
print(result)

# After
trainer = OnpolicyTrainer()
result = trainer.run()
print(result)

or more efficiently:

result = OnpolicyTrainer().run()
print(result)

Affected Code Lines

"result = OnpolicyTrainer(\n",
" policy=policy,\n",
" train_collector=train_collector,\n",
" test_collector=test_collector,\n",
" max_epoch=10,\n",
" step_per_epoch=1,\n",
" repeat_per_collect=1,\n",
" episode_per_test=10,\n",
" step_per_collect=2000,\n",
" batch_size=512,\n",
")\n",
"print(result)"

"result = OnpolicyTrainer(\n",
" policy=policy,\n",
" train_collector=train_collector,\n",
" test_collector=test_collector,\n",
" max_epoch=10,\n",
" step_per_epoch=50000,\n",
" repeat_per_collect=10,\n",
" episode_per_test=10,\n",
" batch_size=256,\n",
" step_per_collect=2000,\n",
" stop_fn=lambda mean_reward: mean_reward >= 195,\n",
")"

@carlocagnetta
Copy link
Contributor Author

@MischaPanch @opcode81 This is the issue we discussed

@carlocagnetta
Copy link
Contributor Author

resolved by #1009

MischaPanch pushed a commit that referenced this issue Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant