Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
77d8c018
提交
77d8c018
authored
9月 07, 2009
作者:
Olivier Breuleux
浏览文件
操作
浏览文件
下载
差异文件
merge
上级
c5a0b307
721e1885
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
25 行增加
和
11 行删除
+25
-11
link.py
theano/gof/link.py
+4
-4
basic.py
theano/tensor/basic.py
+15
-3
nnet.py
theano/tensor/nnet.py
+6
-4
没有找到文件。
theano/gof/link.py
浏览文件 @
77d8c018
...
@@ -146,9 +146,9 @@ class Container(object):
...
@@ -146,9 +146,9 @@ class Container(object):
self
.
storage
=
storage
self
.
storage
=
storage
self
.
readonly
=
readonly
self
.
readonly
=
readonly
self
.
strict
=
strict
self
.
strict
=
strict
def
__get
(
self
):
def
__get
__
(
self
):
return
self
.
storage
[
0
]
return
self
.
storage
[
0
]
def
__set
(
self
,
value
):
def
__set
__
(
self
,
value
):
if
self
.
readonly
:
if
self
.
readonly
:
raise
Exception
(
"Cannot set readonly storage:
%
s"
%
self
.
name
)
raise
Exception
(
"Cannot set readonly storage:
%
s"
%
self
.
name
)
try
:
try
:
...
@@ -162,8 +162,8 @@ class Container(object):
...
@@ -162,8 +162,8 @@ class Container(object):
except
Exception
,
e
:
except
Exception
,
e
:
e
.
args
=
e
.
args
+
((
'Container name "
%
s"'
%
self
.
name
),)
e
.
args
=
e
.
args
+
((
'Container name "
%
s"'
%
self
.
name
),)
raise
raise
data
=
property
(
__get
,
__set
)
data
=
property
(
__get
__
,
__set__
)
value
=
property
(
__get
,
__set
)
value
=
property
(
__get
__
,
__set__
)
def
__str__
(
self
):
def
__str__
(
self
):
return
"<"
+
str
(
self
.
storage
[
0
])
+
">"
return
"<"
+
str
(
self
.
storage
[
0
])
+
">"
def
__repr__
(
self
):
def
__repr__
(
self
):
...
...
theano/tensor/basic.py
浏览文件 @
77d8c018
...
@@ -373,9 +373,11 @@ class TensorType(Type):
...
@@ -373,9 +373,11 @@ class TensorType(Type):
def
c_extract
(
self
,
name
,
sub
):
def
c_extract
(
self
,
name
,
sub
):
"""Override `CLinkerOp.c_extract` """
"""Override `CLinkerOp.c_extract` """
# TODO: make the error message print out the dtype of the
# input received.
return
"""
return
"""
%(name)
s = NULL;
%(name)
s = NULL;
type_num_
%(name)
s =
%(type_num)
s;
type_num_
%(name)
s =
((PyArrayObject*)py_
%(name)
s)->descr->type_num; //we expect
%(type_num)
s
if (py_
%(name)
s == Py_None) {
if (py_
%(name)
s == Py_None) {
// We can either fail here or set
%(name)
s to NULL and rely on Ops using
// We can either fail here or set
%(name)
s to NULL and rely on Ops using
// tensors to handle the NULL case, but if they fail to do so they'll end up
// tensors to handle the NULL case, but if they fail to do so they'll end up
...
@@ -387,7 +389,7 @@ class TensorType(Type):
...
@@ -387,7 +389,7 @@ class TensorType(Type):
PyErr_SetString(PyExc_ValueError, "expected an ndarray");
PyErr_SetString(PyExc_ValueError, "expected an ndarray");
%(fail)
s
%(fail)
s
}
}
else if (
((PyArrayObject*)py_
%(name)
s)->descr->type_num
!=
%(type_num)
s) {
else if (
type_num_
%(name)
s
!=
%(type_num)
s) {
PyErr_SetString(PyExc_ValueError, "expected
%(type_num)
s");
PyErr_SetString(PyExc_ValueError, "expected
%(type_num)
s");
%(fail)
s
%(fail)
s
}
}
...
@@ -1358,6 +1360,15 @@ class Repeat(gof.Op):
...
@@ -1358,6 +1360,15 @@ class Repeat(gof.Op):
repeat
=
Repeat
()
repeat
=
Repeat
()
class
SetDefault
(
gof
.
Op
):
view_map
=
{
0
:
[
1
]}
def
make_node
(
self
,
x
,
default
):
assert
x
.
type
==
default
.
type
return
gof
.
Apply
(
self
,
[
x
,
default
],
[
default
.
type
()])
def
perform
(
self
,
node
,
(
x
,
default
),
(
out
,
)):
out
[
0
]
=
default
.
copy
()
if
x
is
None
else
x
setdefault
=
SetDefault
()
##########################
##########################
...
@@ -1852,7 +1863,6 @@ class Split(Op):
...
@@ -1852,7 +1863,6 @@ class Split(Op):
return
[
join
(
axis
,
*
g_outputs
),
None
,
None
]
return
[
join
(
axis
,
*
g_outputs
),
None
,
None
]
class
Rebroadcast
(
Op
):
class
Rebroadcast
(
Op
):
"""
"""
Change the input's broadcastable fields in
Change the input's broadcastable fields in
...
@@ -1892,6 +1902,7 @@ def unbroadcast(x, *axes):
...
@@ -1892,6 +1902,7 @@ def unbroadcast(x, *axes):
return
Rebroadcast
(
*
[(
axis
,
False
)
for
axis
in
axes
])(
x
)
return
Rebroadcast
(
*
[(
axis
,
False
)
for
axis
in
axes
])(
x
)
class
Join
(
Op
):
class
Join
(
Op
):
"""
"""
Concatenate multiple `TensorVariable`s along some axis.
Concatenate multiple `TensorVariable`s along some axis.
...
@@ -2523,6 +2534,7 @@ class Outer(Op):
...
@@ -2523,6 +2534,7 @@ class Outer(Op):
return
"outer"
return
"outer"
outer
=
Outer
()
outer
=
Outer
()
#########################
#########################
# Gradient
# Gradient
#########################
#########################
...
...
theano/tensor/nnet.py
浏览文件 @
77d8c018
...
@@ -394,10 +394,12 @@ def local_softmax_with_bias(node):
...
@@ -394,10 +394,12 @@ def local_softmax_with_bias(node):
vectors
=
[]
vectors
=
[]
non_vectors
=
[]
non_vectors
=
[]
for
x_in
in
x
.
owner
.
inputs
:
for
x_in
in
x
.
owner
.
inputs
:
if
list
(
x_in
.
type
.
broadcastable
)
==
[
True
,
False
]
\
if
list
(
x_in
.
type
.
broadcastable
)
==
[
True
,
False
]:
and
isinstance
(
x_in
.
owner
.
op
,
tensor
.
DimShuffle
):
if
x_in
.
owner
and
isinstance
(
x_in
.
owner
.
op
,
tensor
.
DimShuffle
):
assert
len
(
x_in
.
owner
.
inputs
)
==
1
assert
len
(
x_in
.
owner
.
inputs
)
==
1
vectors
.
append
(
x_in
.
owner
.
inputs
[
0
])
vectors
.
append
(
x_in
.
owner
.
inputs
[
0
])
else
:
vectors
.
append
(
tensor
.
DimShuffle
((
True
,
False
),
(
1
,))(
x_in
))
else
:
else
:
non_vectors
.
append
(
x_in
)
non_vectors
.
append
(
x_in
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论