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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Armin Co
LearningEnvironment
Commits
8e575e06
Commit
8e575e06
authored
4 years ago
by
Armin Co
Browse files
Options
Downloads
Patches
Plain Diff
Added offline batchsize option
Load both networks for double q agent
parent
4a0dc96d
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
agents.py
+11
-1
11 additions, 1 deletion
agents.py
with
12 additions
and
1 deletion
.gitignore
+
1
−
0
View file @
8e575e06
...
@@ -3,6 +3,7 @@ __pycache__
...
@@ -3,6 +3,7 @@ __pycache__
saved_agents
saved_agents
benchmarks
benchmarks
baselines
baselines
simple
workspace.code-workspace
workspace.code-workspace
test
test
tech_demo.py
tech_demo.py
...
...
This diff is collapsed.
Click to expand it.
agents.py
+
11
−
1
View file @
8e575e06
...
@@ -20,6 +20,7 @@ class QAgent:
...
@@ -20,6 +20,7 @@ class QAgent:
self
.
action_space
=
conf
.
env
.
action_space
.
n
self
.
action_space
=
conf
.
env
.
action_space
.
n
self
.
name
=
conf
.
name
self
.
name
=
conf
.
name
self
.
epsilon_decay
=
conf
.
eps_decay
self
.
epsilon_decay
=
conf
.
eps_decay
self
.
OFFLINE_BATCHSIZE
=
conf
.
offline_batchsize
def
get_action
(
self
,
state
):
def
get_action
(
self
,
state
):
if
np
.
random
.
rand
()
<=
self
.
epsilon
:
if
np
.
random
.
rand
()
<=
self
.
epsilon
:
...
@@ -80,7 +81,7 @@ class DQAgent(QAgent):
...
@@ -80,7 +81,7 @@ class DQAgent(QAgent):
def
get_action
(
self
,
state
):
def
get_action
(
self
,
state
):
if
np
.
random
.
rand
()
<=
self
.
epsilon
:
if
np
.
random
.
rand
()
<=
self
.
epsilon
:
return
random
.
randrange
(
self
.
action_space
)
return
random
.
randrange
(
self
.
action_space
)
action_values
=
(
self
.
q
.
predict
(
state
)
+
self
.
q2
.
predict
(
state
))
/
2
action_values
=
self
.
q
.
predict
(
state
)
return
np
.
argmax
(
action_values
[
0
])
return
np
.
argmax
(
action_values
[
0
])
def
learn
(
self
,
offline
=
False
,
epochs
=
1
):
def
learn
(
self
,
offline
=
False
,
epochs
=
1
):
...
@@ -110,6 +111,15 @@ class DQAgent(QAgent):
...
@@ -110,6 +111,15 @@ class DQAgent(QAgent):
self
.
epsilon
*=
self
.
epsilon_decay
self
.
epsilon
*=
self
.
epsilon_decay
return
loss
return
loss
def
load
(
self
,
path
,
net
=
True
,
memory
=
True
):
print
(
'
Load:
'
+
path
)
if
net
:
print
(
'
Network
'
)
self
.
q
.
load
(
path
+
'
.net
'
)
self
.
q2
.
load
(
path
+
'
.net
'
)
if
memory
:
self
.
memory
.
load
(
path
+
'
.mem
'
)
class
CarlaManual
(
QAgent
):
class
CarlaManual
(
QAgent
):
control
=
None
control
=
None
...
...
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