forked from microsoft/hi-ml
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Tensorboard ability to read from different folders (microsoft#112)
* Update run_tensorboard to work with logs in different folders * fix flake8 complaints * fix test and changelog * move types-requests to test_requirements for running mypy * update test * move tensorboard example into docs * shorten command line arg names * Address PR comments
- Loading branch information
Showing
17 changed files
with
250 additions
and
35 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# ------------------------------------------------------------------------------------------ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. | ||
# ------------------------------------------------------------------------------------------ | ||
from azureml.core import Environment, Experiment, ScriptRunConfig, Workspace | ||
|
||
|
||
def main() -> None: | ||
ws = Workspace.from_config("config.json") | ||
experiment = Experiment(ws, "tensorboard_test") | ||
config = ScriptRunConfig( | ||
source_directory='.', | ||
script="pytorch_sample.py", | ||
compute_target="<name of compute target>" | ||
) | ||
env = Environment.from_conda_specification("TensorboardTestEnv", "tensorboard_env.yml") | ||
config.run_config.environment = env | ||
|
||
run = experiment.submit(config) | ||
run.wait_for_completion() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.. literalinclude:: aml_sample.py | ||
:language: python |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# ------------------------------------------------------------------------------------------ | ||
# Adapted from the example at https://pytorch.org/tutorials/recipes/recipes/tensorboard_with_pytorch.html | ||
# ------------------------------------------------------------------------------------------ | ||
from pathlib import Path | ||
import torch | ||
from torch.utils.tensorboard import SummaryWriter | ||
|
||
|
||
def main() -> None: | ||
log_dir = Path("outputs") | ||
log_dir.mkdir(exist_ok=True) | ||
writer = SummaryWriter(log_dir=str(log_dir)) | ||
|
||
x = torch.arange(-20, 20, 0.1).view(-1, 1) | ||
y = -2 * x + 0.1 * torch.randn(x.size()) | ||
|
||
model = torch.nn.Linear(1, 1) | ||
criterion = torch.nn.MSELoss() | ||
optimizer = torch.optim.SGD(model.parameters(), lr=0.1) | ||
|
||
for epoch in range(10): | ||
y1 = model(x) | ||
loss = criterion(y1, y) | ||
writer.add_scalar("Loss/train", loss, epoch) | ||
optimizer.zero_grad() | ||
loss.backward() | ||
optimizer.step() | ||
writer.flush() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.. literalinclude:: pytorch_sample.py | ||
:language: python |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.. literalinclude:: tensorboard_env.yml | ||
:language: yaml |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: TensorboardTestEnv | ||
channels: | ||
- defaults | ||
- pytorch | ||
dependencies: | ||
- pip=20.1.1 | ||
- python=3.7.3 | ||
- pytorch=1.4.0 | ||
- pip: | ||
- tensorboard==2.2.1 |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ pylint==2.9.5 | |
pycobertura==2.0.1 | ||
pytest==6.2.2 | ||
pytest-cov==2.11.1 | ||
types-requests==2.25.6 |
This file contains 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
Binary file added
BIN
+518 Bytes
..._data/dummy_summarywriter_logs/id123/events.out.tfevents.1631695551.MSRC-11200758.38884.0
Binary file not shown.
Oops, something went wrong.