Skip to content

Commit 78f9670

Browse files
committed
Removing Conda install references.
1 parent 1588c5e commit 78f9670

File tree

1 file changed

+37
-41
lines changed

1 file changed

+37
-41
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,17 @@
11
"""
22
How to use TensorBoard with PyTorch
33
===================================
4-
TensorBoard is a visualization toolkit for machine learning experimentation.
5-
TensorBoard allows tracking and visualizing metrics such as loss and accuracy,
6-
visualizing the model graph, viewing histograms, displaying images and much more.
7-
In this tutorial we are going to cover TensorBoard installation,
4+
TensorBoard is a visualization toolkit for machine learning experimentation.
5+
TensorBoard allows tracking and visualizing metrics such as loss and accuracy,
6+
visualizing the model graph, viewing histograms, displaying images and much more.
7+
In this tutorial we are going to cover TensorBoard installation,
88
basic usage with PyTorch, and how to visualize data you logged in TensorBoard UI.
99
1010
Installation
1111
----------------------
12-
PyTorch should be installed to log models and metrics into TensorBoard log
13-
directory. The following command will install PyTorch 1.4+ via
14-
Anaconda (recommended):
15-
16-
.. code-block:: sh
17-
18-
$ conda install pytorch torchvision -c pytorch
19-
20-
21-
or pip
12+
PyTorch should be installed to log models and metrics into TensorBoard log
13+
directory. The following command will install PyTorch 1.4+ via
14+
pip:
2215
2316
.. code-block:: sh
2417
@@ -29,31 +22,32 @@
2922
######################################################################
3023
# Using TensorBoard in PyTorch
3124
# -----------------------------
32-
#
33-
# Let’s now try using TensorBoard with PyTorch! Before logging anything,
25+
#
26+
# Let’s now try using TensorBoard with PyTorch! Before logging anything,
3427
# we need to create a ``SummaryWriter`` instance.
35-
#
28+
#
3629

3730
import torch
3831
from torch.utils.tensorboard import SummaryWriter
32+
3933
writer = SummaryWriter()
4034

4135
######################################################################
4236
# Writer will output to ``./runs/`` directory by default.
43-
#
37+
#
4438

4539

4640
######################################################################
4741
# Log scalars
4842
# -----------
49-
#
50-
# In machine learning, it’s important to understand key metrics such as
51-
# loss and how they change during training. Scalar helps to save
52-
# the loss value of each training step, or the accuracy after each epoch.
53-
#
54-
# To log a scalar value, use
55-
# ``add_scalar(tag, scalar_value, global_step=None, walltime=None)``.
56-
# For example, lets create a simple linear regression training, and
43+
#
44+
# In machine learning, it’s important to understand key metrics such as
45+
# loss and how they change during training. Scalar helps to save
46+
# the loss value of each training step, or the accuracy after each epoch.
47+
#
48+
# To log a scalar value, use
49+
# ``add_scalar(tag, scalar_value, global_step=None, walltime=None)``.
50+
# For example, lets create a simple linear regression training, and
5751
# log loss value using ``add_scalar``
5852
#
5953

@@ -62,7 +56,8 @@
6256

6357
model = torch.nn.Linear(1, 1)
6458
criterion = torch.nn.MSELoss()
65-
optimizer = torch.optim.SGD(model.parameters(), lr = 0.1)
59+
optimizer = torch.optim.SGD(model.parameters(), lr=0.1)
60+
6661

6762
def train_model(iter):
6863
for epoch in range(iter):
@@ -72,18 +67,19 @@ def train_model(iter):
7267
optimizer.zero_grad()
7368
loss.backward()
7469
optimizer.step()
75-
70+
71+
7672
train_model(10)
7773
writer.flush()
7874

7975

80-
######################################################################
81-
# Call ``flush()`` method to make sure that all pending events
76+
######################################################################
77+
# Call ``flush()`` method to make sure that all pending events
8278
# have been written to disk.
83-
#
84-
# See `torch.utils.tensorboard tutorials <https://pytorch.org/docs/stable/tensorboard.html>`_
79+
#
80+
# See `torch.utils.tensorboard tutorials <https://pytorch.org/docs/stable/tensorboard.html>`_
8581
# to find more TensorBoard visualization types you can log.
86-
#
82+
#
8783
# If you do not need the summary writer anymore, call ``close()`` method.
8884
#
8985

@@ -92,17 +88,17 @@ def train_model(iter):
9288
######################################################################
9389
# Run TensorBoard
9490
# ----------------
95-
#
91+
#
9692
# Install TensorBoard through the command line to visualize data you logged
9793
#
9894
# .. code-block:: sh
9995
#
10096
# pip install tensorboard
10197
#
10298
#
103-
# Now, start TensorBoard, specifying the root log directory you used above.
104-
# Argument ``logdir`` points to directory where TensorBoard will look to find
105-
# event files that it can display. TensorBoard will recursively walk
99+
# Now, start TensorBoard, specifying the root log directory you used above.
100+
# Argument ``logdir`` points to directory where TensorBoard will look to find
101+
# event files that it can display. TensorBoard will recursively walk
106102
# the directory structure rooted at ``logdir``, looking for ``.*tfevents.*`` files.
107103
#
108104
# .. code-block:: sh
@@ -114,17 +110,17 @@ def train_model(iter):
114110
# .. image:: ../../_static/img/thumbnails/tensorboard_scalars.png
115111
# :scale: 40 %
116112
#
117-
# This dashboard shows how the loss and accuracy change with every epoch.
118-
# You can use it to also track training speed, learning rate, and other
119-
# scalar values. It’s helpful to compare these metrics across different
113+
# This dashboard shows how the loss and accuracy change with every epoch.
114+
# You can use it to also track training speed, learning rate, and other
115+
# scalar values. It’s helpful to compare these metrics across different
120116
# training runs to improve your model.
121117
#
122118

123119

124120
########################################################################
125121
# Learn More
126122
# ----------------------------
127-
#
123+
#
128124
# - `torch.utils.tensorboard <https://pytorch.org/docs/stable/tensorboard.html>`_ docs
129125
# - `Visualizing models, data, and training with TensorBoard <https://pytorch.org/tutorials/intermediate/tensorboard_tutorial.html>`_ tutorial
130126
#

0 commit comments

Comments
 (0)