Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
a51d2d4a
提交
a51d2d4a
authored
8月 18, 2017
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add some documentation to RNNBlock.
上级
2d3ab3b0
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
42 行增加
和
1 行删除
+42
-1
dnn.py
theano/gpuarray/dnn.py
+42
-1
没有找到文件。
theano/gpuarray/dnn.py
浏览文件 @
a51d2d4a
...
@@ -2501,7 +2501,7 @@ class GpuDnnRNNGradWeights(DnnBase):
...
@@ -2501,7 +2501,7 @@ class GpuDnnRNNGradWeights(DnnBase):
class
RNNBlock
(
object
):
class
RNNBlock
(
object
):
"""
"""
An object that allow us to use CuDNN
v5
RNN implementation.
An object that allow us to use CuDNN RNN implementation.
TODO: make an example how to use. You can check Theano tests
TODO: make an example how to use. You can check Theano tests
test_dnn_rnn_gru() and test_dnn_rnn_lstm() in the file
test_dnn_rnn_gru() and test_dnn_rnn_lstm() in the file
theano/gpuarray/tests/test_dnn.py for now.
theano/gpuarray/tests/test_dnn.py for now.
...
@@ -2542,6 +2542,20 @@ class RNNBlock(object):
...
@@ -2542,6 +2542,20 @@ class RNNBlock(object):
self
.
dtype
=
dtype
self
.
dtype
=
dtype
def
get_param_size
(
self
,
input_size
):
def
get_param_size
(
self
,
input_size
):
"""
Get the size of the shared variable for the parameters of the RNN.
This will return a size (in items) necessary to store all the
parameters for the RNN. You should allocate a variable of
that size to store those parameters. The order and layout of
the parameters is opaque.
Parameters
----------
input_size: (int, int)
Size of the input blocks
"""
bytesize
=
_get_param_size
(
self
.
desc
,
input_size
,
self
.
dtype
,
bytesize
=
_get_param_size
(
self
.
desc
,
input_size
,
self
.
dtype
,
self
.
context_name
)
self
.
context_name
)
bytesize
=
int
(
bytesize
)
bytesize
=
int
(
bytesize
)
...
@@ -2549,11 +2563,38 @@ class RNNBlock(object):
...
@@ -2549,11 +2563,38 @@ class RNNBlock(object):
return
bytesize
//
np
.
dtype
(
self
.
dtype
)
.
itemsize
return
bytesize
//
np
.
dtype
(
self
.
dtype
)
.
itemsize
def
split_params
(
self
,
w
,
layer
,
input_size
):
def
split_params
(
self
,
w
,
layer
,
input_size
):
"""
Split the opaque parameter block into components.
Parameters
----------
w: GpuArraySharedVariable
opaque parameter block
layer: int
ID of the layer
input_size: (int, int)
Size of the input blocks
"""
if
not
isinstance
(
w
,
GpuArraySharedVariable
):
if
not
isinstance
(
w
,
GpuArraySharedVariable
):
raise
TypeError
(
"split_params only works on gpuarray shared variables"
)
raise
TypeError
(
"split_params only works on gpuarray shared variables"
)
return
_split_rnn_params
(
w
,
self
.
desc
,
layer
,
input_size
,
self
.
dtype
,
self
.
rnn_mode
)
return
_split_rnn_params
(
w
,
self
.
desc
,
layer
,
input_size
,
self
.
dtype
,
self
.
rnn_mode
)
def
apply
(
self
,
w
,
x
,
hx
,
cx
=
None
):
def
apply
(
self
,
w
,
x
,
hx
,
cx
=
None
):
"""
Apply the RNN to some data
Parameters
----------
w:
opaque parameter block
x:
input
hx:
initial hidden state
cx:
initial cell state (for LSTM)
"""
# Don't return the reserve as an output
# Don't return the reserve as an output
return
GpuDnnRNNOp
(
self
.
rnn_mode
,
self
.
direction_mode
)(
return
GpuDnnRNNOp
(
self
.
rnn_mode
,
self
.
direction_mode
)(
rnndesc_type
.
make_constant
(
self
.
desc
),
rnndesc_type
.
make_constant
(
self
.
desc
),
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论