Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MSO_3_4-TD1
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
Thomas Desgreys
MSO_3_4-TD1
Commits
da1ca4a3
Commit
da1ca4a3
authored
3 months ago
by
td
Browse files
Options
Downloads
Patches
Plain Diff
avancement
parent
f0926141
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.md
+8
-1
8 additions, 1 deletion
README.md
a2c_sb3_cartpole.py
+49
-0
49 additions, 0 deletions
a2c_sb3_cartpole.py
a2c_sb3_panda_reach.py
+45
-0
45 additions, 0 deletions
a2c_sb3_panda_reach.py
with
102 additions
and
1 deletion
README.md
+
8
−
1
View file @
da1ca4a3
...
@@ -12,4 +12,11 @@ Although, with a bit of luck we end up with a model that reaches the max steps p
...
@@ -12,4 +12,11 @@ Although, with a bit of luck we end up with a model that reaches the max steps p
### Evaluation
### Evaluation
During evaluation, we get a 100% success rate.
During evaluation, we get a 100% success rate for 100 trials.
\ No newline at end of file
## Familiarization with a complete RL pipeline: Application to training a robotic arm
We initialize the
https://huggingface.co/Thomstr/A2C_CartPole/tree/main
https://wandb.ai/thomasdgr-ecole-centrale-de-lyon/cartpole/runs/vh4anh20/workspace?nw=nwuserthomasdgr
\ No newline at end of file
This diff is collapsed.
Click to expand it.
a2c_sb3_cartpole.py
0 → 100644
+
49
−
0
View file @
da1ca4a3
from
stable_baselines3
import
A2C
from
stable_baselines3.common.env_util
import
make_vec_env
from
huggingface_hub
import
login
from
huggingface_sb3
import
push_to_hub
import
wandb
def
play
(
model
):
obs
=
vec_env
.
reset
()
while
True
:
action
,
_states
=
model
.
predict
(
obs
)
obs
,
rewards
,
dones
,
info
=
vec_env
.
step
(
action
)
vec_env
.
render
(
"
human
"
)
if
__name__
==
"
__main__
"
:
# start a new wandb run to track this script
config
=
{
"
policy_type
"
:
"
MlpPolicy
"
,
"
total_timesteps
"
:
25000
,
"
env_name
"
:
"
CartPole-v1
"
,
}
wandb
.
login
(
key
=
'
4ac81e81b051a56ebfc528b579021cfc9ed1e5dc
'
)
run
=
wandb
.
init
(
project
=
"
cartpole
"
,
config
=
config
,
sync_tensorboard
=
True
,
monitor_gym
=
True
,
save_code
=
True
,
)
# Parallel environments
vec_env
=
make_vec_env
(
"
CartPole-v1
"
,
n_envs
=
4
)
model
=
A2C
(
"
MlpPolicy
"
,
vec_env
,
verbose
=
1
)
model
.
learn
(
total_timesteps
=
25000
)
model
.
save
(
"
a2c_cartpole
"
)
if
False
:
login
(
token
=
"
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
"
)
push_to_hub
(
repo_id
=
"
Thomstr/A2C_CartPole
"
,
filename
=
"
a2c_cartpole.zip
"
,
commit_message
=
"
Added A2C model for CartPole with Stable Baselines3
"
,
)
This diff is collapsed.
Click to expand it.
a2c_sb3_panda_reach.py
0 → 100644
+
45
−
0
View file @
da1ca4a3
import
gym
import
panda_gym
from
stable_baselines3
import
A2C
from
stable_baselines3.common.monitor
import
Monitor
from
stable_baselines3.common.vec_env
import
DummyVecEnv
import
wandb
from
wandb.integration.sb3
import
WandbCallback
config
=
{
"
policy_type
"
:
"
MultiInputPolicy
"
,
"
total_timesteps
"
:
500000
,
"
env_name
"
:
"
PandaReachJointsDense-v3
"
,
}
run
=
wandb
.
init
(
project
=
"
pandareach
"
,
config
=
config
,
sync_tensorboard
=
True
,
monitor_gym
=
True
,
save_code
=
True
,
)
def
make_env
():
env
=
gym
.
make
(
config
[
"
env_name
"
])
env
=
Monitor
(
env
)
# record stats such as returns
return
env
env
=
DummyVecEnv
([
make_env
])
env
=
gym
.
make
(
"
PandaReachJointsDense-v3
"
)
model
=
A2C
(
config
[
"
policy_type
"
],
env
,
verbose
=
1
,
tensorboard_log
=
f
"
runs/
{
run
.
id
}
"
)
model
.
learn
(
total_timesteps
=
config
[
"
total_timesteps
"
],
callback
=
WandbCallback
(
)
)
run
.
finish
()
login
(
token
=
"
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
"
)
push_to_hub
(
repo_id
=
"
Thomstr/A2C_PandaReach
"
,
filename
=
"
a2c_pandareach.zip
"
,
commit_message
=
"
Added A2C model for PandaReach with Stable Baselines3
"
,
)
\ 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