Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PARL
提交
a7ac16df
P
PARL
项目概览
PaddlePaddle
/
PARL
通知
67
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
3
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PARL
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
3
合并请求
3
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
a7ac16df
编写于
7月 23, 2020
作者:
Z
zenghsh3
提交者:
GitHub
7月 23, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bug of rpm (#359)
* fix bug of rpm * fix bug of rpm * soft link
上级
04a16723
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
105 addition
and
7 deletion
+105
-7
examples/NeurIPS2018-AI-for-Prosthetics-Challenge/replay_memory.py
...NeurIPS2018-AI-for-Prosthetics-Challenge/replay_memory.py
+97
-0
examples/NeurIPS2018-AI-for-Prosthetics-Challenge/simulator_server.py
...rIPS2018-AI-for-Prosthetics-Challenge/simulator_server.py
+2
-1
examples/NeurIPS2019-Learn-to-Move-Challenge/evaluate.py
examples/NeurIPS2019-Learn-to-Move-Challenge/evaluate.py
+1
-1
examples/NeurIPS2019-Learn-to-Move-Challenge/replay_memory.py
...ples/NeurIPS2019-Learn-to-Move-Challenge/replay_memory.py
+1
-0
examples/NeurIPS2019-Learn-to-Move-Challenge/train.py
examples/NeurIPS2019-Learn-to-Move-Challenge/train.py
+2
-1
parl/utils/replay_memory.py
parl/utils/replay_memory.py
+2
-4
未找到文件。
examples/NeurIPS2018-AI-for-Prosthetics-Challenge/replay_memory.py
0 → 100755
浏览文件 @
a7ac16df
# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import
numpy
as
np
from
parl.utils
import
logger
__all__
=
[
'ReplayMemory'
]
class
ReplayMemory
(
object
):
def
__init__
(
self
,
max_size
,
obs_dim
,
act_dim
):
self
.
max_size
=
int
(
max_size
)
self
.
obs_dim
=
obs_dim
self
.
act_dim
=
act_dim
self
.
obs
=
np
.
zeros
((
max_size
,
obs_dim
),
dtype
=
'float32'
)
self
.
action
=
np
.
zeros
((
max_size
,
act_dim
),
dtype
=
'float32'
)
self
.
reward
=
np
.
zeros
((
max_size
,
),
dtype
=
'float32'
)
self
.
terminal
=
np
.
zeros
((
max_size
,
),
dtype
=
'bool'
)
self
.
next_obs
=
np
.
zeros
((
max_size
,
obs_dim
),
dtype
=
'float32'
)
self
.
_curr_size
=
0
self
.
_curr_pos
=
0
def
sample_batch
(
self
,
batch_size
):
batch_idx
=
np
.
random
.
randint
(
self
.
_curr_size
-
300
-
1
,
size
=
batch_size
)
obs
=
self
.
obs
[
batch_idx
]
reward
=
self
.
reward
[
batch_idx
]
action
=
self
.
action
[
batch_idx
]
next_obs
=
self
.
next_obs
[
batch_idx
]
terminal
=
self
.
terminal
[
batch_idx
]
return
obs
,
action
,
reward
,
next_obs
,
terminal
def
make_index
(
self
,
batch_size
):
batch_idx
=
np
.
random
.
randint
(
self
.
_curr_size
-
300
-
1
,
size
=
batch_size
)
return
batch_idx
def
sample_batch_by_index
(
self
,
batch_idx
):
obs
=
self
.
obs
[
batch_idx
]
reward
=
self
.
reward
[
batch_idx
]
action
=
self
.
action
[
batch_idx
]
next_obs
=
self
.
next_obs
[
batch_idx
]
terminal
=
self
.
terminal
[
batch_idx
]
return
obs
,
action
,
reward
,
next_obs
,
terminal
def
append
(
self
,
obs
,
act
,
reward
,
next_obs
,
terminal
):
if
self
.
_curr_size
<
self
.
max_size
:
self
.
_curr_size
+=
1
self
.
obs
[
self
.
_curr_pos
]
=
obs
self
.
action
[
self
.
_curr_pos
]
=
act
self
.
reward
[
self
.
_curr_pos
]
=
reward
self
.
next_obs
[
self
.
_curr_pos
]
=
next_obs
self
.
terminal
[
self
.
_curr_pos
]
=
terminal
self
.
_curr_pos
=
(
self
.
_curr_pos
+
1
)
%
self
.
max_size
def
size
(
self
):
return
self
.
_curr_size
def
save
(
self
,
pathname
):
other
=
np
.
array
([
self
.
_curr_size
,
self
.
_curr_pos
],
dtype
=
np
.
int32
)
np
.
savez
(
pathname
,
obs
=
self
.
obs
,
action
=
self
.
action
,
reward
=
self
.
reward
,
terminal
=
self
.
terminal
,
next_obs
=
self
.
next_obs
,
other
=
other
)
def
load
(
self
,
pathname
):
data
=
np
.
load
(
pathname
)
other
=
data
[
'other'
]
if
int
(
other
[
0
])
>
self
.
max_size
:
logger
.
warn
(
'loading from a bigger size rpm!'
)
self
.
_curr_size
=
min
(
int
(
other
[
0
]),
self
.
max_size
)
self
.
_curr_pos
=
min
(
int
(
other
[
1
]),
self
.
max_size
-
1
)
self
.
obs
[:
self
.
_curr_size
]
=
data
[
'obs'
][:
self
.
_curr_size
]
self
.
action
[:
self
.
_curr_size
]
=
data
[
'action'
][:
self
.
_curr_size
]
self
.
reward
[:
self
.
_curr_size
]
=
data
[
'reward'
][:
self
.
_curr_size
]
self
.
terminal
[:
self
.
_curr_size
]
=
data
[
'terminal'
][:
self
.
_curr_size
]
self
.
next_obs
[:
self
.
_curr_size
]
=
data
[
'next_obs'
][:
self
.
_curr_size
]
logger
.
info
(
"[load rpm]memory loade from {}"
.
format
(
pathname
))
examples/NeurIPS2018-AI-for-Prosthetics-Challenge/simulator_server.py
浏览文件 @
a7ac16df
...
...
@@ -28,7 +28,8 @@ from concurrent import futures
from
multi_head_ddpg
import
MultiHeadDDPG
from
opensim_agent
import
OpenSimAgent
from
opensim_model
import
OpenSimModel
from
parl.utils
import
logger
,
ReplayMemory
from
parl.utils
import
logger
from
replay_memory
import
ReplayMemory
from
utils
import
calc_indicators
,
ScalarsManager
,
TransitionExperience
ACT_DIM
=
19
...
...
examples/NeurIPS2019-Learn-to-Move-Challenge/evaluate.py
浏览文件 @
a7ac16df
...
...
@@ -22,7 +22,7 @@ import numpy as np
from
actor
import
Actor
from
opensim_model
import
OpenSimModel
from
opensim_agent
import
OpenSimAgent
from
parl.utils
import
logger
,
ReplayMemory
,
summary
,
get_gpu_count
from
parl.utils
import
logger
,
summary
,
get_gpu_count
from
parl.utils.window_stat
import
WindowStat
from
parl.remote.client
import
get_global_client
from
parl.utils
import
machine_info
...
...
examples/NeurIPS2019-Learn-to-Move-Challenge/replay_memory.py
0 → 120000
浏览文件 @
a7ac16df
..
/
NeurIPS2018
-
AI
-
for
-
Prosthetics
-
Challenge
/
replay_memory
.
py
\ No newline at end of file
examples/NeurIPS2019-Learn-to-Move-Challenge/train.py
浏览文件 @
a7ac16df
...
...
@@ -22,7 +22,8 @@ import numpy as np
from
actor
import
Actor
from
opensim_model
import
OpenSimModel
from
opensim_agent
import
OpenSimAgent
from
parl.utils
import
logger
,
ReplayMemory
,
summary
,
get_gpu_count
from
parl.utils
import
logger
,
summary
,
get_gpu_count
from
replay_memory
import
ReplayMemory
from
parl.utils.window_stat
import
WindowStat
from
parl.remote.client
import
get_global_client
from
parl.utils
import
machine_info
...
...
parl/utils/replay_memory.py
浏览文件 @
a7ac16df
...
...
@@ -34,8 +34,7 @@ class ReplayMemory(object):
self
.
_curr_pos
=
0
def
sample_batch
(
self
,
batch_size
):
batch_idx
=
np
.
random
.
randint
(
self
.
_curr_size
-
300
-
1
,
size
=
batch_size
)
batch_idx
=
np
.
random
.
randint
(
self
.
_curr_size
,
size
=
batch_size
)
obs
=
self
.
obs
[
batch_idx
]
reward
=
self
.
reward
[
batch_idx
]
...
...
@@ -45,8 +44,7 @@ class ReplayMemory(object):
return
obs
,
action
,
reward
,
next_obs
,
terminal
def
make_index
(
self
,
batch_size
):
batch_idx
=
np
.
random
.
randint
(
self
.
_curr_size
-
300
-
1
,
size
=
batch_size
)
batch_idx
=
np
.
random
.
randint
(
self
.
_curr_size
,
size
=
batch_size
)
return
batch_idx
def
sample_batch_by_index
(
self
,
batch_idx
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录