Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
cc041dc3
提交
cc041dc3
authored
11月 13, 2008
作者:
James Bergstra
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
removed automatic casts, and changed mean to cast input to FP, and added print op
上级
a06073d6
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
35 行增加
和
6 行删除
+35
-6
printing.py
theano/printing.py
+25
-1
basic.py
theano/tensor/basic.py
+10
-5
没有找到文件。
theano/printing.py
浏览文件 @
cc041dc3
"""Pretty-printing graphs, and the 'Print' Op.
"""
import
gof
from
copy
import
copy
import
sys
from
gof
import
Op
,
Apply
class
Print
(
Op
):
"""This identity-like Op has the side effect of printing a message followed by its inputs
when it runs.
"""
def
__init__
(
self
,
message
=
""
):
self
.
message
=
message
self
.
view_map
=
{
0
:[
0
]}
def
make_node
(
self
,
xin
):
xout
=
xin
.
type
.
make_result
()
return
Apply
(
op
=
self
,
inputs
=
[
xin
],
outputs
=
[
xout
])
def
perform
(
self
,
node
,
inputs
,
output_storage
):
xin
,
=
inputs
xout
,
=
output_storage
xout
[
0
]
=
xin
print
self
.
message
,
xin
def
grad
(
self
,
input
,
output_gradients
):
return
output_gradients
class
PrinterState
(
gof
.
utils
.
scratchpad
):
...
...
@@ -232,3 +255,4 @@ pprint.assign(lambda pstate, r: hasattr(pstate, 'target') and pstate.target is n
pp
=
pprint
theano/tensor/basic.py
浏览文件 @
cc041dc3
...
...
@@ -21,7 +21,7 @@ from .. import scalar as scal
from
..gof.python25
import
partial
from
..
import
compile
,
printing
from
..printing
import
pprint
from
..printing
import
pprint
,
Print
### set up the external interface
...
...
@@ -456,10 +456,11 @@ class _tensor_py_operators:
def
__abs__
(
self
):
return
abs_
(
self
)
def
__neg__
(
self
):
return
neg
(
self
)
#CASTS
def
__int__
(
self
):
return
AsInt
(
self
)
.
out
def
__float__
(
self
):
return
AsInt
(
self
)
.
out
def
__complex__
(
self
):
return
AsComplex
(
self
)
.
out
#CASTS
#### REMOVED THESE BECAUSE PYTHON appears to require __int__ to return an int. -JB 20081112
#def __int__(self): return convert_to_int32(self)
#def __float__(self): return convert_to_float64(self)
#def __complex__(self): return convert_to_complex128(self)
#COMPARISONS
def
__lt__
(
self
,
other
):
return
lt
(
self
,
other
)
...
...
@@ -1012,6 +1013,10 @@ pprint.assign(Sum(), printing.FunctionPrinter('sum'))
@constructor
def
mean
(
input
,
axis
=
None
):
"""WRITEME"""
if
str
(
input
.
dtype
)
.
startswith
(
'int'
):
# we need to cast eventually anyway, and this helps
# to prevents overflow
input
=
convert_to_float64
(
input
)
s
=
sum
(
input
,
axis
)
shp
=
shape
(
input
)
if
axis
is
None
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论