Created
December 3, 2021 15:49
-
-
Save daskol/b9d2f8a176c7599ec8ccceba28f83d0d to your computer and use it in GitHub Desktop.
Add PyTorch graph summary to TensorBoard.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import torch as T | |
| model = T.nn.Sequential() | |
| model.add_module('W0', T.nn.Linear(128, 10)) | |
| model.add_module('tanh', T.nn.Tanh()) | |
| model.add_module('W1', T.nn.Linear(10, 5)) | |
| model.add_module('tanh', T.nn.Tanh()) | |
| model.add_module('W2', T.nn.Linear(5, 1)) | |
| input = T.randn(16, 128) | |
| with T.utils.tensorboard.SummaryWriter('/tmp/log/graph-summary') as summary: | |
| summary.add_graph(model, x) | |
| # Now, run `tensorboard --logdir /tmp/log serve` in shell and open TensorBoard in browser. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment