Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hands-on-rl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
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
Gerest Corentin
hands-on-rl
Commits
7c2027ba
Commit
7c2027ba
authored
1 year ago
by
cgerest
Browse files
Options
Downloads
Patches
Plain Diff
Update full workflow
parent
280fe978
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
a2c_sb3_panda_reach.py
+15
-14
15 additions, 14 deletions
a2c_sb3_panda_reach.py
with
15 additions
and
14 deletions
a2c_sb3_panda_reach.py
+
15
−
14
View file @
7c2027ba
import
gym
import
gym
nasium
as
gym
from
stable_baselines3
import
A2C
from
stable_baselines3.common.monitor
import
Monitor
from
stable_baselines3.common.vec_env
import
DummyVecEnv
...
...
@@ -8,7 +8,6 @@ from wandb.integration.sb3 import WandbCallback
from
huggingface_hub
import
login
from
huggingface_sb3
import
push_to_hub
if
__name__
==
"
__main__
"
:
# Log in HF
login
()
...
...
@@ -21,13 +20,22 @@ if __name__ == "__main__":
"
env_name
"
:
"
PandaReachJointsDense-v3
"
,
}
#
WB i
nitializ
atio
n
#
I
nitializ
e a new wandb ru
n
run
=
wandb
.
init
(
project
=
"
a2c_sb3_panda_reach
"
,
config
=
config
,
sync_tensorboard
=
True
,
monitor_gym
=
True
,
)
def
make_env
():
env
=
gym
.
make
(
config
[
"
env_name
"
])
env
=
Monitor
(
env
)
# Record stats such as returns
return
env
env
=
DummyVecEnv
([
make_env
])
model
=
A2C
(
config
[
"
policy_type
"
],
env
,
verbose
=
1
,
tensorboard_log
=
f
"
runs/
{
run
.
id
}
"
)
# WB callback
wandb_callback
=
WandbCallback
(
gradient_save_freq
=
100
,
...
...
@@ -35,20 +43,13 @@ if __name__ == "__main__":
verbose
=
2
,
)
env
=
gym
.
make
(
"
PandaReachJointsDense-v3
"
)
model
=
A2C
(
"
MultiInputPolicy
"
,
env
,
verbose
=
1
,
tensorboard_log
=
f
"
runs/
{
run
.
id
}
"
)
model
.
learn
(
total_timesteps
=
500_000
,
total_timesteps
=
config
[
"
total_timesteps
"
]
,
callback
=
wandb_callback
)
model
.
save
(
"
PandaReachJointsDense_1.zip
"
)
# Finish the run
run
.
finish
()
# Upload on HF
...
...
@@ -56,4 +57,4 @@ if __name__ == "__main__":
repo_id
=
"
CorentinGst/PandaReachJointsDense_1
"
,
filename
=
"
PandaReachJointsDense_1.zip
"
,
commit_message
=
"
Add my 1st model trained on PandaReachJointsDense-v3 env
"
,
)
\ No newline at end of file
)
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