Commit 7167cf6d authored by Bohumír Zámečník's avatar Bohumír Zámečník Committed by Yuxin Wu

Fix some typos. (#752)

parent 3c4777ae
...@@ -122,7 +122,7 @@ def get_data(): ...@@ -122,7 +122,7 @@ def get_data():
ds = MapData(ds, lambda dp: [cv2.cvtColor(dp[0], cv2.COLOR_RGB2Lab)[:,:,0], dp[0]]) ds = MapData(ds, lambda dp: [cv2.cvtColor(dp[0], cv2.COLOR_RGB2Lab)[:,:,0], dp[0]])
ds = BatchData(ds, 32) ds = BatchData(ds, 32)
ds = PrefetchData(ds, 4) # use queue size 4 ds = PrefetchData(ds, 4) # use queue size 4
ds = PrintData(ds, num=2) # only for debug ds = PrintData(ds, num=2) # only for debug
return ds return ds
``` ```
......
...@@ -123,7 +123,7 @@ def setup_keras_trainer( ...@@ -123,7 +123,7 @@ def setup_keras_trainer(
get_model (input1, input2, ... -> keras.model.Model): get_model (input1, input2, ... -> keras.model.Model):
Takes tensors and returns a Keras model. Will be part of the tower function. Takes tensors and returns a Keras model. Will be part of the tower function.
input (InputSource): input (InputSource):
optimizer (tf.tarin.Optimizer): optimizer (tf.train.Optimizer):
loss, metrics: list of strings loss, metrics: list of strings
""" """
assert isinstance(optimizer, tf.train.Optimizer), optimizer assert isinstance(optimizer, tf.train.Optimizer), optimizer
...@@ -213,7 +213,7 @@ class KerasModel(object): ...@@ -213,7 +213,7 @@ class KerasModel(object):
if nr_gpu <= 1: if nr_gpu <= 1:
trainer = SimpleTrainer() trainer = SimpleTrainer()
else: else:
# the default multigpu trainer # the default multi-gpu trainer
trainer = SyncMultiGPUTrainerParameterServer(nr_gpu) trainer = SyncMultiGPUTrainerParameterServer(nr_gpu)
assert isinstance(trainer, Trainer), trainer assert isinstance(trainer, Trainer), trainer
assert not isinstance(trainer, DistributedTrainerBase) assert not isinstance(trainer, DistributedTrainerBase)
......
...@@ -84,7 +84,7 @@ class BatchData(ProxyDataFlow): ...@@ -84,7 +84,7 @@ class BatchData(ProxyDataFlow):
remainder (bool): When the remaining datapoints in ``ds`` is not remainder (bool): When the remaining datapoints in ``ds`` is not
enough to form a batch, whether or not to also produce the remaining enough to form a batch, whether or not to also produce the remaining
data as a smaller batch. data as a smaller batch.
If set to False, all produced datapoints are guranteed to have the same batch size. If set to False, all produced datapoints are guaranteed to have the same batch size.
If set to True, `ds.size()` must be accurate. If set to True, `ds.size()` must be accurate.
use_list (bool): if True, each component will contain a list use_list (bool): if True, each component will contain a list
of datapoints instead of an numpy array of an extra dimension. of datapoints instead of an numpy array of an extra dimension.
...@@ -706,7 +706,7 @@ class PrintData(ProxyDataFlow): ...@@ -706,7 +706,7 @@ class PrintData(ProxyDataFlow):
Args: Args:
entry: the datapoint component entry: the datapoint component
k (int): index of this compoennt in current datapoint k (int): index of this component in current datapoint
depth (int, optional): recursion depth depth (int, optional): recursion depth
max_depth, max_list: same as in :meth:`__init__`. max_depth, max_list: same as in :meth:`__init__`.
......
...@@ -191,7 +191,7 @@ class ILSVRC12(ILSVRC12Files): ...@@ -191,7 +191,7 @@ class ILSVRC12(ILSVRC12Files):
dir_structure (str): One of 'original' or 'train'. dir_structure (str): One of 'original' or 'train'.
The directory structure for the 'val' directory. The directory structure for the 'val' directory.
'original' means the original decompressed directory, which only has list of image files (as below). 'original' means the original decompressed directory, which only has list of image files (as below).
If set to 'train', it expects the same two-level directory structure simlar to 'dir/train/'. If set to 'train', it expects the same two-level directory structure similar to 'dir/train/'.
By default, it tries to automatically detect the structure. By default, it tries to automatically detect the structure.
You probably do not need to care about this option because 'original' is what people usually have. You probably do not need to care about this option because 'original' is what people usually have.
......
...@@ -84,8 +84,8 @@ def dump_dataflow_to_lmdb(df, lmdb_path, write_frequency=5000): ...@@ -84,8 +84,8 @@ def dump_dataflow_to_lmdb(df, lmdb_path, write_frequency=5000):
with get_tqdm(total=sz) as pbar: with get_tqdm(total=sz) as pbar:
idx = -1 idx = -1
# lmdb transaction is not exception-safe! # LMDB transaction is not exception-safe!
# although it has a contextmanager interface # although it has a context manager interface
txn = db.begin(write=True) txn = db.begin(write=True)
for idx, dp in enumerate(df.get_data()): for idx, dp in enumerate(df.get_data()):
txn.put(u'{}'.format(idx).encode('ascii'), dumps(dp)) txn.put(u'{}'.format(idx).encode('ascii'), dumps(dp))
......
...@@ -242,7 +242,7 @@ def CaffeLMDB(lmdb_path, shuffle=True, keys=None): ...@@ -242,7 +242,7 @@ def CaffeLMDB(lmdb_path, shuffle=True, keys=None):
class SVMLightData(RNGDataFlow): class SVMLightData(RNGDataFlow):
""" Read X,y from a svmlight file, and produce [X_i, y_i] pairs. """ """ Read X,y from an SVMlight file, and produce [X_i, y_i] pairs. """
def __init__(self, filename, shuffle=True): def __init__(self, filename, shuffle=True):
""" """
...@@ -275,9 +275,9 @@ class TFRecordData(DataFlow): ...@@ -275,9 +275,9 @@ class TFRecordData(DataFlow):
def __init__(self, path, size=None): def __init__(self, path, size=None):
""" """
Args: Args:
path (str): path to the tfrecord file path (str): path to the TFRecord file
size (int): total number of records, because this metadata is not size (int): total number of records, because this metadata is not
stored in the tfrecord file. stored in the TFRecord file.
""" """
self._path = path self._path = path
self._size = int(size) self._size = int(size)
......
...@@ -43,7 +43,7 @@ class Augmentor(object): ...@@ -43,7 +43,7 @@ class Augmentor(object):
""" """
Returns: Returns:
augmented data augmented data
augmentaion params augmentation params
""" """
return self._augment_return_params(d) return self._augment_return_params(d)
...@@ -84,7 +84,7 @@ class Augmentor(object): ...@@ -84,7 +84,7 @@ class Augmentor(object):
""" """
try: try:
argspec = inspect.getargspec(self.__init__) argspec = inspect.getargspec(self.__init__)
assert argspec.varargs is None, "The default __repr__ doesn't work for vaargs!" assert argspec.varargs is None, "The default __repr__ doesn't work for varargs!"
assert argspec.keywords is None, "The default __repr__ doesn't work for kwargs!" assert argspec.keywords is None, "The default __repr__ doesn't work for kwargs!"
fields = argspec.args[1:] fields = argspec.args[1:]
index_field_has_default = len(fields) - (0 if argspec.defaults is None else len(argspec.defaults)) index_field_has_default = len(fields) - (0 if argspec.defaults is None else len(argspec.defaults))
......
...@@ -10,13 +10,13 @@ __all__ = ['ColorSpace', 'Grayscale', 'ToUint8', 'ToFloat32'] ...@@ -10,13 +10,13 @@ __all__ = ['ColorSpace', 'Grayscale', 'ToUint8', 'ToFloat32']
class ColorSpace(ImageAugmentor): class ColorSpace(ImageAugmentor):
""" Convert into another colorspace. """ """ Convert into another color space. """
def __init__(self, mode, keepdims=True): def __init__(self, mode, keepdims=True):
""" """
Args: Args:
mode: opencv colorspace conversion code (e.g., `cv2.COLOR_BGR2HSV`) mode: OpenCV color space conversion code (e.g., `cv2.COLOR_BGR2HSV`)
keepdims (bool): keep the dimension of image unchanged if opencv keepdims (bool): keep the dimension of image unchanged if OpenCV
changes it. changes it.
""" """
self._init(locals()) self._init(locals())
......
...@@ -10,7 +10,7 @@ __all__ = ['GaussianDeform'] ...@@ -10,7 +10,7 @@ __all__ = ['GaussianDeform']
class GaussianMap(object): class GaussianMap(object):
""" Generate gaussian weighted deformation map""" """ Generate Gaussian weighted deformation map"""
# TODO really needs speedup # TODO really needs speedup
def __init__(self, image_shape, sigma=0.5): def __init__(self, image_shape, sigma=0.5):
......
...@@ -10,12 +10,12 @@ __all__ = ['JpegNoise', 'GaussianNoise', 'SaltPepperNoise'] ...@@ -10,12 +10,12 @@ __all__ = ['JpegNoise', 'GaussianNoise', 'SaltPepperNoise']
class JpegNoise(ImageAugmentor): class JpegNoise(ImageAugmentor):
""" Random Jpeg noise. """ """ Random JPEG noise. """
def __init__(self, quality_range=(40, 100)): def __init__(self, quality_range=(40, 100)):
""" """
Args: Args:
quality_range (tuple): range to sample Jpeg quality quality_range (tuple): range to sample JPEG quality
""" """
super(JpegNoise, self).__init__() super(JpegNoise, self).__init__()
self._init(locals()) self._init(locals())
...@@ -54,7 +54,7 @@ class GaussianNoise(ImageAugmentor): ...@@ -54,7 +54,7 @@ class GaussianNoise(ImageAugmentor):
class SaltPepperNoise(ImageAugmentor): class SaltPepperNoise(ImageAugmentor):
""" Salt and pepper noise. """ Salt and pepper noise.
Randomly set some elements in img to 0 or 255, regardless of its channels. Randomly set some elements in image to 0 or 255, regardless of its channels.
""" """
def __init__(self, white_prob=0.05, black_prob=0.05): def __init__(self, white_prob=0.05, black_prob=0.05):
......
...@@ -84,7 +84,7 @@ class CenterPaste(ImageAugmentor): ...@@ -84,7 +84,7 @@ class CenterPaste(ImageAugmentor):
class RandomPaste(CenterPaste): class RandomPaste(CenterPaste):
""" """
Randomly paste the image onto a background convas. Randomly paste the image onto a background canvas.
""" """
def _get_augment_params(self, img): def _get_augment_params(self, img):
......
...@@ -101,7 +101,7 @@ class _MultiProcessZMQDataFlow(DataFlow): ...@@ -101,7 +101,7 @@ class _MultiProcessZMQDataFlow(DataFlow):
return return
self._reset_done = True self._reset_done = True
# __del__ not guranteed to get called at exit # __del__ not guaranteed to get called at exit
atexit.register(del_weakref, weakref.ref(self)) atexit.register(del_weakref, weakref.ref(self))
self._reset_once() # build processes self._reset_once() # build processes
...@@ -134,7 +134,7 @@ class MultiProcessPrefetchData(ProxyDataFlow): ...@@ -134,7 +134,7 @@ class MultiProcessPrefetchData(ProxyDataFlow):
process by a Python :class:`multiprocessing.Queue`. process by a Python :class:`multiprocessing.Queue`.
Note: Note:
1. An iterator cannot run faster automatically -- what's happenning is 1. An iterator cannot run faster automatically -- what's happening is
that the underlying dataflow will be forked ``nr_proc`` times. that the underlying dataflow will be forked ``nr_proc`` times.
As a result, we have the following guarantee on the dataflow correctness: As a result, we have the following guarantee on the dataflow correctness:
...@@ -215,7 +215,7 @@ class PrefetchDataZMQ(_MultiProcessZMQDataFlow): ...@@ -215,7 +215,7 @@ class PrefetchDataZMQ(_MultiProcessZMQDataFlow):
and collect datapoints from the given dataflow in each process by ZeroMQ IPC pipe. and collect datapoints from the given dataflow in each process by ZeroMQ IPC pipe.
Note: Note:
1. An iterator cannot run faster automatically -- what's happenning is 1. An iterator cannot run faster automatically -- what's happening is
that the underlying dataflow will be forked ``nr_proc`` times. that the underlying dataflow will be forked ``nr_proc`` times.
As a result, we have the following guarantee on the dataflow correctness: As a result, we have the following guarantee on the dataflow correctness:
......
...@@ -104,7 +104,7 @@ class MultiThreadMapData(_ParallelMapData): ...@@ -104,7 +104,7 @@ class MultiThreadMapData(_ParallelMapData):
mixed with datapoints from the next pass. mixed with datapoints from the next pass.
You can use **strict mode**, where `MultiThreadMapData.get_data()` You can use **strict mode**, where `MultiThreadMapData.get_data()`
is guranteed to produce the exact set which `df.get_data()` is guaranteed to produce the exact set which `df.get_data()`
produces. Although the order of data still isn't preserved. produces. Although the order of data still isn't preserved.
""" """
class _Worker(StoppableThread): class _Worker(StoppableThread):
...@@ -212,7 +212,7 @@ class MultiProcessMapDataZMQ(_ParallelMapData, _MultiProcessZMQDataFlow): ...@@ -212,7 +212,7 @@ class MultiProcessMapDataZMQ(_ParallelMapData, _MultiProcessZMQDataFlow):
mixed with datapoints from the next pass. mixed with datapoints from the next pass.
You can use **strict mode**, where `MultiProcessMapData.get_data()` You can use **strict mode**, where `MultiProcessMapData.get_data()`
is guranteed to produce the exact set which `df.get_data()` is guaranteed to produce the exact set which `df.get_data()`
produces. Although the order of data still isn't preserved. produces. Although the order of data still isn't preserved.
""" """
class _Worker(mp.Process): class _Worker(mp.Process):
......
...@@ -119,7 +119,7 @@ class DataFromGenerator(DataFlow): ...@@ -119,7 +119,7 @@ class DataFromGenerator(DataFlow):
class DataFromIterable(DataFlow): class DataFromIterable(DataFlow):
""" Wrap an iterable of datapoitns to a DataFlow""" """ Wrap an iterable of datapoints to a DataFlow"""
def __init__(self, iterable): def __init__(self, iterable):
""" """
Args: Args:
......
...@@ -142,7 +142,7 @@ class DistributedReplicatedBuilder(DataParallelBuilder, DistributedBuilderBase): ...@@ -142,7 +142,7 @@ class DistributedReplicatedBuilder(DataParallelBuilder, DistributedBuilderBase):
It is an equivalent of ``--variable_update=distributed_replicated`` in It is an equivalent of ``--variable_update=distributed_replicated`` in
`tensorflow/benchmarks <https://github.com/tensorflow/benchmarks>`_. `tensorflow/benchmarks <https://github.com/tensorflow/benchmarks>`_.
Note that the performance of this trianer is still not satisfactory. Note that the performance of this trainer is still not satisfactory.
Check `ResNet-Horovod <https://github.com/tensorpack/benchmarks/tree/master/ResNet-Horovod>`_ Check `ResNet-Horovod <https://github.com/tensorpack/benchmarks/tree/master/ResNet-Horovod>`_
for fast and correct distributed examples. for fast and correct distributed examples.
......
...@@ -111,7 +111,7 @@ class SyncMultiGPUParameterServerBuilder(DataParallelBuilder): ...@@ -111,7 +111,7 @@ class SyncMultiGPUParameterServerBuilder(DataParallelBuilder):
""" """
Data-parallel training in 'ParameterServer' mode. Data-parallel training in 'ParameterServer' mode.
It builds one tower on each GPU with It builds one tower on each GPU with
shared variable scope. It synchronoizes the gradients computed shared variable scope. It synchronizes the gradients computed
from each tower, averages them and applies to the shared variables. from each tower, averages them and applies to the shared variables.
It is an equivalent of ``--variable_update=parameter_server`` in It is an equivalent of ``--variable_update=parameter_server`` in
...@@ -178,7 +178,7 @@ class SyncMultiGPUReplicatedBuilder(DataParallelBuilder): ...@@ -178,7 +178,7 @@ class SyncMultiGPUReplicatedBuilder(DataParallelBuilder):
Attribute: Attribute:
grads: #GPU number of lists of (g, v). Synchronized gradients on each device, available after build() grads: #GPU number of lists of (g, v). Synchronized gradients on each device, available after build()
Though on different deviecs, they should contain the same value. Though on different devices, they should contain the same value.
""" """
def __init__(self, towers, average, mode): def __init__(self, towers, average, mode):
......
...@@ -351,7 +351,7 @@ class DummyConstantInput(TensorInput): ...@@ -351,7 +351,7 @@ class DummyConstantInput(TensorInput):
def __init__(self, shapes): def __init__(self, shapes):
""" """
Args: Args:
shapes (list[list]): a list of fully-sepcified shapes. shapes (list[list]): a list of fully-specified shapes.
""" """
self.shapes = shapes self.shapes = shapes
logger.warn("Using dummy input for debug!") logger.warn("Using dummy input for debug!")
...@@ -372,7 +372,7 @@ class DummyConstantInput(TensorInput): ...@@ -372,7 +372,7 @@ class DummyConstantInput(TensorInput):
class ZMQInput(TensorInput): class ZMQInput(TensorInput):
""" """
Recv tensors from a ZMQ endpoint, with ops from https://github.com/tensorpack/zmq_ops. Receive tensors from a ZMQ endpoint, with ops from https://github.com/tensorpack/zmq_ops.
It works with :meth:`dataflow.remote.send_dataflow_zmq(format='zmq_op')`. It works with :meth:`dataflow.remote.send_dataflow_zmq(format='zmq_op')`.
""" """
def __init__(self, end_point, hwm, bind=True): def __init__(self, end_point, hwm, bind=True):
......
...@@ -134,7 +134,7 @@ _EXECUTE_HISTORY = set() ...@@ -134,7 +134,7 @@ _EXECUTE_HISTORY = set()
def execute_only_once(): def execute_only_once():
""" """
Each called in the code to this function is guranteed to return True the Each called in the code to this function is guaranteed to return True the
first time and False afterwards. first time and False afterwards.
Returns: Returns:
......
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