Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
d0821805
提交
d0821805
authored
3月 27, 2009
作者:
James Bergstra
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
replaced sparse dot with * operator
上级
b2b4fed8
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
19 行增加
和
10 行删除
+19
-10
test_debugmode.py
theano/compile/tests/test_debugmode.py
+4
-4
test_function.py
theano/compile/tests/test_function.py
+6
-0
basic.py
theano/sparse/basic.py
+6
-3
test_basic.py
theano/sparse/tests/test_basic.py
+3
-3
没有找到文件。
theano/compile/tests/test_debugmode.py
浏览文件 @
d0821805
import
numpy
import
sys
import
numpy
,
scipy
import
scipy.sparse
import
scipy.sparse
from
theano
import
gof
from
theano
import
gof
...
@@ -34,9 +35,8 @@ class BROKEN_ON_PURPOSE_StructuredDotCSC(gof.Op):
...
@@ -34,9 +35,8 @@ class BROKEN_ON_PURPOSE_StructuredDotCSC(gof.Op):
(
a_nrows
,
b
.
shape
[
0
]),
(
a_nrows
,
b
.
shape
[
0
]),
copy
=
False
)
copy
=
False
)
# TODO: todense() is automatic in 0.7.0, just remove the following line:
# TODO: todense() is automatic in 0.7.0, just remove the following line:
# out[0] = numpy.asarray(a.dot(b).todense())
z
=
a
*
b
out
[
0
]
=
a
.
dot
(
b
)
+
0.5
if
self
.
py_offset
else
a
.
dot
(
b
)
#ERROR TO ADD THIS CRAPPY OFFSET
out
[
0
]
=
z
+
0.5
if
self
.
py_offset
else
z
#ERROR TO ADD THIS CRAPPY OFFSET
#assert _is_dense(out[0])
def
c_code
(
self
,
node
,
name
,
(
a_val
,
a_ind
,
a_ptr
,
a_nrows
,
b
),
(
z
,),
sub
):
def
c_code
(
self
,
node
,
name
,
(
a_val
,
a_ind
,
a_ptr
,
a_nrows
,
b
),
(
z
,),
sub
):
return
"""
return
"""
...
...
theano/compile/tests/test_function.py
浏览文件 @
d0821805
...
@@ -455,9 +455,15 @@ class T_picklefunction(unittest.TestCase):
...
@@ -455,9 +455,15 @@ class T_picklefunction(unittest.TestCase):
g
=
cPickle
.
loads
(
str_f
)
g
=
cPickle
.
loads
(
str_f
)
#print g.maker.mode
#print g.maker.mode
#print compile.mode.default_mode
#print compile.mode.default_mode
except
NotImplementedError
,
e
:
if
e
[
0
]
.
startswith
(
'DebugMode is not pickl'
):
g
=
'ok'
finally
:
finally
:
compile
.
mode
.
default_mode
=
old_default_mode
compile
.
mode
.
default_mode
=
old_default_mode
if
g
==
'ok'
:
return
assert
f
.
maker
is
not
g
.
maker
assert
f
.
maker
is
not
g
.
maker
assert
f
.
maker
.
env
is
not
g
.
maker
.
env
assert
f
.
maker
.
env
is
not
g
.
maker
.
env
tf
=
f
.
maker
.
env
.
toposort
()
tf
=
f
.
maker
.
env
.
toposort
()
...
...
theano/sparse/basic.py
浏览文件 @
d0821805
...
@@ -676,7 +676,8 @@ class StructuredDot(gof.Op):
...
@@ -676,7 +676,8 @@ class StructuredDot(gof.Op):
if
a
.
shape
[
1
]
!=
b
.
shape
[
0
]:
if
a
.
shape
[
1
]
!=
b
.
shape
[
0
]:
raise
ValueError
(
'shape mismatch in StructuredDot.perform'
,
(
a
.
shape
,
b
.
shape
))
raise
ValueError
(
'shape mismatch in StructuredDot.perform'
,
(
a
.
shape
,
b
.
shape
))
variable
=
a
.
dot
(
b
)
#variable = a.dot(b) # deprecated
variable
=
a
*
b
assert
_is_dense
(
variable
)
# scipy 0.7 automatically converts to dense
assert
_is_dense
(
variable
)
# scipy 0.7 automatically converts to dense
# dot of an NxM sparse matrix, with a Mx1 dense matrix, returns vector not matrix
# dot of an NxM sparse matrix, with a Mx1 dense matrix, returns vector not matrix
...
@@ -738,7 +739,8 @@ class StructuredDotCSC(gof.Op):
...
@@ -738,7 +739,8 @@ class StructuredDotCSC(gof.Op):
a
=
sparse
.
csc_matrix
((
a_val
,
a_ind
,
a_ptr
),
a
=
sparse
.
csc_matrix
((
a_val
,
a_ind
,
a_ptr
),
(
a_nrows
,
b
.
shape
[
0
]),
(
a_nrows
,
b
.
shape
[
0
]),
copy
=
False
)
copy
=
False
)
out
[
0
]
=
a
.
dot
(
b
)
#out[0] = a.dot(b)
out
[
0
]
=
a
*
b
assert
_is_dense
(
out
[
0
])
# scipy 0.7 automatically converts to dense
assert
_is_dense
(
out
[
0
])
# scipy 0.7 automatically converts to dense
def
c_code
(
self
,
node
,
name
,
(
a_val
,
a_ind
,
a_ptr
,
a_nrows
,
b
),
(
z
,),
sub
):
def
c_code
(
self
,
node
,
name
,
(
a_val
,
a_ind
,
a_ptr
,
a_nrows
,
b
),
(
z
,),
sub
):
...
@@ -881,7 +883,8 @@ class StructuredDotCSR(gof.Op):
...
@@ -881,7 +883,8 @@ class StructuredDotCSR(gof.Op):
a
=
sparse
.
csr_matrix
((
a_val
,
a_ind
,
a_ptr
),
a
=
sparse
.
csr_matrix
((
a_val
,
a_ind
,
a_ptr
),
(
len
(
a_ptr
)
-
1
,
b
.
shape
[
0
]),
(
len
(
a_ptr
)
-
1
,
b
.
shape
[
0
]),
copy
=
True
)
#use view_map before setting this to False
copy
=
True
)
#use view_map before setting this to False
out
[
0
]
=
a
.
dot
(
b
)
#out[0] = a.dot(b)
out
[
0
]
=
a
*
b
assert
_is_dense
(
out
[
0
])
# scipy 0.7 automatically converts to dense, but not .6 sometimes
assert
_is_dense
(
out
[
0
])
# scipy 0.7 automatically converts to dense, but not .6 sometimes
def
c_code
(
self
,
node
,
name
,
(
a_val
,
a_ind
,
a_ptr
,
b
),
(
z
,),
sub
):
def
c_code
(
self
,
node
,
name
,
(
a_val
,
a_ind
,
a_ptr
,
b
),
(
z
,),
sub
):
...
...
theano/sparse/tests/test_basic.py
浏览文件 @
d0821805
...
@@ -185,11 +185,11 @@ class test_structureddot(unittest.TestCase):
...
@@ -185,11 +185,11 @@ class test_structureddot(unittest.TestCase):
imvals
=
1.0
*
numpy
.
arange
(
bsize
*
spmat
.
shape
[
1
])
.
reshape
(
bsize
,
spmat
.
shape
[
1
])
imvals
=
1.0
*
numpy
.
arange
(
bsize
*
spmat
.
shape
[
1
])
.
reshape
(
bsize
,
spmat
.
shape
[
1
])
outvals
=
f
(
kernvals
,
imvals
)
outvals
=
f
(
kernvals
,
imvals
)
# compare to scipy
# compare to scipy
c
=
spmat
.
dot
(
imvals
.
T
)
c
=
spmat
*
(
imvals
.
T
)
assert
_is_dense
(
c
)
assert
_is_dense
(
c
)
assert
numpy
.
all
(
outvals
==
c
)
assert
numpy
.
all
(
outvals
==
c
)
tensor
.
verify_grad
(
None
,
buildgraphCSC
,
[
kernvals
,
imvals
])
tensor
.
verify_grad
(
buildgraphCSC
,
[
kernvals
,
imvals
])
##
##
# Test compressed-sparse row matrices ###
# Test compressed-sparse row matrices ###
...
@@ -207,7 +207,7 @@ class test_structureddot(unittest.TestCase):
...
@@ -207,7 +207,7 @@ class test_structureddot(unittest.TestCase):
imvals
=
1.0
*
numpy
.
arange
(
bsize
*
spmat
.
shape
[
1
])
.
reshape
(
bsize
,
spmat
.
shape
[
1
])
imvals
=
1.0
*
numpy
.
arange
(
bsize
*
spmat
.
shape
[
1
])
.
reshape
(
bsize
,
spmat
.
shape
[
1
])
outvals
=
f
(
kernvals
,
imvals
)
outvals
=
f
(
kernvals
,
imvals
)
# compare to scipy
# compare to scipy
c
=
spmat
.
dot
(
imvals
.
T
)
c
=
spmat
*
(
imvals
.
T
)
assert
_is_dense
(
c
)
assert
_is_dense
(
c
)
assert
numpy
.
all
(
outvals
==
c
)
assert
numpy
.
all
(
outvals
==
c
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论