Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
2f95561e
提交
2f95561e
authored
7月 05, 2011
作者:
James Bergstra
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added profile param to function
* * * added profile param support to function * * * added profile param support to pfunc * * * profile argument support in DebugMode
上级
754d4dd6
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
55 行增加
和
13 行删除
+55
-13
debugmode.py
theano/compile/debugmode.py
+8
-3
function.py
theano/compile/function.py
+11
-2
pfunc.py
theano/compile/pfunc.py
+36
-8
没有找到文件。
theano/compile/debugmode.py
浏览文件 @
2f95561e
"""Provides `DebugMode`, an evaluation mode for debugging theano internals."""
"""Provides `DebugMode`, an evaluation mode for debugging theano internals.
:TODO: add support for Cond Op, LazyLinker, PureOp, etc.
"""
__docformat__
=
"restructuredtext en"
import
time
,
copy
,
sys
,
copy_reg
,
gc
,
os
...
...
@@ -1552,7 +1556,8 @@ class _Maker(FunctionMaker): #inheritance buys a few helper functions
def
__init__
(
self
,
inputs
,
outputs
,
optimizer
,
mode
,
accept_inplace
=
False
,
function_builder
=
Function
):
function_builder
=
Function
,
profile
=
None
):
"""
:type inputs: a list of SymbolicInput instances
...
...
@@ -1567,7 +1572,7 @@ class _Maker(FunctionMaker): #inheritance buys a few helper functions
:note: this function sets TensorType.filter_checks_isfinite when `mode.check_isfinite` is True
"""
self
.
profile
=
profile
# Handle the case where inputs and/or outputs is a single Variable (not in a list)
unpack_single
=
False
return_none
=
False
...
...
theano/compile/function.py
浏览文件 @
2f95561e
...
...
@@ -7,12 +7,13 @@ _logger = logging.getLogger('theano.compile.function')
from
io
import
In
from
function_module
import
orig_function
from
profiling
import
ProfileStats
from
pfunc
import
pfunc
from
numpy
import
any
#for to work in python 2.4
def
function
(
inputs
,
outputs
=
None
,
mode
=
None
,
updates
=
[],
givens
=
[],
no_default_updates
=
False
,
accept_inplace
=
False
,
name
=
None
,
rebuild_strict
=
True
,
allow_input_downcast
=
None
):
rebuild_strict
=
True
,
allow_input_downcast
=
None
,
profile
=
None
):
"""
Return a callable object that will calculate `outputs` from `inputs`.
...
...
@@ -62,6 +63,11 @@ def function(inputs, outputs=None, mode=None, updates=[], givens=[],
precise, type. None (default) is almost like False, but allows
downcasting of Python float scalars to floatX.
:type profile: None, True, or ProfileStats instance
:param profile: accumulate profiling information into a given ProfileStats
instance. If argument is `True` then a new ProfileStats instance will be
used. This profiling object will be available via self.profile.
:note: Regarding givens: Be careful to make sure that these substitutions are
independent--behaviour when Var1 of one pair appears in the graph leading to Var2 in
another expression is undefined. Replacements specified with givens are different from
...
...
@@ -88,6 +94,8 @@ def function(inputs, outputs=None, mode=None, updates=[], givens=[],
if
uses_In
or
uses_tuple
:
# we must use old semantics in this case.
if
profile
:
raise
NotImplementedError
(
'profiling not supported in old-style function'
)
if
uses_updates
or
uses_givens
:
raise
NotImplementedError
(
"In() instances and tuple inputs triggers the old semantics, which disallow using updates and givens"
)
fn
=
orig_function
(
inputs
,
outputs
,
...
...
@@ -102,7 +110,8 @@ def function(inputs, outputs=None, mode=None, updates=[], givens=[],
no_default_updates
=
no_default_updates
,
accept_inplace
=
accept_inplace
,
name
=
name
,
rebuild_strict
=
rebuild_strict
,
allow_input_downcast
=
allow_input_downcast
)
allow_input_downcast
=
allow_input_downcast
,
profile
=
profile
)
# We need to add the flag check_aliased inputs if we have any mutable or
# borrowed used defined inputs
fn
.
_check_for_aliased_inputs
=
check_for_aliased_inputs
...
...
theano/compile/pfunc.py
浏览文件 @
2f95561e
"""Provide a simple user friendly API """
__docformat__
=
'restructuredtext en'
import
numpy
# for backport to 2.4, to get any().
from
profiling
import
ProfileStats
from
theano.gof
import
Container
,
Variable
,
generic
,
graph
,
Constant
,
Value
from
theano.compile
import
orig_function
,
In
,
Out
from
theano.compile.sharedvalue
import
SharedVariable
,
shared
import
numpy
# for backport to 2.4, to get any().
from
theano
import
config
def
rebuild_collect_shared
(
outputs
,
inputs
=
None
...
...
@@ -292,7 +295,8 @@ class Param(object):
def
pfunc
(
params
,
outputs
=
None
,
mode
=
None
,
updates
=
[],
givens
=
[],
no_default_updates
=
False
,
accept_inplace
=
False
,
name
=
None
,
rebuild_strict
=
True
,
allow_input_downcast
=
None
):
rebuild_strict
=
True
,
allow_input_downcast
=
None
,
profile
=
None
):
"""Function-constructor for graphs with shared variables.
:type params: list of either Variable or Param instances.
...
...
@@ -319,11 +323,9 @@ def pfunc(params, outputs=None, mode=None, updates=[], givens=[],
If False (default), perform them all. Else, perform automatic updates on all Variables
that are neither in "updates" nor in "no_default_updates".
:param name: an optional name for this fct. If used, the profile mode will print the time spent in this fct.
:rtype: theano.compile.Function
:returns: a callable object that will compute the outputs (given the inputs)
and update the implicit function arguments according to the `updates`.
:type name: None or string
:param name: attaches a name to the Profiling result of this function when
using ProfileMode (will be deprecated).
:type allow_input_downcast: Boolean
:param allow_input_downcast: True means that the values passed as
...
...
@@ -333,6 +335,21 @@ def pfunc(params, outputs=None, mode=None, updates=[], givens=[],
precise, type. None (default) is almost like False, but allows
downcasting of Python float scalars to floatX.
:type profile: None, True, str, or ProfileStats instance
:param profile: accumulate profiling information into a given ProfileStats
instance. None is the default, and means to use the value of
config.profile.
If argument is `True` then a new ProfileStats instance will be
used. If argument is a string, a new ProfileStats instance will be created
with that string as its `message` attribute. This profiling object will be
available via self.profile.
:rtype: theano.compile.Function
:returns: a callable object that will compute the outputs (given the inputs)
and update the implicit function arguments according to the `updates`.
:note: Regarding givens: Be careful to make sure that these substitutions are
independent--behaviour when Var1 of one pair appears in the graph leading to Var2 in
another expression is undefined. Replacements specified with givens are different from
...
...
@@ -354,6 +371,17 @@ def pfunc(params, outputs=None, mode=None, updates=[], givens=[],
# Then it clones the outputs and the update expressions. This rebuilds a computation graph
# from the inputs and the givens.
#
if
profile
is
None
:
profile
=
config
.
profile
# profile -> True or False
if
profile
==
True
:
profile
=
ProfileStats
(
message
=
name
)
# profile -> object
if
type
(
profile
)
==
str
:
profile
=
ProfileStats
(
message
=
profile
)
# profile is typically either False or an object at this point.
# No need to block other objects being passed through though. It might be
# useful.
if
not
isinstance
(
params
,(
list
,
tuple
)):
raise
Exception
(
"in pfunc() the first argument must be a list or a tuple"
)
...
...
@@ -393,7 +421,7 @@ def pfunc(params, outputs=None, mode=None, updates=[], givens=[],
inputs
.
append
(
si
)
return
orig_function
(
inputs
,
cloned_outputs
,
mode
,
accept_inplace
=
accept_inplace
,
name
=
name
)
accept_inplace
=
accept_inplace
,
name
=
name
,
profile
=
profile
)
def
_pfunc_param_to_in
(
param
,
strict
=
False
,
allow_downcast
=
None
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论