Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
LearningEnvironment
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Armin Co
LearningEnvironment
Commits
e714c48a
Commit
e714c48a
authored
4 years ago
by
Armin Co
Browse files
Options
Downloads
Patches
Plain Diff
Start sample agent
parent
0e1745c4
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
environment_wrapper.py
+3
-3
3 additions, 3 deletions
environment_wrapper.py
main.py
+3
-0
3 additions, 0 deletions
main.py
with
6 additions
and
3 deletions
environment_wrapper.py
+
3
−
3
View file @
e714c48a
...
@@ -31,7 +31,7 @@ class Config:
...
@@ -31,7 +31,7 @@ class Config:
if
self
.
force_cpu
:
if
self
.
force_cpu
:
os
.
environ
[
"
CUDA_DEVICE_ORDER
"
]
=
"
PCI_BUS_ID
"
os
.
environ
[
"
CUDA_DEVICE_ORDER
"
]
=
"
PCI_BUS_ID
"
os
.
environ
[
"
CUDA_VISIBLE_DEVICES
"
]
=
""
os
.
environ
[
"
CUDA_VISIBLE_DEVICES
"
]
=
""
self
.
name
+
=
self
.
env_type
self
.
name
=
self
.
env_type
+
'
_
'
+
self
.
name
for
layer
in
self
.
net_layout
:
for
layer
in
self
.
net_layout
:
self
.
name
+=
'
_
'
+
str
(
layer
)
+
'
_
'
self
.
name
+=
'
_
'
+
str
(
layer
)
+
'
_
'
self
.
name
+=
str
(
self
.
eps_decay
)
+
'
_
'
self
.
name
+=
str
(
self
.
eps_decay
)
+
'
_
'
...
@@ -91,7 +91,7 @@ def run(environment, agent, episodes, render=True, learn=True):
...
@@ -91,7 +91,7 @@ def run(environment, agent, episodes, render=True, learn=True):
score_history
=
[]
score_history
=
[]
avg_score_history
=
[]
avg_score_history
=
[]
pbar
=
trange
(
episodes
,
desc
=
agent
.
name
+
'
[act
ual
, av
erage
]: [0, 0]
'
,
unit
=
"
Episodes
"
)
pbar
=
trange
(
episodes
,
desc
=
agent
.
name
+
'
[act, av
g
]: [0, 0]
'
,
unit
=
"
Episodes
"
)
for
_
in
pbar
:
for
_
in
pbar
:
score
=
one_episode
(
environment
,
agent
,
render
,
learn
)
score
=
one_episode
(
environment
,
agent
,
render
,
learn
)
score_history
.
append
(
score
)
score_history
.
append
(
score
)
...
@@ -101,7 +101,7 @@ def run(environment, agent, episodes, render=True, learn=True):
...
@@ -101,7 +101,7 @@ def run(environment, agent, episodes, render=True, learn=True):
if
is_solved
>
195
and
learn
:
if
is_solved
>
195
and
learn
:
break
break
desc
=
(
"
Score
[act
ual
, av
erage
]: [{0:.2f}, {1:.2f}]
"
.
format
(
score
,
is_solved
))
desc
=
(
agent
.
name
+
"
[act, av
g
]: [{0:.2f}, {1:.2f}]
"
.
format
(
score
,
is_solved
))
pbar
.
set_description
(
desc
)
pbar
.
set_description
(
desc
)
pbar
.
refresh
()
pbar
.
refresh
()
return
score_history
,
avg_score_history
return
score_history
,
avg_score_history
...
...
This diff is collapsed.
Click to expand it.
main.py
+
3
−
0
View file @
e714c48a
...
@@ -5,6 +5,7 @@ Run your desired environment and agent configuration.
...
@@ -5,6 +5,7 @@ Run your desired environment and agent configuration.
import
os
import
os
import
atexit
import
atexit
import
gym
import
gym
from
agents
import
QAgent
import
environment_wrapper
as
ew
import
environment_wrapper
as
ew
...
@@ -47,7 +48,9 @@ def run(conf):
...
@@ -47,7 +48,9 @@ def run(conf):
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
conf
=
ew
.
Config
()
conf
=
ew
.
Config
()
conf
.
render
=
True
conf
.
env
=
gym
.
make
(
'
LunarLander-v2
'
)
conf
.
env
=
gym
.
make
(
'
LunarLander-v2
'
)
conf
.
env_type
=
'
Lunar
'
conf
.
env_type
=
'
Lunar
'
conf
.
conf_to_name
()
conf
.
conf_to_name
()
conf
.
agent
=
QAgent
(
conf
)
run
(
conf
)
run
(
conf
)
\ 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