Skip to content

Commit

Permalink
hparam support (#470)
Browse files Browse the repository at this point in the history
* hparam support

* add test and doc

* fix test for py2

* fix CI test again

* minor improves

* further improvements
  • Loading branch information
lanpa committed Jul 16, 2019
1 parent a66b1ac commit dce4fb1
Show file tree
Hide file tree
Showing 11 changed files with 2,012 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Write TensorBoard events with simple function call.

* Support `scalar`, `image`, `figure`, `histogram`, `audio`, `text`, `graph`, `onnx_graph`, `embedding`, `pr_curve`, `mesh`
* Support `scalar`, `image`, `figure`, `histogram`, `audio`, `text`, `graph`, `onnx_graph`, `embedding`, `pr_curve`, `mesh`, `hyper-parameters`
and `video` summaries.

* requirement for `demo_graph.py` is tensorboardX>=1.6 and pytorch>=1.1
Expand Down
Binary file added docs/_static/img/tensorboard/add_hparam.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions examples/demo_hparams.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from tensorboardX import SummaryWriter
import time
import random


hparam = {'lr': [0.1, 0.01, 0.001],
'bsize': [1, 2, 4],
'n_hidden': [100, 200]}

metrics = {'accuracy', 'loss'}

def train(lr, bsize, n_hidden):
x = random.random()
return x, x*5

with SummaryWriter() as w:
for lr in hparam['lr']:
for bsize in hparam['bsize']:
for n_hidden in hparam['n_hidden']:
accu, loss = train(lr, bsize, n_hidden)

w.add_hparams({'lr': lr, 'bsize': bsize, 'n_hidden': n_hidden},
{'accuracy': accu, 'loss': loss})

0 comments on commit dce4fb1

Please sign in to comment.