Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
5ab56080
提交
5ab56080
authored
7月 26, 2013
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix import
上级
5243a337
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
10 行增加
和
8 行删除
+10
-8
opt.py
theano/tensor/opt.py
+7
-6
type.py
theano/tensor/type.py
+3
-2
没有找到文件。
theano/tensor/opt.py
浏览文件 @
5ab56080
...
@@ -24,6 +24,7 @@ from theano.gof.python25 import maxsize
...
@@ -24,6 +24,7 @@ from theano.gof.python25 import maxsize
from
theano.gof.utils
import
MethodNotDefined
from
theano.gof.utils
import
MethodNotDefined
from
theano.configparser
import
config
from
theano.configparser
import
config
from
theano.tensor.elemwise
import
Elemwise
,
DimShuffle
from
theano.tensor.elemwise
import
Elemwise
,
DimShuffle
from
theano.tensor.subtensor
import
get_idx_list
,
get_canonical_form_slice
from
theano
import
scalar
from
theano
import
scalar
from
theano.tensor
import
basic
as
T
from
theano.tensor
import
basic
as
T
from
theano
import
compile
# to register the optimizer built by this file
from
theano
import
compile
# to register the optimizer built by this file
...
@@ -1764,8 +1765,8 @@ def merge_two_slices(slice1, len1, slice2, len2):
...
@@ -1764,8 +1765,8 @@ def merge_two_slices(slice1, len1, slice2, len2):
if
type
(
slice1
)
is
not
slice
:
if
type
(
slice1
)
is
not
slice
:
raise
ValueError
((
'First provided slice should actually be of type'
raise
ValueError
((
'First provided slice should actually be of type'
'slice and not an index !'
),
slice1
)
'slice and not an index !'
),
slice1
)
sl1
,
reverse1
=
T
.
get_canonical_form_slice
(
slice1
,
len1
)
sl1
,
reverse1
=
get_canonical_form_slice
(
slice1
,
len1
)
sl2
,
reverse2
=
T
.
get_canonical_form_slice
(
slice2
,
len2
)
sl2
,
reverse2
=
get_canonical_form_slice
(
slice2
,
len2
)
if
type
(
sl2
)
is
not
slice
:
if
type
(
sl2
)
is
not
slice
:
if
reverse1
is
None
:
if
reverse1
is
None
:
...
@@ -1892,8 +1893,8 @@ def local_subtensor_merge(node):
...
@@ -1892,8 +1893,8 @@ def local_subtensor_merge(node):
# x actual tensor on which we are picking slices
# x actual tensor on which we are picking slices
x
=
u
.
owner
.
inputs
[
0
]
x
=
u
.
owner
.
inputs
[
0
]
# slices of the first applied subtensor
# slices of the first applied subtensor
slices1
=
T
.
get_idx_list
(
u
.
owner
.
inputs
,
u
.
owner
.
op
.
idx_list
)
slices1
=
get_idx_list
(
u
.
owner
.
inputs
,
u
.
owner
.
op
.
idx_list
)
slices2
=
T
.
get_idx_list
(
node
.
inputs
,
node
.
op
.
idx_list
)
slices2
=
get_idx_list
(
node
.
inputs
,
node
.
op
.
idx_list
)
# Get the shapes of the vectors !
# Get the shapes of the vectors !
try
:
try
:
# try not to introduce new shape into the graph
# try not to introduce new shape into the graph
...
@@ -1948,7 +1949,7 @@ def local_subtensor_of_alloc(node):
...
@@ -1948,7 +1949,7 @@ def local_subtensor_of_alloc(node):
return
False
return
False
if
not
isinstance
(
u
.
owner
.
op
,
T
.
Alloc
):
if
not
isinstance
(
u
.
owner
.
op
,
T
.
Alloc
):
return
False
return
False
slices
=
T
.
get_idx_list
(
node
.
inputs
,
node
.
op
.
idx_list
)
slices
=
get_idx_list
(
node
.
inputs
,
node
.
op
.
idx_list
)
val
=
u
.
owner
.
inputs
[
0
]
val
=
u
.
owner
.
inputs
[
0
]
dims
=
u
.
owner
.
inputs
[
1
:]
dims
=
u
.
owner
.
inputs
[
1
:]
assert
len
(
slices
)
<=
len
(
dims
)
assert
len
(
slices
)
<=
len
(
dims
)
...
@@ -1972,7 +1973,7 @@ def local_subtensor_of_alloc(node):
...
@@ -1972,7 +1973,7 @@ def local_subtensor_of_alloc(node):
else
:
else
:
val_slices
.
append
(
sl
)
val_slices
.
append
(
sl
)
csl
,
_
=
T
.
get_canonical_form_slice
(
sl
,
dim
)
csl
,
_
=
get_canonical_form_slice
(
sl
,
dim
)
if
type
(
csl
)
is
not
slice
:
if
type
(
csl
)
is
not
slice
:
# That dimension is removed.
# That dimension is removed.
pass
pass
...
...
theano/tensor/type.py
浏览文件 @
5ab56080
import
numpy
import
numpy
import
theano
import
theano
from
theano.gof
import
hashtype
,
Type
,
Variable
from
theano
import
config
from
theano.gof
import
Constant
,
hashtype
,
Type
,
Variable
from
theano.gof.python25
import
any
from
theano.gof.python25
import
any
from
theano
import
scalar
as
scal
from
theano
import
scalar
as
scal
...
@@ -297,7 +298,7 @@ class TensorType(Type):
...
@@ -297,7 +298,7 @@ class TensorType(Type):
a
=
a
.
reshape
(
1
)
a
=
a
.
reshape
(
1
)
b
=
b
.
reshape
(
1
)
b
=
b
.
reshape
(
1
)
cmp
=
_allclose
(
a
,
b
,
rtol
=
rtol
,
atol
=
atol
)
cmp
=
theano
.
tensor
.
basic
.
_allclose
(
a
,
b
,
rtol
=
rtol
,
atol
=
atol
)
if
cmp
:
if
cmp
:
# Numpy claims they are close, this is good enough for us.
# Numpy claims they are close, this is good enough for us.
return
True
return
True
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论