Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
65465106
提交
65465106
authored
8月 01, 2017
作者:
Reyhane Askari
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
changed sync to function
上级
50f66cc6
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
17 行增加
和
19 行删除
+17
-19
function.py
theano/compile/function.py
+2
-3
function_module.py
theano/compile/function_module.py
+10
-12
pfunc.py
theano/compile/pfunc.py
+2
-2
test_function_module.py
theano/compile/tests/test_function_module.py
+3
-2
没有找到文件。
theano/compile/function.py
浏览文件 @
65465106
...
...
@@ -76,7 +76,7 @@ def function_dump(filename, inputs, outputs=None, mode=None, updates=None,
def
function
(
inputs
,
outputs
=
None
,
mode
=
None
,
updates
=
None
,
givens
=
None
,
no_default_updates
=
False
,
accept_inplace
=
False
,
name
=
None
,
rebuild_strict
=
True
,
allow_input_downcast
=
None
,
profile
=
None
,
on_unused_input
=
None
,
sync
=
False
):
on_unused_input
=
None
):
"""
Return a :class:`callable object <theano.compile.function_module.Function>`
that will calculate `outputs` from `inputs`.
...
...
@@ -323,8 +323,7 @@ def function(inputs, outputs=None, mode=None, updates=None, givens=None,
allow_input_downcast
=
allow_input_downcast
,
on_unused_input
=
on_unused_input
,
profile
=
profile
,
output_keys
=
output_keys
,
sync
=
sync
)
output_keys
=
output_keys
)
# 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/function_module.py
浏览文件 @
65465106
...
...
@@ -1007,6 +1007,13 @@ class Function(object):
"""
return
[
i
.
variable
for
i
in
self
.
maker
.
inputs
if
i
.
implicit
]
def
sync_shared
(
self
):
for
i
,
inp
in
enumerate
(
self
.
input_storage
):
if
i
in
self
.
maker
.
fgraph
.
update_mapping
.
values
():
if
(
hasattr
(
theano
,
"gpuarray"
)
and
isinstance
(
inp
.
data
,
pygpu
.
gpuarray
.
GpuArray
)):
inp
.
data
.
sync
()
# pickling/deepcopy support for Function
def
_pickle_Function
(
f
):
...
...
@@ -1391,8 +1398,7 @@ class FunctionMaker(object):
def
__init__
(
self
,
inputs
,
outputs
,
mode
=
None
,
accept_inplace
=
False
,
function_builder
=
Function
,
profile
=
None
,
on_unused_input
=
None
,
fgraph
=
None
,
output_keys
=
None
,
sync
=
False
):
self
.
sync
=
sync
output_keys
=
None
):
mode
=
theano
.
compile
.
mode
.
get_mode
(
mode
)
# Assert old way of working isn't used
...
...
@@ -1691,13 +1697,6 @@ class FunctionMaker(object):
defaults
,
self
.
unpack_single
,
self
.
return_none
,
self
.
output_keys
,
self
)
if
self
.
sync
:
for
i
,
inp
in
enumerate
(
input_storage
):
if
i
in
self
.
fgraph
.
update_mapping
.
values
():
if
(
hasattr
(
theano
,
"gpuarray"
)
and
isinstance
(
inp
.
data
,
pygpu
.
gpuarray
.
GpuArray
)):
inp
.
data
.
sync
()
fn
.
profile
=
self
.
profile
return
fn
...
...
@@ -1743,7 +1742,7 @@ def register_checker(checker):
def
orig_function
(
inputs
,
outputs
,
mode
=
None
,
accept_inplace
=
False
,
name
=
None
,
profile
=
None
,
on_unused_input
=
None
,
output_keys
=
None
,
sync
=
False
):
output_keys
=
None
):
"""
Return a Function that will calculate the outputs from the inputs.
...
...
@@ -1814,8 +1813,7 @@ def orig_function(inputs, outputs, mode=None, accept_inplace=False,
accept_inplace
=
accept_inplace
,
profile
=
profile
,
on_unused_input
=
on_unused_input
,
output_keys
=
output_keys
,
sync
=
sync
)
output_keys
=
output_keys
)
with
theano
.
configparser
.
change_flags
(
compute_test_value
=
"off"
):
fn
=
m
.
create
(
defaults
)
finally
:
...
...
theano/compile/pfunc.py
浏览文件 @
65465106
...
...
@@ -283,7 +283,7 @@ class Param(In):
def
pfunc
(
params
,
outputs
=
None
,
mode
=
None
,
updates
=
None
,
givens
=
None
,
no_default_updates
=
False
,
accept_inplace
=
False
,
name
=
None
,
rebuild_strict
=
True
,
allow_input_downcast
=
None
,
profile
=
None
,
on_unused_input
=
None
,
output_keys
=
None
,
sync
=
False
):
profile
=
None
,
on_unused_input
=
None
,
output_keys
=
None
):
"""
Function-constructor for graphs with shared variables.
...
...
@@ -483,7 +483,7 @@ def pfunc(params, outputs=None, mode=None, updates=None, givens=None,
return
orig_function
(
inputs
,
cloned_outputs
,
mode
,
accept_inplace
=
accept_inplace
,
name
=
name
,
profile
=
profile
,
on_unused_input
=
on_unused_input
,
output_keys
=
output_keys
,
sync
=
sync
)
output_keys
=
output_keys
)
def
_pfunc_param_to_in
(
param
,
strict
=
False
,
allow_downcast
=
None
):
...
...
theano/compile/tests/test_function_module.py
浏览文件 @
65465106
...
...
@@ -919,8 +919,9 @@ def test_sync():
updates
=
[(
w
,
w
+
T
.
sum
(
T
.
dot
(
x
,
w
)
+
T
.
dot
(
5
*
x
,
2
*
w
)))]
f
=
theano
.
function
([
x
],
y
,
updates
=
updates
,
sync
=
True
)
g
=
theano
.
function
([
x
],
y
,
updates
=
updates
,
sync
=
False
)
f
=
theano
.
function
([
x
],
y
,
updates
=
updates
)
f
.
sync_shared
()
g
=
theano
.
function
([
x
],
y
,
updates
=
updates
)
x_
=
np
.
random
.
rand
(
100
,
300
)
.
astype
(
'float32'
)
f
(
x_
)
g
(
x_
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论