Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use tensordboard? #195

Open
githubyaww opened this issue Mar 5, 2021 · 5 comments
Open

How to use tensordboard? #195

githubyaww opened this issue Mar 5, 2021 · 5 comments

Comments

@githubyaww
Copy link

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?

@SamSamhuns
Copy link

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

@bellzhong677
Copy link

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

@SamSamhuns
Copy link

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

@bellzhong677
Copy link

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

Thank you the code is work. But I still don't know in
$ tensorboard --logdir=experiments --port=6006
What is the experiments

@SamSamhuns
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants