tensorboard_scalar

import numpy as np

from tensorboardX import SummaryWriter

writer=SummaryWriter(log_dir="scala",comment="base_scala")

for epoch in range(100):
writer.add_scala('scala/test',np.random.rand(),epoch)
writer.add_scalars("scala/scalars_test",{"xsinx":epoch *np.sin(epoch),"xcosx":epoch*np.cos(epoch)},epoch)
writer.close()

1. from tensorboardXimport SummaryWriter

2. Then define a SummaryWriter () instance.

    Parameter SummaryWriter () is: def __init __ (self, log_dir = "scala", comment = "base_scala", ** kwargs):

       Log_dir file which is generated by the release of the directory,

       comment for the file name.

       The default directory folder directory to generate runs .

       

 

3.    writer.add_scalar('scalar/test', np.random.rand(), epoch)

       Data type scalar type

       The first argument can be simply understood as the name of the saved map

       The second parameter is the Y-axis data to be understood that

       The third parameter to be understood that the X-axis data

       When the data is more than one Y-axis, may be used writer.add_scalars ()

       

4. If the default directory, tensorboard --logdir runs

     In the present embodiment, tensorboard --logdir scalar

5. Finally, call writer.close ()

 

Guess you like

Origin www.cnblogs.com/hapyygril/p/11693407.html