* doc fix

* change line

Co-authored-by: Trinkle23897 <463003665@qq.com>
This commit is contained in:
youkaichao 2020-07-08 08:30:01 +08:00 committed by GitHub
parent 9c7d31e5d6
commit dbbb859ec5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 16 deletions

View File

@ -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.

View File

@ -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):