Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
6c5071c9
提交
6c5071c9
authored
8月 10, 2017
作者:
AndreiCostinescu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Changed comments to docstrings where necessary in theano/scan_module/tests
上级
3154dc99
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
48 行增加
和
37 行删除
+48
-37
test_scan.py
theano/scan_module/tests/test_scan.py
+33
-28
test_scan_opt.py
theano/scan_module/tests/test_scan_opt.py
+15
-9
没有找到文件。
theano/scan_module/tests/test_scan.py
浏览文件 @
6c5071c9
...
@@ -55,16 +55,18 @@ type_eps = {'float64': 1e-7,
...
@@ -55,16 +55,18 @@ type_eps = {'float64': 1e-7,
class
multiple_outputs_numeric_grad
:
class
multiple_outputs_numeric_grad
:
# WRITEME
"""WRITEME"""
def
__init__
(
self
,
f
,
pt
,
ndarray_mask
=
None
,
eps
=
None
):
def
__init__
(
self
,
f
,
pt
,
ndarray_mask
=
None
,
eps
=
None
):
# Return the gradient of f at pt.
"""
#
Return the gradient of f at pt.
# This function computes the gradient by a one-sided finite differences
# of a fixed step size (eps).
This function computes the gradient by a one-sided finite differences
#
of a fixed step size (eps).
# It is assumed that f(...) will return a scalar.
# :param eps: the stepsize for the finite differencing. None means
It is assumed that f(...) will return a scalar.
# input dtype-dependent. See `type_eps`.
:param eps: the stepsize for the finite differencing. None means
input dtype-dependent. See `type_eps`.
"""
def
prod
(
inputs
):
def
prod
(
inputs
):
rval
=
1
rval
=
1
...
@@ -123,13 +125,15 @@ class multiple_outputs_numeric_grad:
...
@@ -123,13 +125,15 @@ class multiple_outputs_numeric_grad:
@staticmethod
@staticmethod
def
abs_rel_err
(
a
,
b
,
eps
=
1.0e-10
):
def
abs_rel_err
(
a
,
b
,
eps
=
1.0e-10
):
# Return a small number when a and b are close, relative to how big
"""
# they are
Return a small number when a and b are close, relative to how big they are
"""
return
abs
(
a
-
b
)
/
(
abs
(
a
)
+
abs
(
b
)
+
eps
)
return
abs
(
a
-
b
)
/
(
abs
(
a
)
+
abs
(
b
)
+
eps
)
def
max_err
(
self
,
_g_pt
):
def
max_err
(
self
,
_g_pt
):
# Return the biggest relative error between g_pt and self.gx
"""
Return the biggest relative error between g_pt and self.gx
"""
g_pt
=
[]
g_pt
=
[]
for
i
in
xrange
(
len
(
_g_pt
)):
for
i
in
xrange
(
len
(
_g_pt
)):
if
self
.
ndarray_mask
[
i
]:
if
self
.
ndarray_mask
[
i
]:
...
@@ -4527,19 +4531,18 @@ class T_Scan(unittest.TestCase):
...
@@ -4527,19 +4531,18 @@ class T_Scan(unittest.TestCase):
class
ScanGpuTests
:
class
ScanGpuTests
:
# This class defines a number of tests for Scan on GPU as well as a few
"""
# helper functions for these tests. The GPU tests defined in this class are
This class defines a number of tests for Scan on GPU as well as a few
# independant of the GPU backend used. Because of this, a class inheriting
helper functions for these tests. The GPU tests defined in this class are
# from ScanGpuTests should define the following attributes and methods to
independant of the GPU backend used. Because of this, a class inheriting
# make the tests run on a specific backend :
from ScanGpuTests should define the following attributes and methods to
# - self.gpu_backend : Reference to the backend module
make the tests run on a specific backend :
# - self.mode_with_opt : Compilation mode to force usage of the gpu backend
- self.gpu_backend : Reference to the backend module
# - self.is_scan_on_gpu(node) : Method to determine is a scan node has been
- self.mode_with_opt : Compilation mode to force usage of the gpu backend
# moved to run on a gpu under the specific
- self.is_scan_on_gpu(node) : Method to determine is a scan node has been
# backend. Returns a boolean.
moved to run on a gpu under the specific
backend. Returns a boolean.
# as test_one_sequence_one_output_weights, but on the gpu
"""
# This first version test the first case in the optimizer to the gpu.
def
test_one_sequence_one_output_weights_gpu1
(
self
):
def
test_one_sequence_one_output_weights_gpu1
(
self
):
def
f_rnn
(
u_t
,
x_tm1
,
W_in
,
W
):
def
f_rnn
(
u_t
,
x_tm1
,
W_in
,
W
):
...
@@ -4869,8 +4872,10 @@ class ScanGpuTests:
...
@@ -4869,8 +4872,10 @@ class ScanGpuTests:
class
T_Scan_Gpuarray
(
unittest
.
TestCase
,
ScanGpuTests
):
class
T_Scan_Gpuarray
(
unittest
.
TestCase
,
ScanGpuTests
):
# This class takes the gpu tests for scan that are defined in
"""
# class ScanGpuTests and runs them using the gpuarray backend.
This class takes the gpu tests for scan that are defined in
class ScanGpuTests and runs them using the gpuarray backend.
"""
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
from
theano
import
gpuarray
from
theano
import
gpuarray
...
...
theano/scan_module/tests/test_scan_opt.py
浏览文件 @
6c5071c9
...
@@ -12,9 +12,11 @@ mode = theano.compile.mode.get_mode(config.mode)
...
@@ -12,9 +12,11 @@ mode = theano.compile.mode.get_mode(config.mode)
class
TestGaussNewton
(
unittest
.
TestCase
):
class
TestGaussNewton
(
unittest
.
TestCase
):
# Regression test for code exhibiting various optimization errors.
"""
# This test case is based on code by Sigurd Spieckermann
.
Regression test for code exhibiting various optimization errors
.
This test case is based on code by Sigurd Spieckermann.
"""
def
setUp
(
self
):
def
setUp
(
self
):
self
.
rng
=
np
.
random
.
RandomState
(
utt
.
fetch_seed
())
self
.
rng
=
np
.
random
.
RandomState
(
utt
.
fetch_seed
())
...
@@ -134,10 +136,12 @@ class GaussNewtonMatrix(object):
...
@@ -134,10 +136,12 @@ class GaussNewtonMatrix(object):
class
TestPushOutScanOutputDot
(
object
):
class
TestPushOutScanOutputDot
(
object
):
# Test class for the PushOutScanOutput optimizer in the case where the inner
"""
# function of a scan op has an output which is the result of a Dot product
Test class for the PushOutScanOutput optimizer in the case where the inner
# on a non-sequence matrix input to scan and a vector that is the result of
function of a scan op has an output which is the result of a Dot product
# computation in the inner function.
on a non-sequence matrix input to scan and a vector that is the result of
computation in the inner function.
"""
def
test_dot_not_output
(
self
):
def
test_dot_not_output
(
self
):
# Test the case where the vector input to the dot is not already an
# Test the case where the vector input to the dot is not already an
...
@@ -264,9 +268,11 @@ class TestPushOutScanOutputDot(object):
...
@@ -264,9 +268,11 @@ class TestPushOutScanOutputDot(object):
class
TestPushOutSumOfDot
():
class
TestPushOutSumOfDot
():
# Test case for the PushOutScanOutput optimizer in the case where the scan
"""
# is used to compute the sum over the dot products between the corresponding
Test case for the PushOutScanOutput optimizer in the case where the scan
# elements of two list of matrices.
is used to compute the sum over the dot products between the corresponding
elements of two list of matrices.
"""
def
test_machine_translation
(
self
):
def
test_machine_translation
(
self
):
# This test case comes from https://github.com/rizar/scan-grad-speed and
# This test case comes from https://github.com/rizar/scan-grad-speed and
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论