diff --git a/tianshou/data/batch.py b/tianshou/data/batch.py index 2a670ab..2fbe431 100644 --- a/tianshou/data/batch.py +++ b/tianshou/data/batch.py @@ -100,14 +100,13 @@ class Batch: * ``done`` the done flag of step :math:`t` ; * ``obs_next`` the observation of step :math:`t+1` ; * ``info`` the info of step :math:`t` (in ``gym.Env``, the ``env.step()``\ - function return 4 arguments, and the last one is ``info``); + function returns 4 arguments, and the last one is ``info``); * ``policy`` the data computed by policy in step :math:`t`; - :class:`~tianshou.data.Batch` object can be initialized using wide variety - of arguments, starting with the key/value pairs or dictionary, but also - list and Numpy arrays of :class:`dict` or Batch instances. In which case, - each element is considered as an individual sample and get stacked - together: + :class:`~tianshou.data.Batch` object can be initialized by a wide variety + of arguments, ranging from the key/value pairs or dictionary, to list and + Numpy arrays of :class:`dict` or Batch instances where each element is + considered as an individual sample and get stacked together: :: >>> data = Batch([{'a': {'b': [0.0, "info"]}}]) @@ -119,7 +118,7 @@ class Batch: ) :class:`~tianshou.data.Batch` has the same API as a native Python - :class:`dict`. In this regard, one can access to stored data using string + :class:`dict`. In this regard, one can access stored data using string key, or iterate over stored data: :: @@ -132,7 +131,7 @@ class Batch: b: [5, 5] - :class:`~tianshou.data.Batch` is also reproduce partially the Numpy API for + :class:`~tianshou.data.Batch` also partially reproduces the Numpy API for arrays. It also supports the advanced slicing method, such as batch[:, i], if the index is valid. You can access or iterate over the individual samples, if any: @@ -147,7 +146,6 @@ class Batch: >>> for sample in data: >>> print(sample.a) [0., 2.] - [1., 3.] >>> print(data.shape) [1, 2] @@ -195,7 +193,7 @@ class Batch: ) Note that stacking of inconsistent data is also supported. In which case, - None is added in list or :class:`np.ndarray` of objects, 0 otherwise. + ``None`` is added in list or :class:`np.ndarray` of objects, 0 otherwise. :: >>> data_1 = Batch(a=np.array([0.0, 2.0])) @@ -208,7 +206,7 @@ class Batch: b: array([None, 'done'], dtype=object), ) - Also with method empty (which will set to 0 or ``None`` (with np.object)) + Method ``empty_`` sets elements to 0 or ``None`` for ``np.object``. :: >>> data.empty_() @@ -248,9 +246,9 @@ class Batch: Convenience helpers are available to convert in-place the stored data into Numpy arrays or Torch tensors. - Finally, note that :class:`~tianshou.data.Batch` instance are serializable - and therefore Pickle compatible. This is especially important for - distributed sampling. + Finally, note that :class:`~tianshou.data.Batch` is serializable and + therefore Pickle compatible. This is especially important for distributed + sampling. """ def __init__(self, @@ -618,7 +616,7 @@ class Batch: def split(self, size: Optional[int] = None, shuffle: bool = True) -> Iterator['Batch']: - """Split whole data into multiple small batch. + """Split whole data into multiple small batches. :param int size: if it is ``None``, it does not split the data batch; otherwise it will divide the data batch with the given size. diff --git a/tianshou/data/buffer.py b/tianshou/data/buffer.py index 7eefc50..53c158e 100644 --- a/tianshou/data/buffer.py +++ b/tianshou/data/buffer.py @@ -424,7 +424,7 @@ class PrioritizedReplayBuffer(ReplayBuffer): """Update priority weight by indice in this buffer. :param np.ndarray indice: indice you want to update weight - :param np.ndarray new_weight: new priority weight you wangt to update + :param np.ndarray new_weight: new priority weight you want to update """ if self._replace: if isinstance(indice, slice):