@@ -0,0 +1,1691 @@
+'''Server for visualization.'''%0Afrom __future__ import (absolute_import, print_function, unicode_literals, division)%0A%0Aimport json%0Afrom random import random%0Aimport numpy as np%0A%0Afrom bokeh.layouts import column%0Afrom bokeh.models import Button%0Afrom bokeh.palettes import Set1%0Afrom bokeh.plotting import figure, curdoc%0A%0AFILENAME = 'log'%0A%0A# create a plot and style its properties%0Ap = figure(plot_width=1200, plot_height=800)%0ACOLORS = Set1%5B3%5D%5B:2%5D * 2%0AALPHAS = %5B.4, .4, 1., 1.%5D%0Aloss = p.multi_line(xs=%5B%5B%5D%5D * 4,%0A                    ys=%5B%5B%5D%5D * 4,%0A                    color=COLORS,%0A                    alpha=ALPHAS)%0A%0A# # create a callback that will add a number in a random location%0ATRAIN_KEY, TEST_KEY = 'main/nll', 'validation/main/nll'%0AWINDOW_SIZE = 10%0A%0A%0Adef callback():%0A    with open(FILENAME) as ifile:%0A        data = json.load(ifile)%0A        train_ts = np.array(%5B(record%5B'iteration'%5D, record%5BTRAIN_KEY%5D) for record in data%5D, 'f')%0A        test_ts = np.array(%5B(record%5B'iteration'%5D, record%5BTEST_KEY%5D) for record in data if TEST_KEY in record%5D, 'f')%0A%0A    window = np.hamming(WINDOW_SIZE)%0A    window /= window.sum()%0A    def smooth(data):%0A        return np.concatenate(%5Bdata%5B:WINDOW_SIZE-1%5D, np.convolve(data, window, mode='valid')%5D)%0A%0A    train_smooth = smooth(train_ts%5B:, 1%5D)%0A    test_smooth = smooth(test_ts%5B:, 1%5D)%0A%0A    loss.data_source.data.update(%7B%0A        'xs': %5Btrain_ts%5B:, 0%5D, test_ts%5B:, 0%5D%5D * 2,%0A        'ys': %5Btrain_ts%5B:, 1%5D, test_ts%5B:, 1%5D, train_smooth, test_smooth%5D,%0A    %7D)%0A%0A%0A# # add a button widget and configure with the call back%0Abutton = Button(label=%22Update%22)%0Abutton.on_click(callback)%0A%0A# put the button and plot in a layout and add to the document%0Acurdoc().add_root(column(button, p))%0A

Add live monitoring