Commit 193f6056 authored by Yuxin Wu's avatar Yuxin Wu

update docs; bump version

parent 65c0b326
...@@ -20,6 +20,6 @@ __PLEASE ALWAYS INCLUDE__: ...@@ -20,6 +20,6 @@ __PLEASE ALWAYS INCLUDE__:
+ TF version: `python -c 'import tensorflow as tf; print(tf.GIT_VERSION, tf.VERSION)'`. + TF version: `python -c 'import tensorflow as tf; print(tf.GIT_VERSION, tf.VERSION)'`.
+ Tensorpack version: `python -c 'import tensorpack; print(tensorpack.__version__)'`. + Tensorpack version: `python -c 'import tensorpack; print(tensorpack.__version__)'`.
You can install Tensorpack master by `pip install -U git+https://github.com/ppwwyyxx/tensorpack.git`.: You can install Tensorpack master by `pip install -U git+https://github.com/ppwwyyxx/tensorpack.git`.:
+ Hardware information, if relevant. + Hardware information, e.g. number of GPUs used.
About efficiency issues, PLEASE first read http://tensorpack.readthedocs.io/en/latest/tutorial/performance-tuning.html About efficiency issues, PLEASE first read http://tensorpack.readthedocs.io/en/latest/tutorial/performance-tuning.html
...@@ -4,6 +4,9 @@ about: More general questions about Tensorpack. ...@@ -4,6 +4,9 @@ about: More general questions about Tensorpack.
--- ---
+ If you did something specific and it failed, please use the "Unexpected Problems /
Bugs" category.
+ Your question is probably answered in [tutorials](http://tensorpack.readthedocs.io/en/latest/tutorial/index.html#user-tutorials). Read it first. + Your question is probably answered in [tutorials](http://tensorpack.readthedocs.io/en/latest/tutorial/index.html#user-tutorials). Read it first.
+ We answer "HOW to do X with Tensorpack" for a well-defined X. + We answer "HOW to do X with Tensorpack" for a well-defined X.
......
tensorpack.callbacks package tensorpack.callbacks package
============================ ============================
__Everything__ other than the training iterations happen in the callbacks. **Everything** other than the training iterations happen in the callbacks.
Most of the fancy things you want to do will probably end up here. Most of the fancy things you want to do will probably end up here.
See relevant tutorials: :doc:`../tutorial/callback`. See relevant tutorials: :doc:`../tutorial/callback`.
......
...@@ -52,7 +52,7 @@ tensorpack.utils.serialize module ...@@ -52,7 +52,7 @@ tensorpack.utils.serialize module
:show-inheritance: :show-inheritance:
tensorpack.utils.compatible_serialize module tensorpack.utils.compatible_serialize module
--------------------------------- --------------------------------------------
.. automodule:: tensorpack.utils.compatible_serialize .. automodule:: tensorpack.utils.compatible_serialize
:members: :members:
......
...@@ -126,3 +126,8 @@ You can overwrite any of the following methods to define a new callback: ...@@ -126,3 +126,8 @@ You can overwrite any of the following methods to define a new callback:
or [EnableCallbackIf](../../modules/callbacks.html#tensorpack.callbacks.EnableCallbackIf). or [EnableCallbackIf](../../modules/callbacks.html#tensorpack.callbacks.EnableCallbackIf).
Of course you also have the freedom to implement "what to do" and "when to do" altogether. Of course you also have the freedom to implement "what to do" and "when to do" altogether.
### Examples
Check source code of the [existing tensorpack callbacks](../../modules/callbacks.html).
Or grep 'Callback' in tensorpack examples for those implemented as extensions.
...@@ -22,6 +22,11 @@ class AttrDict(): ...@@ -22,6 +22,11 @@ class AttrDict():
setattr(self, name, ret) setattr(self, name, ret)
return ret return ret
def __setattr__(self, name, value):
if self._freezed and name not in self.__dict__:
raise AttributeError("Cannot create new attribute!")
super().__setattr__(name, value)
def __str__(self): def __str__(self):
return pprint.pformat(self.to_dict(), indent=1) return pprint.pformat(self.to_dict(), indent=1)
...@@ -51,6 +56,9 @@ class AttrDict(): ...@@ -51,6 +56,9 @@ class AttrDict():
def freeze(self): def freeze(self):
self._freezed = True self._freezed = True
for v in self.__dict__.values():
if isinstance(v, AttrDict):
v.freeze()
# avoid silent bugs # avoid silent bugs
def __eq__(self, _): def __eq__(self, _):
...@@ -229,6 +237,7 @@ def finalize_configs(is_training): ...@@ -229,6 +237,7 @@ def finalize_configs(is_training):
else: else:
assert 'OMPI_COMM_WORLD_SIZE' not in os.environ assert 'OMPI_COMM_WORLD_SIZE' not in os.environ
ngpu = get_num_gpu() ngpu = get_num_gpu()
assert ngpu > 0, "Has to run with GPU!"
assert ngpu % 8 == 0 or 8 % ngpu == 0, ngpu assert ngpu % 8 == 0 or 8 % ngpu == 0, ngpu
if _C.TRAIN.NUM_GPUS is None: if _C.TRAIN.NUM_GPUS is None:
_C.TRAIN.NUM_GPUS = ngpu _C.TRAIN.NUM_GPUS = ngpu
......
...@@ -117,7 +117,7 @@ class ScalarStats(Inferencer): ...@@ -117,7 +117,7 @@ class ScalarStats(Inferencer):
class ClassificationError(Inferencer): class ClassificationError(Inferencer):
""" """
Compute __true__ classification error in batch mode, from a ``wrong`` tensor. Compute **true** classification error in batch mode, from a ``wrong`` tensor.
The ``wrong`` tensor is supposed to be an binary vector containing The ``wrong`` tensor is supposed to be an binary vector containing
whether each sample in the batch is *incorrectly* classified. whether each sample in the batch is *incorrectly* classified.
......
...@@ -42,7 +42,7 @@ class InjectShell(Callback): ...@@ -42,7 +42,7 @@ class InjectShell(Callback):
Example: Example:
.. code-block:: python .. code-block:: none
callbacks=[InjectShell('/path/to/pause-training.tmp'), ...] callbacks=[InjectShell('/path/to/pause-training.tmp'), ...]
......
...@@ -16,6 +16,7 @@ import re ...@@ -16,6 +16,7 @@ import re
import tensorflow as tf import tensorflow as tf
from ..utils import logger from ..utils import logger
from ..tfutils.summary import create_scalar_summary, create_image_summary from ..tfutils.summary import create_scalar_summary, create_image_summary
from ..utils.develop import HIDE_DOC
from .base import Callback from .base import Callback
__all__ = ['TrainingMonitor', 'Monitors', __all__ = ['TrainingMonitor', 'Monitors',
...@@ -242,9 +243,11 @@ class TFEventWriter(TrainingMonitor): ...@@ -242,9 +243,11 @@ class TFEventWriter(TrainingMonitor):
self._logdir, graph=tf.get_default_graph(), self._logdir, graph=tf.get_default_graph(),
max_queue=self._max_queue, flush_secs=self._flush_secs) max_queue=self._max_queue, flush_secs=self._flush_secs)
@HIDE_DOC
def process_summary(self, summary): def process_summary(self, summary):
self._writer.add_summary(summary, self.global_step) self._writer.add_summary(summary, self.global_step)
@HIDE_DOC
def process_event(self, evt): def process_event(self, evt):
self._writer.add_event(evt) self._writer.add_event(evt)
...@@ -345,6 +348,7 @@ class JSONWriter(TrainingMonitor): ...@@ -345,6 +348,7 @@ class JSONWriter(TrainingMonitor):
def _trigger_epoch(self): def _trigger_epoch(self):
self._trigger() self._trigger()
@HIDE_DOC
def process_scalar(self, name, val): def process_scalar(self, name, val):
self._stat_now[name] = val self._stat_now[name] = val
...@@ -417,6 +421,7 @@ class ScalarPrinter(TrainingMonitor): ...@@ -417,6 +421,7 @@ class ScalarPrinter(TrainingMonitor):
if self._enable_epoch: if self._enable_epoch:
self._trigger() self._trigger()
@HIDE_DOC
def process_scalar(self, name, val): def process_scalar(self, name, val):
self._dic[name] = float(val) self._dic[name] = float(val)
...@@ -444,6 +449,7 @@ class ScalarHistory(TrainingMonitor): ...@@ -444,6 +449,7 @@ class ScalarHistory(TrainingMonitor):
def __init__(self): def __init__(self):
self._dic = defaultdict(list) self._dic = defaultdict(list)
@HIDE_DOC
def process_scalar(self, name, val): def process_scalar(self, name, val):
self._dic[name].append(float(val)) self._dic[name].append(float(val))
...@@ -488,6 +494,7 @@ class SendMonitorData(TrainingMonitor): ...@@ -488,6 +494,7 @@ class SendMonitorData(TrainingMonitor):
self.names = names self.names = names
self.dic = {} self.dic = {}
@HIDE_DOC
def process_scalar(self, name, val): def process_scalar(self, name, val):
if name in self.names: if name in self.names:
self.dic[name] = val self.dic[name] = val
......
...@@ -114,9 +114,6 @@ def MergeAllSummaries(period=0, run_alone=False, key=tf.GraphKeys.SUMMARIES): ...@@ -114,9 +114,6 @@ def MergeAllSummaries(period=0, run_alone=False, key=tf.GraphKeys.SUMMARIES):
depend on inputs. depend on inputs.
key (str): the collection of summary tensors. Same as in `tf.summary.merge_all`. key (str): the collection of summary tensors. Same as in `tf.summary.merge_all`.
Default is ``tf.GraphKeys.SUMMARIES`` Default is ``tf.GraphKeys.SUMMARIES``
Returns:
a Callback.
""" """
period = int(period) period = int(period)
if run_alone: if run_alone:
......
...@@ -623,7 +623,9 @@ class StagingInput(FeedfreeInput): ...@@ -623,7 +623,9 @@ class StagingInput(FeedfreeInput):
# TODO tensorflow/benchmarks use static shapes here, # TODO tensorflow/benchmarks use static shapes here,
# though it doesn't seem to help. We can use it when it's known. # though it doesn't seem to help. We can use it when it's known.
stage = StagingArea(dtypes, shapes=None) # Setting capacity to 1 to potentially save some memory, because we should
# expect the consumers to run slower than the producer.
stage = StagingArea(dtypes, shapes=None, capacity=1)
# put & get automatically inherit the name scope from the area # put & get automatically inherit the name scope from the area
self._stage_ops.append(stage.put(inputs)) self._stage_ops.append(stage.put(inputs))
......
...@@ -54,4 +54,4 @@ except ImportError: ...@@ -54,4 +54,4 @@ except ImportError:
# This line has to be the last line of the file. # This line has to be the last line of the file.
# setup.py will use it to determine the version # setup.py will use it to determine the version
__version__ = '0.8.8' __version__ = '0.8.9'
...@@ -9,6 +9,8 @@ from ..utils.argtools import get_data_format ...@@ -9,6 +9,8 @@ from ..utils.argtools import get_data_format
from ..tfutils.common import get_tf_version_tuple from ..tfutils.common import get_tf_version_tuple
from ..tfutils.varreplace import custom_getter_scope from ..tfutils.varreplace import custom_getter_scope
__all__ = []
def map_common_tfargs(kwargs): def map_common_tfargs(kwargs):
df = kwargs.pop('data_format', None) df = kwargs.pop('data_format', None)
......
...@@ -34,7 +34,7 @@ class NewSessionCreator(tf.train.ChiefSessionCreator): ...@@ -34,7 +34,7 @@ class NewSessionCreator(tf.train.ChiefSessionCreator):
else: else:
self.user_provided_config = True self.user_provided_config = True
logger.warn( logger.warn(
"Some options in custom session config may not work due to TF \ "User-provided custom session config may not work due to TF \
bugs. See https://github.com/tensorpack/tensorpack/issues/497 for workarounds.") bugs. See https://github.com/tensorpack/tensorpack/issues/497 for workarounds.")
self.config = config self.config = config
......
...@@ -251,15 +251,15 @@ def subproc_call(cmd, timeout=None): ...@@ -251,15 +251,15 @@ def subproc_call(cmd, timeout=None):
shell=True, timeout=timeout) shell=True, timeout=timeout)
return output, 0 return output, 0
except subprocess.TimeoutExpired as e: except subprocess.TimeoutExpired as e:
logger.warn("Command timeout!") logger.warn("Command '{}' timeout!".format(cmd))
logger.warn(e.output.decode('utf-8')) logger.warn(e.output.decode('utf-8'))
return e.output, -1 return e.output, -1
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
logger.warn("Command failed: {}".format(e.returncode)) logger.warn("Command '{}' failed, return code={}".format(cmd, e.returncode))
logger.warn(e.output.decode('utf-8')) logger.warn(e.output.decode('utf-8'))
return e.output, e.returncode return e.output, e.returncode
except Exception: except Exception:
logger.warn("Command failed to run: {}".format(cmd)) logger.warn("Command '{}' failed to run.".format(cmd))
return "", -2 return "", -2
......
...@@ -15,6 +15,8 @@ import six ...@@ -15,6 +15,8 @@ import six
from . import logger from . import logger
__all__ = []
def create_dummy_class(klass, dependency): def create_dummy_class(klass, dependency):
""" """
......
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