Open githubyaww opened 3 years ago
Add this in the training code
from torch.utils.tensorboard import SummaryWriter
tboard_writer = SummaryWriter(log_dir="experiments")
# to add the network structure in the tensorboard logger
# make sure the type matches the input type required for the model
_dummy_input = torch.ones([1, c, h, w], dtype=torch.float32).to(self.device)
tboard_writer.add_graph(self.model, _dummy_input)
# to add a batch of images in the tensorboard logger
tboard_writer.add_images('preprocessed image batch',
next(iter(train_data_loader))[0],
epoch_number)
# to add scalars such as loss/accuracy values in the tensorboard logger
tboard_writer.add_scalars('Loss (epoch)',
{'train': train_loss},
epoch_number)
Install tensorboard using pip, i.e. pip install tensorboard
, then to run the tensorboard display on localhost:port 6006, run:
$ tensorboard --logdir=experiments --port=6006
More instructions here at the official PyTorch documentation
Add this in the training code
from torch.utils.tensorboard import SummaryWriter tboard_writer = SummaryWriter(log_dir="experiments") # to add the network structure in the tensorboard logger # make sure the type matches the input type required for the model _dummy_input = torch.ones([1, c, h, w], dtype=torch.float32).to(self.device) tboard_writer.add_graph(self.model, _dummy_input) # to add a batch of images in the tensorboard logger tboard_writer.add_images('preprocessed image batch', next(iter(train_data_loader))[0], epoch_number) # to add scalars such as loss/accuracy values in the tensorboard logger tboard_writer.add_scalars('Loss (epoch)', {'train': train_loss}, epoch_number)
Install tensorboard using pip, i.e.
pip install tensorboard
, then to run the tensorboard display on localhost:port 6006, run:$ tensorboard --logdir=experiments --port=6006
More instructions here at the official PyTorch documentation
hello,i met this problem could you help me? NameError: name 'c' is not defined
c, h, w
refer to the input channel, height and width of network. Based on what network you are using these values might be 3, 320, 320
.
Check the config/yaml
files to get the input shape of the network. For example this network mobilenet_v2_ssd320_voc0712.yaml
will have c,h,w values of 3,320,320
c, h, w
refer to the input channel, height and width of network. Based on what network you are using these values might be3, 320, 320
.Check the
config/yaml
files to get the input shape of the network. For example this networkmobilenet_v2_ssd320_voc0712.yaml
will have c,h,w values of 3,320,320
Thank you the code is work. But I still don't know in $ tensorboard --logdir=experiments --port=6006 What is the experiments
This line tboard_writer = SummaryWriter(log_dir="experiments")
should create an experiments folder in your working directory where tensorboard stores its log files.
Then from a different terminal, you can enter tensorboard --logdir=experiments --port=6006
to start the tensorboard server in your localhost at port 6006, after which you can go to http://localhost:6006/
in your browser to see the tboard logs
I want to look at the network structure diagram, but I am not sure how to change it,and i don't know how to use tensorboard, can you help me?