Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
seminar-breakout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shashank Suhas
seminar-breakout
Commits
6087698d
Commit
6087698d
authored
Nov 13, 2016
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
a3c supports cpu
parent
61384a65
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
16 deletions
+24
-16
examples/HED/hed.py
examples/HED/hed.py
+9
-8
examples/OpenAIGym/run-atari.py
examples/OpenAIGym/run-atari.py
+1
-1
examples/OpenAIGym/train-atari.py
examples/OpenAIGym/train-atari.py
+14
-7
No files found.
examples/HED/hed.py
View file @
6087698d
...
...
@@ -80,14 +80,15 @@ class Model(ModelDesc):
wrong
=
tf
.
cast
(
tf
.
not_equal
(
pred
,
edgemap
),
tf
.
float32
)
wrong
=
tf
.
reduce_mean
(
wrong
,
name
=
'train_error'
)
wd_w
=
tf
.
train
.
exponential_decay
(
2e-4
,
get_global_step_var
(),
80000
,
0.7
,
True
)
wd_cost
=
tf
.
mul
(
wd_w
,
regularize_cost
(
'.*/W'
,
tf
.
nn
.
l2_loss
),
name
=
'wd_cost'
)
costs
.
append
(
wd_cost
)
add_moving_summary
(
costs
+
[
wrong
])
add_param_summary
([(
'.*/W'
,
[
'histogram'
])])
# monitor W
self
.
cost
=
tf
.
add_n
(
costs
,
name
=
'cost'
)
if
get_current_tower_context
()
.
is_training
:
wd_w
=
tf
.
train
.
exponential_decay
(
2e-4
,
get_global_step_var
(),
80000
,
0.7
,
True
)
wd_cost
=
tf
.
mul
(
wd_w
,
regularize_cost
(
'.*/W'
,
tf
.
nn
.
l2_loss
),
name
=
'wd_cost'
)
costs
.
append
(
wd_cost
)
add_moving_summary
(
costs
+
[
wrong
])
add_param_summary
([(
'.*/W'
,
[
'histogram'
])])
# monitor W
self
.
cost
=
tf
.
add_n
(
costs
,
name
=
'cost'
)
def
get_gradient_processor
(
self
):
return
[
ScaleGradient
([(
'convfcweight.*'
,
0.1
),
(
'conv5_.*'
,
5
)])
]
...
...
examples/OpenAIGym/run-atari.py
View file @
6087698d
...
...
@@ -69,7 +69,7 @@ def run_submission(cfg, output, nr):
if
k
!=
0
:
player
.
restart_episode
()
score
=
play_one_episode
(
player
,
predfunc
)
print
(
"
Total
:"
,
score
)
print
(
"
Score
:"
,
score
)
def
do_submit
(
output
):
gym
.
upload
(
output
,
api_key
=
'xxx'
)
...
...
examples/OpenAIGym/train-atari.py
View file @
6087698d
...
...
@@ -242,16 +242,23 @@ if __name__ == '__main__':
elif
args
.
task
==
'eval'
:
eval_model_multithread
(
cfg
,
EVAL_EPISODE
)
else
:
nr_gpu
=
get_nr_gpu
()
if
nr_gpu
>
1
:
predict_tower
=
range
(
nr_gpu
)[
-
nr_gpu
/
2
:]
if
args
.
gpu
:
nr_gpu
=
get_nr_gpu
()
if
nr_gpu
>
1
:
predict_tower
=
range
(
nr_gpu
)[
-
nr_gpu
/
2
:]
else
:
predict_tower
=
[
0
]
PREDICTOR_THREAD
=
len
(
predict_tower
)
*
PREDICTOR_THREAD_PER_GPU
train_tower
=
range
(
nr_gpu
)[:
-
nr_gpu
/
2
]
or
[
0
]
logger
.
info
(
"[BA3C] Train on gpu {} and infer on gpu {}"
.
format
(
','
.
join
(
map
(
str
,
train_tower
)),
','
.
join
(
map
(
str
,
predict_tower
))))
else
:
nr_gpu
=
0
PREDICTOR_THREAD
=
1
predict_tower
=
[
0
]
PREDICTOR_THREAD
=
len
(
predict_tower
)
*
PREDICTOR_THREAD_PER_GPU
train_tower
=
[
0
]
config
=
get_config
()
if
args
.
load
:
config
.
session_init
=
SaverRestore
(
args
.
load
)
config
.
tower
=
range
(
nr_gpu
)[:
-
nr_gpu
/
2
]
or
[
0
]
logger
.
info
(
"[BA3C] Train on gpu {} and infer on gpu {}"
.
format
(
','
.
join
(
map
(
str
,
config
.
tower
)),
','
.
join
(
map
(
str
,
predict_tower
))))
config
.
tower
=
train_tower
AsyncMultiGPUTrainer
(
config
,
predict_tower
=
predict_tower
)
.
train
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment