Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
f7b98a6e
提交
f7b98a6e
authored
6月 10, 2014
作者:
abergeron
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1867 from nouiz/fix_test
Fix test
上级
95b4fec5
6cfb201b
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
33 行增加
和
7 行删除
+33
-7
type.py
theano/gof/type.py
+8
-1
ops.py
theano/sandbox/linalg/ops.py
+13
-2
test_linalg.py
theano/sandbox/linalg/tests/test_linalg.py
+10
-1
type_other.py
theano/tensor/type_other.py
+2
-3
没有找到文件。
theano/gof/type.py
浏览文件 @
f7b98a6e
...
@@ -401,10 +401,17 @@ class SingletonType(Type):
...
@@ -401,10 +401,17 @@ class SingletonType(Type):
It saves having to implement __eq__ and __hash__
It saves having to implement __eq__ and __hash__
"""
"""
__instance
=
None
__instance
=
None
def
__new__
(
cls
):
def
__new__
(
cls
):
if
cls
.
__instance
is
None
:
# If sub-subclass of SingletonType don't redeclare __instance
# when we look for it, we will find it in the subclass. We
# don't want that, so we check the class. When we add one, we
# add one only to the current class, so all is working
# correctly.
if
cls
.
__instance
is
None
or
not
isinstance
(
cls
.
__instance
,
cls
):
cls
.
__instance
=
Type
.
__new__
(
cls
)
cls
.
__instance
=
Type
.
__new__
(
cls
)
return
cls
.
__instance
return
cls
.
__instance
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
__class__
.
__name__
return
self
.
__class__
.
__name__
...
...
theano/sandbox/linalg/ops.py
浏览文件 @
f7b98a6e
...
@@ -1119,11 +1119,22 @@ class Eigvalsh(Op):
...
@@ -1119,11 +1119,22 @@ class Eigvalsh(Op):
def
make_node
(
self
,
a
,
b
):
def
make_node
(
self
,
a
,
b
):
assert
imported_scipy
,
(
assert
imported_scipy
,
(
"Scipy not available. Scipy is needed for the Eigvalsh op"
)
"Scipy not available. Scipy is needed for the Eigvalsh op"
)
a
,
b
=
map
(
as_tensor_variable
,
(
a
,
b
)
)
a
=
as_tensor_variable
(
a
)
assert
a
.
ndim
==
2
assert
a
.
ndim
==
2
if
not
isinstance
(
b
,
(
theano
.
Variable
)):
if
b
is
None
:
b
=
theano
.
tensor
.
NoneConst
out_dtype
=
a
.
dtype
else
:
b
=
as_tensor_variable
(
b
)
out_dtype
=
theano
.
scalar
.
upcast
(
a
.
dtype
,
b
.
dtype
)
elif
not
isinstance
(
b
.
type
,
theano
.
tensor
.
NoneTypeT
):
b
=
as_tensor_variable
(
b
)
out_dtype
=
theano
.
scalar
.
upcast
(
a
.
dtype
,
b
.
dtype
)
assert
b
.
ndim
==
2
assert
b
.
ndim
==
2
else
:
out_dtype
=
a
.
dtype
out_dtype
=
theano
.
scalar
.
upcast
(
a
.
dtype
,
b
.
dtype
)
w
=
theano
.
tensor
.
vector
(
dtype
=
out_dtype
)
w
=
theano
.
tensor
.
vector
(
dtype
=
out_dtype
)
return
Apply
(
self
,
[
a
,
b
],
[
w
])
return
Apply
(
self
,
[
a
,
b
],
[
w
])
...
...
theano/sandbox/linalg/tests/test_linalg.py
浏览文件 @
f7b98a6e
...
@@ -587,11 +587,20 @@ def test_eigvalsh():
...
@@ -587,11 +587,20 @@ def test_eigvalsh():
rng
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
rng
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
a
=
rng
.
randn
(
5
,
5
)
a
=
rng
.
randn
(
5
,
5
)
a
=
a
+
a
.
T
a
=
a
+
a
.
T
for
b
in
[
10
*
numpy
.
eye
(
5
,
5
)
+
rng
.
randn
(
5
,
5
)
,
None
]:
for
b
in
[
10
*
numpy
.
eye
(
5
,
5
)
+
rng
.
randn
(
5
,
5
)]:
w
=
f
(
a
,
b
)
w
=
f
(
a
,
b
)
refw
=
scipy
.
linalg
.
eigvalsh
(
a
,
b
)
refw
=
scipy
.
linalg
.
eigvalsh
(
a
,
b
)
numpy
.
testing
.
assert_array_almost_equal
(
w
,
refw
)
numpy
.
testing
.
assert_array_almost_equal
(
w
,
refw
)
# We need to test None separatly, as otherwise DebugMode will
# complain, as this isn't a valid ndarray.
b
=
None
B
=
theano
.
tensor
.
NoneConst
f
=
function
([
A
],
eigvalsh
(
A
,
B
))
w
=
f
(
a
)
refw
=
scipy
.
linalg
.
eigvalsh
(
a
,
b
)
numpy
.
testing
.
assert_array_almost_equal
(
w
,
refw
)
def
test_eigvalsh_grad
():
def
test_eigvalsh_grad
():
rng
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
rng
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
...
...
theano/tensor/type_other.py
浏览文件 @
f7b98a6e
...
@@ -72,10 +72,9 @@ class NoneTypeT(Generic):
...
@@ -72,10 +72,9 @@ class NoneTypeT(Generic):
else
:
else
:
raise
TypeError
(
'Expected None!'
)
raise
TypeError
(
'Expected None!'
)
def
__str__
(
self
):
none_type_t
=
NoneTypeT
()
return
"None"
# This is a variable instance. It can be used only once per fgraph.
# This is a variable instance. It can be used only once per fgraph.
# So use NoneConst.clone() before using it in a Theano graph.
# So use NoneConst.clone() before using it in a Theano graph.
# Use NoneConst.equal(x) to check if two variable are NoneConst.
# Use NoneConst.equal(x) to check if two variable are NoneConst.
NoneConst
=
Constant
(
NoneTypeT
(),
None
,
name
=
'None'
)
NoneConst
=
Constant
(
NoneTypeT
(),
None
,
name
=
'None
Const
'
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论