提交 b5c4a92f authored 作者: James Bergstra's avatar James Bergstra

slight clean up of get_theano_flag

上级 d847f13d
...@@ -371,19 +371,23 @@ def type_guard(type1): ...@@ -371,19 +371,23 @@ def type_guard(type1):
def get_theano_flag(key, default=None): def get_theano_flag(key, default=None):
""" """Return the value for a key passed via the THEANO_FLAGS environment variable.
This function parse the environement variable THEANO_FLAGS.
:type key: a string
:param key: the key to lookup
:type default: any
:param default: the value to be returned if the key is not present. (Default: None)
if the variable don't exist return None if the variable don't exist return `default`
if the key is not in the variable return None if the key is not in the variable return `default`
if the key is in the variable but without a value return True if the key is in the variable but without a value return True
if the key is in the variable with a value return the value if the key is in the variable with a value return the value
if the key appear many times, we return the last value if the key appears many times, we return the last value
the THEANO_FLAGS environement variable is a list of key[=value] that is separated by comma. The THEANO_FLAGS environement variable should be a list of comma-separated key[=value] entries.
""" """
f=os.getenv("THEANO_FLAGS") f=os.getenv("THEANO_FLAGS", "")
ret = default ret = default
key2=key+"=" key2=key+"="
for fl in f.split(','): for fl in f.split(','):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论