Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
51a3f3a5
提交
51a3f3a5
authored
12月 21, 2012
作者:
Jeremiah Lowin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
changes made for clarity, per code review
上级
cbee7123
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
23 行增加
和
24 行删除
+23
-24
test_compute_test_value.py
theano/gof/tests/test_compute_test_value.py
+1
-1
basic.py
theano/tensor/basic.py
+20
-13
test_basic.py
theano/tensor/tests/test_basic.py
+2
-10
没有找到文件。
theano/gof/tests/test_compute_test_value.py
浏览文件 @
51a3f3a5
...
@@ -243,7 +243,7 @@ class TestComputeTestValue(unittest.TestCase):
...
@@ -243,7 +243,7 @@ class TestComputeTestValue(unittest.TestCase):
except
ValueError
,
e
:
except
ValueError
,
e
:
# Get traceback
# Get traceback
tb
=
sys
.
exc_info
()[
2
]
tb
=
sys
.
exc_info
()[
2
]
# Get frame info
3
layers up
# Get frame info
4
layers up
frame_info
=
traceback
.
extract_tb
(
tb
)[
-
5
]
frame_info
=
traceback
.
extract_tb
(
tb
)[
-
5
]
# We should be in the "fx" function defined above
# We should be in the "fx" function defined above
assert
os
.
path
.
split
(
frame_info
[
0
])[
1
]
==
'test_compute_test_value.py'
assert
os
.
path
.
split
(
frame_info
[
0
])[
1
]
==
'test_compute_test_value.py'
...
...
theano/tensor/basic.py
浏览文件 @
51a3f3a5
...
@@ -6872,12 +6872,14 @@ class Dot(Op):
...
@@ -6872,12 +6872,14 @@ class Dot(Op):
equivalent to matrix multiplication. For two vectors, this is the inner
equivalent to matrix multiplication. For two vectors, this is the inner
product.
product.
:note: matrix-matrix products are sometimes optimized to Dot22 o
ps
:note: matrix-matrix products are sometimes optimized to Dot22 o
r Gemm ops.
(see tensor.blas)
(see tensor.blas)
:note: non matrix-matrix products (including matrix-vector
:note: vector-vector products are sometimes optimized to Ger or CGer. (see
products) are handled by numpy. Ensure that you have linked numpy
tensor.blas)
with a fast BLAS.
:note: matrix-vector products are sometimes optimized to Gemv, CGemv (see
tensor.blas)
"""
"""
...
@@ -7082,11 +7084,14 @@ def dot(a, b):
...
@@ -7082,11 +7084,14 @@ def dot(a, b):
3. If both a and b have either 1 or 2 dimensions, it calls Theano's
3. If both a and b have either 1 or 2 dimensions, it calls Theano's
Dot op on a and b.
Dot op on a and b.
:note: matrix-matrix products are sometimes optimized to Dot22 ops.
:note: matrix-matrix products are sometimes optimized to Dot22 or Gemm ops.
(see tensor.blas)
:note: vector-vector products are sometimes optimized to Ger or CGer. (see
tensor.blas)
:note: non matrix-matrix products (including matrix-vector
:note: matrix-vector products are sometimes optimized to Gemv, CGemv (see
products) are handled by numpy. Ensure that you have linked numpy
tensor.blas)
with a fast BLAS.
"""
"""
a
,
b
=
as_tensor_variable
(
a
),
as_tensor_variable
(
b
)
a
,
b
=
as_tensor_variable
(
a
),
as_tensor_variable
(
b
)
...
@@ -7103,7 +7108,6 @@ def dot(a, b):
...
@@ -7103,7 +7108,6 @@ def dot(a, b):
#########################
#########################
# Linalg : TensorDot
# Linalg : TensorDot
#########################
#########################
# TODO: tensordot should be function as described in rst docs.
def
tensordot
(
a
,
b
,
axes
=
2
):
def
tensordot
(
a
,
b
,
axes
=
2
):
"""
"""
...
@@ -7195,15 +7199,18 @@ def tensordot(a, b, axes = 2):
...
@@ -7195,15 +7199,18 @@ def tensordot(a, b, axes = 2):
# axes must be a scalar or list/tuple of length 2
# axes must be a scalar or list/tuple of length 2
if
not
numpy
.
isscalar
(
axes
)
and
len
(
axes
)
!=
2
:
if
not
numpy
.
isscalar
(
axes
)
and
len
(
axes
)
!=
2
:
raise
ValueError
(
'Axes should be scalar valued or a '
raise
ValueError
(
'Axes should be scalar valued or a '
'list/tuple of len 2
.'
)
'list/tuple of len 2
(
%
r was provided)'
%
axes
)
# if 'axes' is a number of axes to multiply and sum over (trailing axes
# if 'axes' is a number of axes to multiply and sum over (trailing axes
# of a, leading axes of b), we can just reshape and use dot.
# of a, leading axes of b), we can just reshape and use dot.
elif
numpy
.
isscalar
(
axes
):
elif
numpy
.
isscalar
(
axes
):
# check if axes is valid given the dimension of a and b
# check if axes is valid given the dimension of a and b
if
axes
>
a
.
ndim
or
axes
>
b
.
ndim
:
if
axes
>
a
.
ndim
:
raise
ValueError
(
'axes should be smaller than the dimension of '
'a (a.ndim=
%
i, axes=
%
i)'
%
(
a
.
ndim
,
axes
))
if
axes
>
b
.
ndim
:
raise
ValueError
(
'axes should be smaller than the dimension of '
raise
ValueError
(
'axes should be smaller than the dimension of '
'
a and b (a.ndim=
%
i, b.ndim=
%
i)'
%
(
a
.
ndim
,
b
.
ndim
))
'
b (b.ndim=
%
i, axes=
%
i)'
%
(
b
.
ndim
,
axes
))
outshape
=
concatenate
([
a
.
shape
[:
a
.
ndim
-
axes
],
b
.
shape
[
axes
:]])
outshape
=
concatenate
([
a
.
shape
[:
a
.
ndim
-
axes
],
b
.
shape
[
axes
:]])
outndim
=
a
.
ndim
+
b
.
ndim
-
(
2
*
axes
)
outndim
=
a
.
ndim
+
b
.
ndim
-
(
2
*
axes
)
...
...
theano/tensor/tests/test_basic.py
浏览文件 @
51a3f3a5
...
@@ -4310,19 +4310,11 @@ class t_dot(unittest.TestCase):
...
@@ -4310,19 +4310,11 @@ class t_dot(unittest.TestCase):
#numpy return matrix not aligned...
#numpy return matrix not aligned...
def
test_dot_1d_1d0
(
self
):
def
test_dot_1d_1d0
(
self
):
try
:
self
.
assertRaises
(
ValueError
,
self
.
cmp_dot
,
rand
(
5
),
rand
(
0
))
self
.
cmp_dot
(
rand
(
5
),
rand
(
0
))
assert
False
except
ValueError
:
pass
#numpy return matrix not aligned...
#numpy return matrix not aligned...
def
test_dot_1d0_1d
(
self
):
def
test_dot_1d0_1d
(
self
):
try
:
self
.
assertRaises
(
ValueError
,
self
.
cmp_dot
,
rand
(
0
),
rand
(
5
))
self
.
cmp_dot
(
rand
(
0
),
rand
(
5
))
assert
False
except
ValueError
:
pass
def
test_dot_1d_2d
(
self
):
def
test_dot_1d_2d
(
self
):
self
.
cmp_dot
(
rand
(
6
),
rand
(
6
,
7
))
self
.
cmp_dot
(
rand
(
6
),
rand
(
6
,
7
))
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论