Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
7c17434d
提交
7c17434d
authored
11月 04, 2011
作者:
nouiz
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #188 from jaberg/master
Fix failing tests in tensor module
上级
74554f33
03e5e722
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
49 行增加
和
20 行删除
+49
-20
op.py
theano/gof/op.py
+2
-1
test_conv_cuda_ndarray.py
theano/sandbox/cuda/tests/test_conv_cuda_ndarray.py
+3
-0
basic.py
theano/scalar/basic.py
+21
-4
elemwise.py
theano/tensor/elemwise.py
+3
-0
tensor_grad.py
theano/tensor/tensor_grad.py
+5
-2
test_basic.py
theano/tensor/tests/test_basic.py
+0
-0
test_misc.py
theano/tensor/tests/test_misc.py
+15
-13
没有找到文件。
theano/gof/op.py
浏览文件 @
7c17434d
...
...
@@ -272,7 +272,8 @@ class CLinkerOp(CLinkerObject):
- `MethodNotDefined`: Subclass does not implement this method
"""
raise
utils
.
MethodNotDefined
(
"c_support_code_apply"
,
type
(
self
),
self
.
__class__
.
__name__
)
raise
utils
.
MethodNotDefined
(
"c_support_code_apply"
,
type
(
self
),
self
.
__class__
.
__name__
)
class
PureOp
(
object
):
...
...
theano/sandbox/cuda/tests/test_conv_cuda_ndarray.py
浏览文件 @
7c17434d
"""
Tests for GPU convolution
"""
import
sys
import
time
import
unittest
...
...
theano/scalar/basic.py
浏览文件 @
7c17434d
...
...
@@ -1206,13 +1206,16 @@ class Mod(BinaryScalarOp):
def
c_code
(
self
,
node
,
name
,
(
x
,
y
),
(
z
,
),
sub
):
"""
We want the result to have the same sign as python, not the other implementation of mod.
We want the result to have the same sign as python, not the other
implementation of mod.
"""
#raise NotImplementedError("Unlike Python, C's modulo returns negative modulo on negative dividend (to implement)")
# raise NotImplementedError("Unlike Python, C's modulo returns negative
# modulo on negative dividend (to implement)")
t
=
node
.
inputs
[
0
]
.
type
.
upcast
(
*
[
i
.
type
for
i
in
node
.
inputs
[
1
:]])
if
(
str
(
t
)
in
imap
(
str
,
discrete_types
)
or
t
in
[
'uint8'
,
'int8'
,
'uint16'
,
'int16'
,
'uint32'
,
'int32'
,
'uint64'
,
'int64'
]
or
t
in
discrete_types
):
t
in
[
'uint8'
,
'int8'
,
'uint16'
,
'int16'
]
or
t
in
[
'uint32'
,
'int32'
,
'uint64'
,
'int64'
]
or
t
in
discrete_types
):
# The above or's should not be needed anymore. However, for now we
# keep them out of safety, and verify they are useless with an
# assert.
...
...
@@ -2097,6 +2100,16 @@ class Composite(ScalarOp):
return
()
return
tuple
(
rval
)
def
c_support_code
(
self
):
rval
=
[]
for
subnode
in
self
.
env
.
toposort
():
try
:
rval
.
append
(
subnode
.
op
.
c_support_code
())
except
gof
.
utils
.
MethodNotDefined
:
pass
# remove duplicate code blocks
return
"
\n
"
.
join
(
sorted
(
set
(
rval
)))
def
c_support_code_apply
(
self
,
node
,
name
):
rval
=
[]
for
subnode
,
subnodename
in
zip
(
self
.
env
.
toposort
(),
self
.
nodenames
):
...
...
@@ -2107,6 +2120,10 @@ class Composite(ScalarOp):
subnodename
%
dict
(
nodename
=
name
)))
except
gof
.
utils
.
MethodNotDefined
:
pass
# there should be no need to remove duplicate code blocks because
# each block should have been specialized for the given nodename.
# Any block that isn't specialized should be returned via
# c_support_code instead of c_support_code_apply.
return
"
\n
"
.
join
(
rval
)
def
__eq__
(
self
,
other
):
...
...
theano/tensor/elemwise.py
浏览文件 @
7c17434d
...
...
@@ -929,6 +929,9 @@ class Elemwise(Op):
def
c_headers
(
self
):
return
[
'<vector>'
,
'<algorithm>'
]
def
c_support_code
(
self
):
return
self
.
scalar_op
.
c_support_code
()
def
c_support_code_apply
(
self
,
node
,
nodename
):
support_code
=
self
.
scalar_op
.
c_support_code_apply
(
node
,
nodename
+
'_scalar_'
)
...
...
theano/tensor/tensor_grad.py
浏览文件 @
7c17434d
...
...
@@ -670,12 +670,15 @@ class GradientError(Exception):
def
__str__
(
self
):
# args may have been inserted by e.g. makeTester
args_msg
=
", "
.
join
(
str
(
a
)
for
a
in
self
.
args
)
return
"""GradientError: numeric gradient and analytic gradient exceed tolerance:
At position
%
i of argument
%
i,
abs. error =
%
f, abs. tolerance =
%
f
rel. error =
%
f, rel. tolerance =
%
f
rel. error =
%
f, rel. tolerance =
%
f
\n
Exception args:
%
s
"""
%
(
self
.
err_pos
,
self
.
arg
,
self
.
abs_err
,
self
.
abs_tol
,
self
.
rel_err
,
self
.
rel_tol
)
self
.
rel_err
,
self
.
rel_tol
,
args_msg
)
verify_grad
.
E_grad
=
GradientError
theano/tensor/tests/test_basic.py
浏览文件 @
7c17434d
差异被折叠。
点击展开。
theano/tensor/tests/test_misc.py
浏览文件 @
7c17434d
import
copy
,
sys
import
numpy
,
theano
import
copy
import
sys
import
numpy
import
theano
from
theano
import
tensor
from
theano.tensor.nnet
import
crossentropy_softmax_argmax_1hot_with_bias
def
test_bug_2009_06_02_trac_387
():
def
test_bug_2009_06_02_trac_387
():
y
=
tensor
.
lvector
(
'y'
)
#f = theano.function([y], tensor.stack(y[0] / 2))
#f = theano.function([y], tensor.join(0,tensor.shape_padleft(y[0] / 2,1)))
f
=
theano
.
function
([
y
],
tensor
.
int_div
(
tensor
.
DimShuffle
(
y
[
0
]
.
broadcastable
,
[
'x'
])(
y
[
0
]),
2
))
f
=
theano
.
function
([
y
],
tensor
.
int_div
(
tensor
.
DimShuffle
(
y
[
0
]
.
broadcastable
,
[
'x'
])(
y
[
0
]),
2
))
sys
.
stdout
.
flush
()
print
f
(
numpy
.
ones
(
1
,
dtype
=
'int64'
)
*
3
)
#z = tensor.lscalar('z')
#f = theano.function([z], tensor.DimShuffle([], ['x'])(z) / 2)
# XXX: there is no assert, nor comment that DEBUGMODE is to do the
# checking. What was the bug, and how is it being tested?
def
test_bug_2009_07_17_borrowed_output
():
"""Regression test for a bug where output was borrowed by mistake."""
...
...
@@ -21,10 +24,10 @@ def test_bug_2009_07_17_borrowed_output():
# The output should *NOT* be borrowed.
g
=
theano
.
function
([
a
,
b
],
theano
.
Out
(
theano
.
tensor
.
dot
(
a
,
b
),
borrow
=
False
))
x
=
numpy
.
zeros
((
1
,
2
))
y
=
numpy
.
ones
((
2
,
5
))
z
=
g
(
x
,
y
)
print
z
# Should be zero.
x
.
fill
(
1
)
...
...
@@ -51,11 +54,11 @@ def test_bug_2009_07_17_borrowed_output():
output
=
nll_softmax_argmax
[
1
]
g
=
theano
.
function
([
test_output_activation_no_bias
,
test_b2
,
test_target
],
theano
.
Out
(
output
,
borrow
=
False
))
a
=
numpy
.
zeros
((
1
,
5
))
b
=
numpy
.
ones
(
5
)
c
=
numpy
.
zeros
(
1
,
dtype
=
numpy
.
int32
)
z
=
g
(
a
,
b
,
c
)
z_backup
=
copy
.
copy
(
z
)
id_z
=
id
(
z
)
...
...
@@ -68,4 +71,3 @@ def test_bug_2009_07_17_borrowed_output():
assert
id_z
!=
id_other
# Just to be 100% sure, ensure that z was not altered.
assert
(
z
==
z_backup
)
.
all
()
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论