Esempio n. 1
0
def show_mpl():
    cli = tw.WatcherClient()
    p = tw.mpl.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()
Esempio n. 2
0
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()
Esempio n. 3
0
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()
Esempio n. 4
0
def dynamic_hist():
    w = tw.Watcher()
    s = w.create_stream()

    v = tw.Visualizer(s, vis_type='histogram', bins=6, clear_after_each=True)
    v.show()

    for _ in range(100):
        s.write([random.random() * 10 for _ in range(100)])
        tw.plt_loop(count=3)
Esempio n. 5
0
def dynamic_bar():
    w = tw.Watcher()
    s = w.create_stream()

    v = tw.Visualizer(s, vis_type='bar', clear_after_each=True)
    v.show()

    for i in range(100):
        s.write([('a' + str(i), random.random() * 10) for i in range(10)])
        tw.plt_loop(count=3)
Esempio n. 6
0
def static_hist():
    w = tw.Watcher()
    s = w.create_stream()

    v = tw.Visualizer(s, vis_type='histogram', bins=6)
    v.show()

    for _ in range(100):
        s.write(random.random() * 10)

    tw.plt_loop()
Esempio n. 7
0
def dynamic_pie():
    w = tw.Watcher()
    s = w.create_stream()

    v = tw.Visualizer(s, vis_type='pie', bins=6, clear_after_each=True)
    v.show()

    for _ in range(100):
        s.write([('label' + str(i), random.random() * 10, None, i * 0.01)
                 for i in range(12)])
        tw.plt_loop(count=3)
Esempio n. 8
0
def static_bar():
    w = tw.Watcher()
    s = w.create_stream()

    v = tw.Visualizer(s, vis_type='bar')
    v.show()

    for i in range(10):
        s.write(int(random.random() * 10))

    tw.plt_loop()
Esempio n. 9
0
def show_mpl():
    cli = tw.WatcherClient()
    st_isum = cli.open_stream('isums')
    st_rsum = cli.open_stream('rsums')
    
    line_plot = tw.Visualizer(st_isum, vis_type='line', xtitle='i', ytitle='isum')
    line_plot.show()

    line_plot2 = tw.Visualizer(st_rsum, vis_type='line', host=line_plot, ytitle='rsum')

    tw.plt_loop()
Esempio n. 10
0
def dynamic_line3d():
    w = tw.Watcher()
    s = w.create_stream()

    v = tw.Visualizer(s, vis_type='line3d', clear_after_each=True)
    v.show()

    for i in range(100):
        s.write([(i, random.random() * 10, z) for i in range(10)
                 for z in range(10)])
        tw.plt_loop(count=3)
Esempio n. 11
0
def static_pie():
    w = tw.Watcher()
    s = w.create_stream()

    v = tw.Visualizer(s, vis_type='pie', bins=6)
    v.show()

    for i in range(6):
        s.write(('label' + str(i), random.random() * 10, None,
                 0.5 if i == 3 else 0))

    tw.plt_loop()
Esempio n. 12
0
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()
Esempio n. 13
0
def reader3():
    print('---------------------------reader3---------------------------')

    watcher = tw.Watcher(filename=r'c:\temp\test.log', port=None)
    stream1 = watcher.open_stream('metric1')
    stream2 = watcher.open_stream('metric2')

    vis1 = tw.Visualizer(stream1, vis_type='line')
    vis2 = tw.Visualizer(stream2, vis_type='line', host=vis1)

    vis1.show()

    tw.plt_loop()
Esempio n. 14
0
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()
Esempio n. 15
0
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()
Esempio n. 16
0
def plot_weight():
    train_cli = tw.WatcherClient()

    params = train_cli.create_stream(
        event_name='batch',
        expr='lambda d:agg_params(d.model, lambda p: p.abs().mean().item())',
        throttle=1)
    params_plot = tw.mpl.LinePlot()
    params_plot.subscribe(params,
                          xtitle='Epoch',
                          ytitle='avg |params|',
                          clear_after_each=1,
                          history_len=40,
                          dim_history=True)
    params_plot.show()

    tw.plt_loop()
Esempio n. 17
0
def batch_stats():
    train_cli = tw.WatcherClient()
    stream = train_cli.create_stream(
        event_name="batch",
        expr='lambda v:(v.metrics.epochf, v.metrics.batch_loss)',
        throttle=0.75)

    train_loss = tw.Visualizer(stream,
                               clear_after_end=False,
                               vis_type='mpl-line',
                               xtitle='Epoch',
                               ytitle='Train Loss')

    #train_acc = tw.Visualizer('lambda v:(v.metrics.epochf, v.metrics.epoch_loss)', event_name="batch",
    #                     xtitle='Epoch', ytitle='Train Accuracy', clear_after_end=False, yrange=(0,1),
    #                     vis=train_loss, vis_type='mpl-line')

    train_loss.show()
    tw.plt_loop()
Esempio n. 18
0
def epoch_stats():
    train_cli = tw.WatcherClient(port=0)
    test_cli = tw.WatcherClient(port=1)

    plot = tw.mpl.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()
Esempio n. 19
0
import tensorwatch as tw

w = tw.Watcher()
s = w.create_stream()

v = tw.Visualizer(s, vis_type='line')
v.show()

for i in range(10):
    i = float(i)
    s.write(tw.PointData(i, i * i, low=i * i - i, high=i * i + i))

tw.plt_loop()