Commit e63d8b7e authored by Yuxin Wu's avatar Yuxin Wu

update docs

parent 34e8d817
...@@ -15,7 +15,8 @@ The Tensorpack API brings speed and flexibility together. ...@@ -15,7 +15,8 @@ The Tensorpack API brings speed and flexibility together.
Is TensorFlow Slow? Is TensorFlow Slow?
~~~~~~~~~~~~~~~~~~~~~ *******************
There is a common misconception, There is a common misconception,
but no, it's not slow. But it's not easy to write it in an efficient way. but no, it's not slow. But it's not easy to write it in an efficient way.
......
...@@ -55,7 +55,7 @@ The tower function needs to follow some rules: ...@@ -55,7 +55,7 @@ The tower function needs to follow some rules:
Tensorpack layers create variables based on the name given to the layer: Tensorpack layers create variables based on the name given to the layer:
e.g., `Conv2D('test', x)` will open a variable scope named "test". e.g., `Conv2D('test', x)` will open a variable scope named "test".
In order to respect the above rules, In order to respect the above rules,
the name of the layer must not depend on name_scope's name or any tensor's name. the name of the layer must not depend on name_scope's name or any tensor's name.
4. It must __respect variable scope reuse__: 4. It must __respect variable scope reuse__:
* The creation of any trainable variables must __respect reuse__ variable scope. * The creation of any trainable variables must __respect reuse__ variable scope.
......
...@@ -69,17 +69,30 @@ def humanize_time_delta(sec): ...@@ -69,17 +69,30 @@ def humanize_time_delta(sec):
def change_env(name, val): def change_env(name, val):
""" """
Args: Args:
name(str), val(str): name(str): name of the env var
val(str or None): the value, or set to None to clear the env var.
Returns: Returns:
a context where the environment variable ``name`` being set to a context where the environment variable ``name`` being set to
``val``. It will be set back after the context exits. ``val``. It will be set back after the context exits.
""" """
oldval = os.environ.get(name, None) oldval = os.environ.get(name, None)
os.environ[name] = val
if val is None:
try:
del os.environ[name]
except KeyError:
pass
else:
os.environ[name] = val
yield yield
if oldval is None: if oldval is None:
del os.environ[name] try:
del os.environ[name]
except KeyError:
pass
else: else:
os.environ[name] = oldval os.environ[name] = oldval
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment