Commit a9958037 authored by Patrick Wieschollek's avatar Patrick Wieschollek Committed by Yuxin Wu

remove some typos from the documentation (#155)

* remove some typos from the documentation

* add missing updates

* revert datapoint spelling

* renaming variable

`grep -rn . -e "max_pertub_pixel" --include=*.py` shows no
dependencies in examples.
parent 35833026
...@@ -33,7 +33,7 @@ A more complicated example is the [ResNet training script](../examples/ResNet/im ...@@ -33,7 +33,7 @@ A more complicated example is the [ResNet training script](../examples/ResNet/im
with all the data preprocessing. with all the data preprocessing.
All these modules are written in Python, All these modules are written in Python,
so you can easily implement whatever opeartions/transformations you need, so you can easily implement whatever operations/transformations you need,
without worrying about adding operators to TensorFlow. without worrying about adding operators to TensorFlow.
In the mean time, thanks to the prefetching, it can still run fast enough for In the mean time, thanks to the prefetching, it can still run fast enough for
tasks as large as ImageNet training. tasks as large as ImageNet training.
...@@ -71,7 +71,7 @@ Optionally, Dataflow can implement the following two methods: ...@@ -71,7 +71,7 @@ Optionally, Dataflow can implement the following two methods:
+ `size()`. Return the number of elements the generator can produce. Certain modules might require this. + `size()`. Return the number of elements the generator can produce. Certain modules might require this.
For example, only Dataflows with the same number of elements can be joined together. For example, only Dataflows with the same number of elements can be joined together.
+ `reset_state()`. It's guranteed that the process which uses this DataFlow will invoke this method before using it. + `reset_state()`. It's guaranteed that the process which uses this DataFlow will invoke this method before using it.
So if this DataFlow needs to something after a `fork()`, you should put it here. So if this DataFlow needs to something after a `fork()`, you should put it here.
A typical situation is when your Dataflow uses random number generator (RNG). Then you'd need to reset the RNG here, A typical situation is when your Dataflow uses random number generator (RNG). Then you'd need to reset the RNG here,
......
...@@ -12,7 +12,7 @@ The original images (JPEG compressed) are 140G in total. ...@@ -12,7 +12,7 @@ The original images (JPEG compressed) are 140G in total.
The average resolution is about 400x350 <sup>[[1]]</sup>. The average resolution is about 400x350 <sup>[[1]]</sup>.
Following the [ResNet example](../examples/ResNet), we need images in their original resolution, Following the [ResNet example](../examples/ResNet), we need images in their original resolution,
so we'll read the original dataset instead of a down-sampled version. so we'll read the original dataset instead of a down-sampled version.
We'll need to reach a speed of, roughly 1k images per second, to keep GPUs busy. We'll need to reach a speed of, roughly 1000 images per second, to keep GPUs busy.
Note that the actual performance would depend on not only the disk, but also Note that the actual performance would depend on not only the disk, but also
memory (for caching) and CPU (for data processing). memory (for caching) and CPU (for data processing).
...@@ -158,7 +158,7 @@ Then we add necessary transformations: ...@@ -158,7 +158,7 @@ Then we add necessary transformations:
ds = BatchData(ds, 256) ds = BatchData(ds, 256)
``` ```
1. `LMDBData` deserialize the datapoints (from string to [jpeg_string, label]) 1. `LMDBData` deserialize the datapoints (from string to [jpeg_string, label])
2. Use opencv to decode the first component into ndarray 2. Use OpenCV to decode the first component into ndarray
3. Apply augmentations to the ndarray 3. Apply augmentations to the ndarray
Both imdecode and the augmentors can be quite slow. We can parallelize them like this: Both imdecode and the augmentors can be quite slow. We can parallelize them like this:
......
...@@ -158,7 +158,7 @@ class Triggerable(Callback): ...@@ -158,7 +158,7 @@ class Triggerable(Callback):
If an triggerable is used as a callback directly (instead of under other If an triggerable is used as a callback directly (instead of under other
higher-level wrapper to control the trigger), it will by default trigger after higher-level wrapper to control the trigger), it will by default trigger after
every epoch. This is mainly for backward-compatibilty and convenience. every epoch. This is mainly for backward-compatibility and convenience.
.. document private functions .. document private functions
.. automethod:: _trigger .. automethod:: _trigger
......
...@@ -56,7 +56,7 @@ class Inferencer(object): ...@@ -56,7 +56,7 @@ class Inferencer(object):
def get_output_tensors(self): def get_output_tensors(self):
""" """
Return a list of tensor names (guranteed not op name) this inferencer needs. Return a list of tensor names (guaranteed not op name) this inferencer needs.
""" """
ret = self._get_output_tensors() ret = self._get_output_tensors()
return [get_op_tensor_name(n)[1] for n in ret] return [get_op_tensor_name(n)[1] for n in ret]
...@@ -145,7 +145,7 @@ class ClassificationError(Inferencer): ...@@ -145,7 +145,7 @@ class ClassificationError(Inferencer):
logger.error("[DEPRECATED] use a 'wrong vector' for ClassificationError instead of nr_wrong. Exiting..") logger.error("[DEPRECATED] use a 'wrong vector' for ClassificationError instead of nr_wrong. Exiting..")
sys.exit(1) sys.exit(1)
else: else:
# TODO put shape assertion into inferencerrunner # TODO put shape assertion into inference-runner
assert vec.ndim == 1, "{} is not a vector!".format(self.wrong_tensor_name) assert vec.ndim == 1, "{} is not a vector!".format(self.wrong_tensor_name)
batch_size = len(vec) batch_size = len(vec)
wrong = np.sum(vec) wrong = np.sum(vec)
......
...@@ -134,7 +134,7 @@ class HyperParamSetter(Triggerable): ...@@ -134,7 +134,7 @@ class HyperParamSetter(Triggerable):
The value to assign to the variable. The value to assign to the variable.
Note: Note:
Subclasses will implemenet the abstract method Subclasses will implement the abstract method
:meth:`_get_value_to_set`, which should return a new value to :meth:`_get_value_to_set`, which should return a new value to
set, or return None to do nothing. set, or return None to do nothing.
""" """
......
...@@ -39,7 +39,7 @@ class MergeAllSummaries(Callback): ...@@ -39,7 +39,7 @@ class MergeAllSummaries(Callback):
def __init__(self, run_alone=False, key=tf.GraphKeys.SUMMARIES): def __init__(self, run_alone=False, key=tf.GraphKeys.SUMMARIES):
""" """
Args: Args:
run_alone (bool): whether to eval the summaries alone. run_alone (bool): whether to evaluate the summaries alone.
If True, summaries will be evaluated after each epoch alone. If True, summaries will be evaluated after each epoch alone.
If False, summaries will be evaluated together with other If False, summaries will be evaluated together with other
`sess.run` calls, in the last step of each epoch. `sess.run` calls, in the last step of each epoch.
......
...@@ -181,7 +181,9 @@ def CaffeLMDB(lmdb_path, shuffle=True, keys=None): ...@@ -181,7 +181,9 @@ def CaffeLMDB(lmdb_path, shuffle=True, keys=None):
a :class:`LMDBDataDecoder` instance. a :class:`LMDBDataDecoder` instance.
Example: Example:
``ds = CaffeLMDB("/tmp/validation", keys='{:0>8d}')``
.. code-block:: none
ds = CaffeLMDB("/tmp/validation", keys='{:0>8d}')
""" """
cpb = get_caffe_pb() cpb = get_caffe_pb()
......
...@@ -82,7 +82,7 @@ class FixedCrop(ImageAugmentor): ...@@ -82,7 +82,7 @@ class FixedCrop(ImageAugmentor):
raise NotImplementedError() raise NotImplementedError()
def perturb_BB(image_shape, bb, max_pertub_pixel, def perturb_BB(image_shape, bb, max_perturb_pixel,
rng=None, max_aspect_ratio_diff=0.3, rng=None, max_aspect_ratio_diff=0.3,
max_try=100): max_try=100):
""" """
...@@ -91,7 +91,7 @@ def perturb_BB(image_shape, bb, max_pertub_pixel, ...@@ -91,7 +91,7 @@ def perturb_BB(image_shape, bb, max_pertub_pixel,
Args: Args:
image_shape: [h, w] image_shape: [h, w]
bb (Rect): original bounding box bb (Rect): original bounding box
max_pertub_pixel: pertubation on each coordinate max_perturb_pixel: perturbation on each coordinate
max_aspect_ratio_diff: result can't have an aspect ratio too different from the original max_aspect_ratio_diff: result can't have an aspect ratio too different from the original
max_try: if cannot find a valid bounding box, return the original max_try: if cannot find a valid bounding box, return the original
Returns: Returns:
...@@ -101,7 +101,7 @@ def perturb_BB(image_shape, bb, max_pertub_pixel, ...@@ -101,7 +101,7 @@ def perturb_BB(image_shape, bb, max_pertub_pixel,
if rng is None: if rng is None:
rng = np.random.RandomState() rng = np.random.RandomState()
for _ in range(max_try): for _ in range(max_try):
p = rng.randint(-max_pertub_pixel, max_pertub_pixel, [4]) p = rng.randint(-max_perturb_pixel, max_perturb_pixel, [4])
newbb = bb.copy() newbb = bb.copy()
newbb.x += p[0] newbb.x += p[0]
newbb.y += p[1] newbb.y += p[1]
...@@ -121,7 +121,7 @@ def perturb_BB(image_shape, bb, max_pertub_pixel, ...@@ -121,7 +121,7 @@ def perturb_BB(image_shape, bb, max_pertub_pixel,
class RandomCropAroundBox(ImageAugmentor): class RandomCropAroundBox(ImageAugmentor):
""" """
Crop a box around a bounding box by some random pertubation Crop a box around a bounding box by some random perturbation
""" """
def __init__(self, perturb_ratio, max_aspect_ratio_diff=0.3): def __init__(self, perturb_ratio, max_aspect_ratio_diff=0.3):
......
...@@ -31,7 +31,7 @@ class JpegNoise(ImageAugmentor): ...@@ -31,7 +31,7 @@ class JpegNoise(ImageAugmentor):
class GaussianNoise(ImageAugmentor): class GaussianNoise(ImageAugmentor):
""" """
Add random gaussian noise N(0, sigma^2) of the same shape to img. Add random Gaussian noise N(0, sigma^2) of the same shape to img.
""" """
def __init__(self, sigma=1, clip=True): def __init__(self, sigma=1, clip=True):
""" """
......
...@@ -17,7 +17,7 @@ class BackgroundFiller(object): ...@@ -17,7 +17,7 @@ class BackgroundFiller(object):
def fill(self, background_shape, img): def fill(self, background_shape, img):
""" """
Return a proper background image of background_shape, given img Return a proper background image of background_shape, given img.
Args: Args:
background_shape: a shape of [h, w] background_shape: a shape of [h, w]
...@@ -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 convas.
""" """
def _get_augment_params(self, img): def _get_augment_params(self, img):
......
...@@ -14,7 +14,7 @@ def class_scope(func): ...@@ -14,7 +14,7 @@ def class_scope(func):
The "{class_name}" is either ``cls.name`` or simply the class name. The "{class_name}" is either ``cls.name`` or simply the class name.
It helps enhance TensorBoard graph visualization by grouping operators. It helps enhance TensorBoard graph visualization by grouping operators.
This is just syntatic sugar to prevent wrinting: with This is just syntactic sugar to prevent writing: with
``tf.name_scope(...)`` in each method. ``tf.name_scope(...)`` in each method.
""" """
...@@ -36,7 +36,7 @@ def class_scope(func): ...@@ -36,7 +36,7 @@ def class_scope(func):
class Distribution(object): class Distribution(object):
""" """
Base class of symbolic distribution utilities Base class of symbolic distribution utilities
(the distrbution parameters can be symbolic tensors). (the distribution parameters can be symbolic tensors).
""" """
name = None name = None
...@@ -73,7 +73,7 @@ class Distribution(object): ...@@ -73,7 +73,7 @@ class Distribution(object):
@class_scope @class_scope
def entropy(self, x, theta): def entropy(self, x, theta):
r""" Entropy of this distribution parameterized by theta, r""" Entropy of this distribution parameterized by theta,
esimtated from a batch of samples. estimated from a batch of samples.
.. math:: .. math::
...@@ -91,7 +91,7 @@ class Distribution(object): ...@@ -91,7 +91,7 @@ class Distribution(object):
@class_scope @class_scope
def sample(self, batch_size, theta): def sample(self, batch_size, theta):
""" """
Sample a batch of vectors from this distrbution parameterized by theta. Sample a batch of vectors from this distribution parameterized by theta.
Args: Args:
batch_size(int): the batch size. batch_size(int): the batch size.
...@@ -121,7 +121,7 @@ class Distribution(object): ...@@ -121,7 +121,7 @@ class Distribution(object):
Note that for each distribution, Note that for each distribution,
there are many feasible ways to design this function and it's hard to say which is better. there are many feasible ways to design this function and it's hard to say which is better.
The default implementations in the distrbution classes here is The default implementations in the distribution classes here is
just one reasonable way to do this. just one reasonable way to do this.
Args: Args:
......
...@@ -134,7 +134,7 @@ _summaried_gradient = set() ...@@ -134,7 +134,7 @@ _summaried_gradient = set()
# TODO let the maintain op depend on grad directly ? # TODO let the maintain op depend on grad directly ?
class SummaryGradient(MapGradient): class SummaryGradient(MapGradient):
""" """
Summary histogram and RMS for each graident variable. Summary histogram and RMS for each gradient variable.
""" """
def __init__(self): def __init__(self):
......
...@@ -259,7 +259,7 @@ def contrastive_loss(left, right, y, margin, extra=False, scope="constrastive_lo ...@@ -259,7 +259,7 @@ def contrastive_loss(left, right, y, margin, extra=False, scope="constrastive_lo
def cosine_loss(left, right, y, scope="cosine_loss"): def cosine_loss(left, right, y, scope="cosine_loss"):
r"""Loss for Siamese networks (cosine version). r"""Loss for Siamese networks (cosine version).
Same as :func:`contrastive_loss` but with different similarity measurment. Same as :func:`contrastive_loss` but with different similarity measurement.
.. math:: .. math::
[\frac{l \cdot r}{\lVert l\rVert \lVert r\rVert} - (2y-1)]^2 [\frac{l \cdot r}{\lVert l\rVert \lVert r\rVert} - (2y-1)]^2
...@@ -306,7 +306,7 @@ def triplet_loss(anchor, positive, negative, margin, extra=False, scope="triplet ...@@ -306,7 +306,7 @@ def triplet_loss(anchor, positive, negative, margin, extra=False, scope="triplet
anchor (tf.Tensor): anchor feature vectors of shape [Batch, N]. anchor (tf.Tensor): anchor feature vectors of shape [Batch, N].
positive (tf.Tensor): features of positive match of the same shape. positive (tf.Tensor): features of positive match of the same shape.
negative (tf.Tensor): features of negative match of the same shape. negative (tf.Tensor): features of negative match of the same shape.
margin (float): horizont for negative examples margin (float): horizon for negative examples
extra (bool): also return distances for pos and neg. extra (bool): also return distances for pos and neg.
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