Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Cooperative Cuisine Environment
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Social Cognitive Systems
CoCoSy
Cooperative Cuisine Environment
Commits
b4dd71bf
Commit
b4dd71bf
authored
1 year ago
by
Fabian Heinrich
Browse files
Options
Downloads
Patches
Plain Diff
Added experimentation script for meta pearl in rl
parent
2f69d600
No related branches found
No related tags found
No related merge requests found
Pipeline
#49265
failed
1 year ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cooperative_cuisine/reinforcement_learning/gym_env.py
+3
-3
3 additions, 3 deletions
cooperative_cuisine/reinforcement_learning/gym_env.py
cooperative_cuisine/reinforcement_learning/pearl_test.py
+68
-0
68 additions, 0 deletions
cooperative_cuisine/reinforcement_learning/pearl_test.py
with
71 additions
and
3 deletions
cooperative_cuisine/reinforcement_learning/gym_env.py
+
3
−
3
View file @
b4dd71bf
...
...
@@ -129,12 +129,12 @@ class EnvGymWrapper(Env):
def
__init__
(
self
):
super
().
__init__
()
self
.
gridsize
=
3
0
self
.
gridsize
=
4
0
self
.
randomize_counter_placement
=
Tru
e
self
.
randomize_counter_placement
=
Fals
e
self
.
use_rgb_obs
=
False
# if False uses simple vectorized state
self
.
full_vector_state
=
True
self
.
onehot_state
=
Fals
e
self
.
onehot_state
=
Tru
e
self
.
env
:
Environment
=
Environment
(
env_config
=
environment_config
,
...
...
This diff is collapsed.
Click to expand it.
cooperative_cuisine/reinforcement_learning/pearl_test.py
0 → 100644
+
68
−
0
View file @
b4dd71bf
import
cv2
from
pearl.action_representation_modules.one_hot_action_representation_module
import
(
OneHotActionTensorRepresentationModule
,
)
from
pearl.pearl_agent
import
PearlAgent
from
pearl.policy_learners.sequential_decision_making.deep_q_learning
import
(
DeepQLearning
,
)
from
pearl.replay_buffers.sequential_decision_making.fifo_off_policy_replay_buffer
import
(
FIFOOffPolicyReplayBuffer
,
)
from
pearl.utils.instantiations.environments.gym_environment
import
GymEnvironment
from
cooperative_cuisine.reinforcement_learning.gym_env
import
EnvGymWrapper
custom
=
True
if
custom
:
env
=
GymEnvironment
(
EnvGymWrapper
())
else
:
env
=
GymEnvironment
(
"
LunarLander-v2
"
,
render_mode
=
"
rgb_array
"
)
num_actions
=
env
.
action_space
.
n
agent
=
PearlAgent
(
policy_learner
=
DeepQLearning
(
state_dim
=
env
.
observation_space
.
shape
[
0
],
action_space
=
env
.
action_space
,
hidden_dims
=
[
64
,
64
],
training_rounds
=
20
,
action_representation_module
=
OneHotActionTensorRepresentationModule
(
max_number_actions
=
num_actions
),
),
replay_buffer
=
FIFOOffPolicyReplayBuffer
(
10_000
),
)
for
i
in
range
(
40
):
print
(
i
)
observation
,
action_space
=
env
.
reset
()
agent
.
reset
(
observation
,
action_space
)
done
=
False
while
not
done
:
action
=
agent
.
act
(
exploit
=
False
)
action_result
=
env
.
step
(
action
)
agent
.
observe
(
action_result
)
agent
.
learn
()
done
=
action_result
.
done
if
custom
:
env
=
GymEnvironment
(
EnvGymWrapper
())
else
:
env
=
GymEnvironment
(
"
LunarLander-v2
"
,
render_mode
=
"
human
"
)
for
i
in
range
(
40
):
print
(
i
)
observation
,
action_space
=
env
.
reset
()
agent
.
reset
(
observation
,
action_space
)
done
=
False
while
not
done
:
action
=
agent
.
act
(
exploit
=
False
)
action_result
=
env
.
step
(
action
)
agent
.
observe
(
action_result
)
agent
.
learn
()
done
=
action_result
.
done
if
custom
:
img
=
env
.
env
.
render
()
cv2
.
imshow
(
"
image
"
,
img
[:,
:,
::
-
1
])
cv2
.
waitKey
(
1
)
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