def show_mpl(): cli = tw.WatcherClient() p = tw.LinePlot(title='Demo') s1 = cli.create_stream(expr='lambda v:(v.i, v.sum)') p.subscribe(s1, xtitle='Index', ytitle='sqrt(ev_i)') p.show() tw.plt_loop()
def mpl_line_plot(): cli = tw.WatcherClient() p = tw.LinePlot(title='Demo') s1 = cli.create_stream(event_name='ev_i', expr='map(lambda v:math.sqrt(v.val)*2, l)') p.subscribe(s1, xtitle='Index', ytitle='sqrt(ev_i)') p.show() tw.plt_loop()
def show_mpl(): cli = tw.WatcherClient(r'c:\temp\sum.log') s1 = cli.open_stream('sum') p = tw.LinePlot(title='Demo') p.subscribe(s1, xtitle='Index', ytitle='sqrt(ev_i)') s1.load() p.show() tw.plt_loop()
def show_find_lr(): cli_train = tw.WatcherClient() plot = tw.LinePlot() train_batch_loss = cli_train.create_stream( event_name='batch', expr='lambda d:(d.tt.scheduler.get_lr()[0], d.metrics.batch_loss)') plot.subscribe(train_batch_loss, xtitle='Epoch', ytitle='Loss') utils.wait_key()
def mpl_history_plot(): cli = tw.WatcherClient() p2 = tw.LinePlot(title='History Demo') p2s1 = cli.create_stream( event_name='ev_j', expr='map(lambda v:(v.val, math.sqrt(v.val)*2), l)') p2.subscribe(p2s1, xtitle='Index', ytitle='sqrt(ev_j)', clear_after_end=True, history_len=15) p2.show() tw.plt_loop()
def plot_weight(): train_cli = tw.WatcherClient() params = train_cli.create_stream(event_name='batch', expr='lambda d:weights_abs_mean(d.model)', throttle=1) params_plot = tw.LinePlot() params_plot.subscribe(params, xtitle='Layer', ytitle='avg |params|', clear_after_each=1, history_len=40, dim_history=True) params_plot.show() tw.plt_loop()
def plot_grads(): train_cli = tw.WatcherClient() grads = train_cli.create_stream(event_name='batch', expr='lambda d:grads_abs_mean(d.model)', throttle=1) grad_plot = tw.LinePlot() grad_plot.subscribe(grads, xtitle='Layer', ytitle='Gradients', clear_after_each=1, history_len=40, dim_history=True) grad_plot.show() tw.plt_loop()
def epoch_stats(): train_cli = tw.WatcherClient(port=0) test_cli = tw.WatcherClient(port=1) plot = tw.LinePlot() train_loss = train_cli.create_stream( event_name="epoch", expr='lambda v:(v.metrics.epoch_index, v.metrics.epoch_loss)') plot.subscribe(train_loss, xtitle='Epoch', ytitle='Train Loss') test_acc = test_cli.create_stream( event_name="epoch", expr='lambda v:(v.metrics.epoch_index, v.metrics.epoch_accuracy)') plot.subscribe(test_acc, xtitle='Epoch', ytitle='Test Accuracy', ylim=(0, 1)) plot.show() tw.plt_loop()