Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
b6c9f91d
提交
b6c9f91d
authored
7月 15, 2010
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add a parameter to thaeno flags to don't allow changing them after theano import.
上级
92ed9f15
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
21 行增加
和
13 行删除
+21
-13
configparser.py
theano/configparser.py
+21
-13
没有找到文件。
theano/configparser.py
浏览文件 @
b6c9f91d
...
...
@@ -163,9 +163,14 @@ def AddConfigVar(name, doc, configparam, root=config):
_config_var_list
.
append
(
configparam
)
class
ConfigParam
(
object
):
def
__init__
(
self
,
default
,
filter
=
None
):
def
__init__
(
self
,
default
,
filter
=
None
,
allow_override
=
True
):
"
If allow_override is False, we can't change the value after the import of Theano.
So the value should be the same during all the execution
"
self
.
default
=
default
self
.
filter
=
filter
self
.
allow_override
=
allow_override
# N.B. --
# self.fullname # set by AddConfigVar
# self.doc # set by AddConfigVar
...
...
@@ -182,6 +187,8 @@ class ConfigParam(object):
return
self
.
val
def
__set__
(
self
,
cls
,
val
):
if
not
self
.
allow_override
and
hasattr
(
self
,
'val'
):
raise
Exception
(
"Can't change the value of this config parameter after initialization!"
)
#print "SETTING PARAM", self.fullname,(cls), val
if
self
.
filter
:
self
.
val
=
self
.
filter
(
val
)
...
...
@@ -191,7 +198,7 @@ class ConfigParam(object):
deleter
=
None
class
EnumStr
(
ConfigParam
):
def
__init__
(
self
,
default
,
*
options
):
def
__init__
(
self
,
default
,
*
options
,
**
kwargs
):
self
.
default
=
default
self
.
all
=
(
default
,)
+
options
def
filter
(
val
):
...
...
@@ -200,13 +207,14 @@ class EnumStr(ConfigParam):
else
:
raise
ValueError
(
'Invalid value (
%
s) for configuration variable "
%
s". Legal options are
%
s'
%
(
val
,
self
.
fullname
,
self
.
all
),
val
)
super
(
EnumStr
,
self
)
.
__init__
(
default
,
filter
)
over
=
kwargs
.
get
(
"allow_override"
,
True
)
super
(
EnumStr
,
self
)
.
__init__
(
default
,
filter
,
over
)
def
__str__
(
self
):
return
'
%
s (
%
s) '
%
(
self
.
fullname
,
self
.
all
)
class
TypedParam
(
ConfigParam
):
def
__init__
(
self
,
default
,
mytype
,
is_valid
=
None
):
def
__init__
(
self
,
default
,
mytype
,
is_valid
=
None
,
allow_override
=
True
):
self
.
mytype
=
mytype
def
filter
(
val
):
casted_val
=
mytype
(
val
)
...
...
@@ -217,17 +225,17 @@ class TypedParam(ConfigParam):
raise
ValueError
(
'Invalid value (
%
s) for configuration variable "
%
s".'
%
(
val
,
self
.
fullname
),
val
)
return
casted_val
super
(
TypedParam
,
self
)
.
__init__
(
default
,
filter
)
super
(
TypedParam
,
self
)
.
__init__
(
default
,
filter
,
allow_override
=
allow_override
)
def
__str__
(
self
):
return
'
%
s (
%
s) '
%
(
self
.
fullname
,
self
.
mytype
)
def
StrParam
(
default
,
is_valid
=
None
):
return
TypedParam
(
default
,
str
,
is_valid
)
def
IntParam
(
default
,
is_valid
=
None
):
return
TypedParam
(
default
,
int
,
is_valid
)
def
FloatParam
(
default
,
is_valid
=
None
):
return
TypedParam
(
default
,
float
,
is_valid
)
def
BoolParam
(
default
,
is_valid
=
None
):
def
StrParam
(
default
,
is_valid
=
None
,
allow_override
=
True
):
return
TypedParam
(
default
,
str
,
is_valid
,
allow_override
=
allow_override
)
def
IntParam
(
default
,
is_valid
=
None
,
allow_override
=
True
):
return
TypedParam
(
default
,
int
,
is_valid
,
allow_override
=
allow_override
)
def
FloatParam
(
default
,
is_valid
=
None
,
allow_override
=
True
):
return
TypedParam
(
default
,
float
,
is_valid
,
allow_override
=
allow_override
)
def
BoolParam
(
default
,
is_valid
=
None
,
allow_override
=
True
):
#see comment at the beggining of this file.
def
booltype
(
s
):
if
s
in
[
'False'
,
'false'
,
'0'
,
False
]:
...
...
@@ -242,4 +250,4 @@ def BoolParam(default, is_valid=None):
return
False
if
is_valid
is
None
:
is_valid
=
is_valid_bool
return
TypedParam
(
default
,
booltype
,
is_valid
)
return
TypedParam
(
default
,
booltype
,
is_valid
,
allow_override
=
allow_override
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论