Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
c7add2a3
提交
c7add2a3
authored
5月 22, 2015
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Flake8 for compile/sharedvalue.py
上级
d5ff2b48
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
23 行增加
和
20 行删除
+23
-20
sharedvalue.py
theano/compile/sharedvalue.py
+23
-19
test_flake8.py
theano/tests/test_flake8.py
+0
-1
没有找到文件。
theano/compile/sharedvalue.py
浏览文件 @
c7add2a3
...
@@ -49,7 +49,8 @@ class SharedVariable(Variable):
...
@@ -49,7 +49,8 @@ class SharedVariable(Variable):
or copied, so they must have the correct type.
or copied, so they must have the correct type.
:param allow_downcast: Only applies if `strict` is False.
:param allow_downcast: Only applies if `strict` is False.
True -> allow assigned value to lose precision when cast during assignment.
True -> allow assigned value to lose precision when cast
during assignment.
False -> never allow precision loss.
False -> never allow precision loss.
None -> only allow downcasting of a Python float to a scalar floatX.
None -> only allow downcasting of a Python float to a scalar floatX.
...
@@ -65,17 +66,18 @@ class SharedVariable(Variable):
...
@@ -65,17 +66,18 @@ class SharedVariable(Variable):
if
container
is
not
None
:
if
container
is
not
None
:
self
.
container
=
container
self
.
container
=
container
if
(
value
is
not
None
)
or
(
strict
is
not
None
):
if
(
value
is
not
None
)
or
(
strict
is
not
None
):
raise
TypeError
(
raise
TypeError
(
'value and strict are ignored if you pass '
'value and strict are ignored if you pass
a container here'
)
'
a container here'
)
else
:
else
:
if
container
is
not
None
:
if
container
is
not
None
:
raise
TypeError
(
'Error to specify both value and container'
)
raise
TypeError
(
'Error to specify both value and container'
)
self
.
container
=
Container
(
self
,
self
.
container
=
Container
(
storage
=
[
type
.
filter
(
value
,
strict
=
strict
,
self
,
allow_downcast
=
allow_downcast
)],
storage
=
[
type
.
filter
(
value
,
strict
=
strict
,
readonly
=
False
,
allow_downcast
=
allow_downcast
)],
strict
=
strict
,
readonly
=
False
,
allow_downcast
=
allow_downcast
)
strict
=
strict
,
allow_downcast
=
allow_downcast
)
def
get_value
(
self
,
borrow
=
False
,
return_internal_type
=
False
):
def
get_value
(
self
,
borrow
=
False
,
return_internal_type
=
False
):
"""Get the non-symbolic value associated with this SharedVariable.
"""Get the non-symbolic value associated with this SharedVariable.
...
@@ -114,11 +116,11 @@ class SharedVariable(Variable):
...
@@ -114,11 +116,11 @@ class SharedVariable(Variable):
def
clone
(
self
):
def
clone
(
self
):
cp
=
self
.
__class__
(
cp
=
self
.
__class__
(
name
=
self
.
name
,
name
=
self
.
name
,
type
=
self
.
type
,
type
=
self
.
type
,
value
=
None
,
value
=
None
,
strict
=
None
,
strict
=
None
,
container
=
self
.
container
)
container
=
self
.
container
)
cp
.
tag
=
copy
.
copy
(
self
.
tag
)
cp
.
tag
=
copy
.
copy
(
self
.
tag
)
return
cp
return
cp
...
@@ -140,8 +142,8 @@ class SharedVariable(Variable):
...
@@ -140,8 +142,8 @@ class SharedVariable(Variable):
type
(
value
))
type
(
value
))
raise
TypeError
(
raise
TypeError
(
"The generic 'SharedVariable' object is not subscriptable. "
"The generic 'SharedVariable' object is not subscriptable. "
"This shared variable contains
%
s"
%
msg
)
"This shared variable contains
%
s"
%
msg
)
def
_value_get
(
self
):
def
_value_get
(
self
):
raise
Exception
(
"sharedvar.value does not exist anymore. Use "
raise
Exception
(
"sharedvar.value does not exist anymore. Use "
...
@@ -183,7 +185,8 @@ def shared(value, name=None, strict=False, allow_downcast=None, **kwargs):
...
@@ -183,7 +185,8 @@ def shared(value, name=None, strict=False, allow_downcast=None, **kwargs):
potential constructors to those that can accept those kwargs.
potential constructors to those that can accept those kwargs.
:note: Some shared variable have ``borrow`` as extra kwargs.
:note: Some shared variable have ``borrow`` as extra kwargs.
`See <http://deeplearning.net/software/theano/tutorial/aliasing.html#borrowing-when-creating-shared-variables>`_ for detail.
`See <http://deeplearning.net/software/theano/tutorial/aliasing.
\
html#borrowing-when-creating-shared-variables>`_ for detail.
:note: Some shared variable have ``broadcastable`` as extra kwargs.
:note: Some shared variable have ``broadcastable`` as extra kwargs.
As shared variable shapes can change, all dimensions default
As shared variable shapes can change, all dimensions default
...
@@ -200,7 +203,8 @@ def shared(value, name=None, strict=False, allow_downcast=None, **kwargs):
...
@@ -200,7 +203,8 @@ def shared(value, name=None, strict=False, allow_downcast=None, **kwargs):
try
:
try
:
if
isinstance
(
value
,
Variable
):
if
isinstance
(
value
,
Variable
):
raise
TypeError
(
" Shared variable constructor needs numeric values and not symbolic variables."
)
raise
TypeError
(
"Shared variable constructor needs numeric "
"values and not symbolic variables."
)
for
ctor
in
reversed
(
shared
.
constructors
):
for
ctor
in
reversed
(
shared
.
constructors
):
try
:
try
:
...
@@ -234,4 +238,4 @@ shared.constructors = []
...
@@ -234,4 +238,4 @@ shared.constructors = []
def
generic_constructor
(
value
,
name
=
None
,
strict
=
False
,
allow_downcast
=
None
):
def
generic_constructor
(
value
,
name
=
None
,
strict
=
False
,
allow_downcast
=
None
):
"""SharedVariable Constructor"""
"""SharedVariable Constructor"""
return
SharedVariable
(
type
=
generic
,
value
=
value
,
name
=
name
,
strict
=
strict
,
return
SharedVariable
(
type
=
generic
,
value
=
value
,
name
=
name
,
strict
=
strict
,
allow_downcast
=
allow_downcast
)
allow_downcast
=
allow_downcast
)
theano/tests/test_flake8.py
浏览文件 @
c7add2a3
...
@@ -41,7 +41,6 @@ whitelist_flake8 = [
...
@@ -41,7 +41,6 @@ whitelist_flake8 = [
"compile/__init__.py"
,
"compile/__init__.py"
,
"compile/profiling.py"
,
"compile/profiling.py"
,
"compile/function_module.py"
,
"compile/function_module.py"
,
"compile/sharedvalue.py"
,
"compile/monitormode.py"
,
"compile/monitormode.py"
,
"compile/io.py"
,
"compile/io.py"
,
"compile/tests/test_builders.py"
,
"compile/tests/test_builders.py"
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论