PyTorch
PyTorch is a deep learning framework that is extremely popular among researchers. We have written extensively about the differences between TensorFlow and PyTorch.
In this section, we will look at how TensorBoard can be used from PyTorch. Let's use a specific example to describe the steps. In this example, we will use the popular MNIST dataset. With TensorFlow, we used the Summary API to create the file writer that would log data into the logdir
folder. With PyTorch, there is a similar file writer. Here is a code snippet showing how to use it.
# Import the summary writer
from torch.utils.tensorboard import SummaryWriter
# Create an instance of the object
writer = SummaryWriter()
Once the file writer is created, we will write the data (i.e. image etc) to TensorBoard. See the section highlighted in the code snippet below.
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 |
|
Once the user navigates to TensorBoard, they will get output similar to what they would see with TensorFlow i.e. users can use the summary writer to write data just like they would with the Summary API.