Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
ceril
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Walters, Celyn Dr (Comp Sci & Elec Eng)
ceril
Commits
67acff7f
Commit
67acff7f
authored
2 years ago
by
Walters, Celyn Dr (Comp Sci & Elec Eng)
Browse files
Options
Downloads
Patches
Plain Diff
Backawrd pass per training epoch
parent
bc549c47
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
rl/models/utils/ppo.py
+6
-9
6 additions, 9 deletions
rl/models/utils/ppo.py
with
6 additions
and
9 deletions
rl/models/utils/ppo.py
+
6
−
9
View file @
67acff7f
...
...
@@ -193,7 +193,6 @@ class PPO(SB3_PPO):
approx_kl_divs
=
[]
# Do a complete pass on the rollout buffer
all_losses
=
0
for
rollout_data
in
self
.
rollout_buffer
.
get
(
batch_size
=
self
.
n_envs
):
# Sampling has to be done at this size later
actions
=
rollout_data
.
actions
if
isinstance
(
self
.
action_space
,
gym
.
spaces
.
Discrete
):
...
...
@@ -277,14 +276,12 @@ class PPO(SB3_PPO):
print
(
f
"
Early stopping at step
{
epoch
}
due to reaching max kl:
{
approx_kl_div
:
.
2
f
}
"
)
break
all_losses
+=
loss
# Optimization step
self
.
policy
.
optimizer
.
zero_grad
()
all_losses
.
backward
()
# Clip grad norm
torch
.
nn
.
utils
.
clip_grad_norm_
(
self
.
policy
.
parameters
(),
self
.
max_grad_norm
)
self
.
policy
.
optimizer
.
step
()
# Optimization step
self
.
policy
.
optimizer
.
zero_grad
()
loss
.
backward
()
# Clip grad norm
torch
.
nn
.
utils
.
clip_grad_norm_
(
self
.
policy
.
parameters
(),
self
.
max_grad_norm
)
self
.
policy
.
optimizer
.
step
()
if
not
continue_training
:
break
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment