tensorboard.rst 1.2 KB
Newer Older
L
LI Yunxiang 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
Tensorboard
===============

Visualize the results with tensorboard.

add_scalar
-------------

Common used arguments:

* tensorboard.add_scalar(tag, scalar_value, global_step=None)
    * tag *(string)* – Data identifier
    * scalar_value *(float or string/blobname)* – Value to save
    * global_step *(int)* – Global step value to record

Example:

.. code-block:: python

    from parl.utils import tensorboard

    x = range(100)
    for i in x:
        tensorboard.add_scalar('y=2x', i * 2, i)

Expected result:

    .. image:: add_scalar.jpg
        :scale: 50 %
            
add_histogram
----------------

Common used arguments:

* tensorboard.add_scalar(tag, scalar_value, global_step=None)
    * tag *(string)* – Data identifier
    * values *(torch.Tensor, numpy.array, or string/blobname)* – Values to build histogram
    * global_step *(int)* – Global step value to record

Example:

.. code-block:: python

    from parl.utils import tensorboard
    import numpy as np

    for i in range(10):
        x = np.random.random(1000)
        tensorboard.add_histogram('distribution centers', x + i, i)

Expected result:

    .. image:: add_histogram.jpg
        :scale: 50 %