Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
9dd0bdf3
提交
9dd0bdf3
authored
9月 05, 2012
作者:
Ian Goodfellow
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
removed dead code
上级
ec0d4be3
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
0 行增加
和
159 行删除
+0
-159
basic.py
theano/tensor/basic.py
+0
-159
没有找到文件。
theano/tensor/basic.py
浏览文件 @
9dd0bdf3
...
...
@@ -2991,73 +2991,6 @@ def eye(n, m=None, k=0, dtype=None):
def
identity_like
(
x
):
return
eye
(
x
.
shape
[
0
],
x
.
shape
[
1
],
k
=
0
,
dtype
=
x
.
dtype
)
if
0
:
## COMMENTED OUT FEB 17 2010
## TODO (DOCUMENT AND WRITE TESTS) OR DELETE
class
Filler
(
gof
.
Op
):
"""WRITEME"""
def
__init__
(
self
,
value
,
ndim
,
dtype
=
'float64'
):
self
.
value
=
value
self
.
ndim
=
ndim
self
.
dtype
=
dtype
self
.
type
=
TensorType
(
dtype
=
dtype
,
broadcastable
=
(
False
,)
*
ndim
)
def
make_node
(
self
,
dims
):
dims
=
as_tensor_variable
(
dims
)
return
gof
.
Apply
(
self
,
[
dims
],
[
self
.
type
()])
def
perform
(
self
,
node
,
inp
,
out_
):
dims
,
=
inp
out
,
=
out_
if
out
[
0
]
is
not
None
:
out
[
0
]
.
resize
(
dims
,
refcheck
=
0
)
out
[
0
]
.
fill
(
self
.
value
)
else
:
if
self
.
value
==
0
:
out
[
0
]
=
numpy
.
zeros
(
dims
,
dtype
=
self
.
dtype
)
elif
self
.
value
==
1
:
out
[
0
]
=
numpy
.
ones
(
dims
,
dtype
=
self
.
dtype
)
else
:
out
[
0
]
=
numpy
.
ones
(
dims
,
dtype
=
self
.
dtype
)
*
self
.
value
def
grad
(
self
,
inp
,
grads
):
return
None
,
def
__eq__
(
self
,
other
):
return
(
type
(
self
)
==
type
(
other
)
and
self
.
ndim
==
other
.
ndim
and
self
.
dtype
==
other
.
dtype
)
def
__hash__
(
self
):
return
hash
(
self
.
ndim
)
^
hash
(
self
.
dtype
)
Zeros
=
partial
(
Filler
,
0
)
"""WRITEME"""
Ones
=
partial
(
Filler
,
1
)
"""WRITEME"""
@constructor
def
zero
():
"""
Return a scalar zero, e.g. for initializing sums.
"""
return
Zeros
(
0
)([])
@constructor
def
one
():
"""WRITEME"""
return
Ones
(
0
)([])
pprint
.
assign
(
lambda
pstate
,
r
:
r
.
owner
and
isinstance
(
r
.
owner
.
op
,
Filler
)
and
r
.
owner
.
op
.
value
==
0
,
printing
.
FunctionPrinter
(
'zeros'
))
pprint
.
assign
(
lambda
pstate
,
r
:
r
.
owner
and
isinstance
(
r
.
owner
.
op
,
Filler
)
and
r
.
owner
.
op
.
value
==
1
,
printing
.
FunctionPrinter
(
'ones'
))
class
Alloc
(
gof
.
Op
):
"""Create a Tensor from an initial value and a desired shape
...
...
@@ -3446,43 +3379,6 @@ def std(input, axis=None, keepdims=False):
return
sqrt
(
var
(
input
=
input
,
axis
=
axis
,
keepdims
=
keepdims
))
if
0
:
## COMMENTED OUT FEB 17 2010
## TODO (DOCUMENT AND WRITE TESTS) OR DELETE
class
Repeat
(
gof
.
Op
):
def
make_node
(
self
,
input
,
repeats
,
axis
):
assert
isinstance
(
input
.
type
,
TensorType
)
assert
repeats
.
type
==
iscalar
assert
axis
.
type
==
iscalar
broadcastable
=
[]
for
i
,
x
in
enumerate
(
input
.
broadcastable
):
if
i
==
axis
:
broadcastable
+=
[
False
]
else
:
broadcastable
+=
[
x
]
type
=
TensorType
(
dtype
=
input
.
type
.
dtype
,
broadcastable
=
broadcastable
)
# backport
# type = TensorType(dtype=input.type.dtype,
# broadcastable=[
# False if i==axis else x
# for i, x in enumerate(input.broadcastable)])
return
gof
.
Apply
(
self
,
[
inputs
,
repeats
,
axis
],
[
type
()])
def
perform
(
self
,
node
,
inp
,
out_
):
input
,
repeats
,
axis
=
inp
out
,
=
out_
out
[
0
]
=
numpy
.
repeat
(
input
,
repeats
,
axis
)
def
grad
(
self
,
inp
,
grads
):
input
,
repeats
,
axis
=
inp
gout
,
=
grads
return
add
.
grad
((
input
,
gout
),
(
gout
,))[:
1
]
repeat
=
Repeat
()
class
Default
(
gof
.
Op
):
"""
...
...
@@ -5313,61 +5209,6 @@ def vertical_stack(*args):
assert
arg
.
type
.
ndim
==
2
return
concatenate
(
args
,
axis
=
0
)
# Vertical and horizontal stacking are deprecated. Better to use stack() and
# join().
if
0
:
class
VerticalStack
(
Op
):
"""
Vertically stack two L{TensorType}s.
Stack two L{TensorType}s along the first axis (row wise). These
L{TensorType}s must have the same shape along all dimensions but the
first.
@attention: Because we use vstack as the implementation, if the
inputs have 1-dimension, the output will have 2-dimensions.
"""
def
make_node
(
self
,
x
,
y
):
x
=
as_tensor_variable
(
x
)
y
=
as_tensor_variable
(
y
)
assert
x
.
type
.
dtype
==
y
.
type
.
dtype
if
x
.
type
.
broadcastable
[
1
:]
!=
y
.
type
.
broadcastable
[
1
:]:
raise
NotImplementedError
inputs
=
[
x
,
y
]
bcastable
=
(
False
,
)
+
x
.
type
.
broadcastable
[
1
:]
outputs
=
[
tensor
(
dtype
=
x
.
type
.
dtype
,
broadcastable
=
bcastable
)]
return
Apply
(
self
,
inputs
,
outputs
)
def
perform
(
self
,
node
,
inp
,
out_
):
x
,
y
=
inp
out
,
=
out_
assert
x
.
ndim
==
y
.
ndim
# Make sure every dimension (save the first) is the same
for
i
in
xrange
(
x
.
ndim
):
assert
i
==
0
or
x
.
shape
[
i
]
==
y
.
shape
[
i
]
out
[
0
]
=
numpy
.
vstack
([
x
,
y
])
def
grad
(
self
,
inp
,
grads
):
"""
@todo: Make VSplit (or this grad implementation) its own L{Op},
that way we can do more sanity-checking::
assert x.ndim == y.ndim
# Make sure every dimension (save the first) is the same
for i in xrange(x.data.ndim):
assert i == 0 or x.data.shape[i] == y.shape[i]
etc...
"""
x
,
y
=
inp
gz
,
=
grads
xs
=
shape
(
x
)
return
gz
[:
xs
[
0
]],
gz
[
xs
[
0
]:]
vertical_stack
=
VerticalStack
()
else
:
pass
class
Reshape
(
Op
):
"""Perform a reshape operation of the input x to the new shape shp.
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论