def __init__(self, epoch_freq=1, y_range=(0, 4.5), fig=None, handle=None,
update_thresh_s=0.65, w=400, h=300, nepochs=1.0, total_batches=10.0,
train_source=None, val_source=None, history=10):
self.update_thresh_s = update_thresh_s
self.w = w
self.h = h
self.nepochs = nepochs
self.total = total_batches
self.last_update = 0
self.epoch = -1
self.history = history
self.cost_history = deque(maxlen=history)
if handle is None:
output_notebook()
self.handle = None
else:
self.handle = handle
if fig is None:
self.fig = figure(name="cost", y_axis_label="Cost", x_range=(0, self.nepochs), y_range=y_range,
x_axis_label="Epoch", plot_width=self.w, plot_height=self.h)
else:
self.fig = fig
if train_source is None:
self.train_source = ColumnDataSource(data=dict(x=[], y=[]))
else:
self.train_source = train_source
self.train_source.data = dict(x=[], y=[])
self.train_cost = self.fig.line('x', 'y', source=self.train_source)
if val_source is None:
self.val_source = ColumnDataSource(data=dict(x=[], y=[]))
else:
self.val_source = val_source
self.val_source.data = dict(x=[], y=[])
self.val_cost = self.fig.line('x', 'y', source=self.val_source, color='red')
评论列表
文章目录