<s> from __future__ import absolute_import <EOL> from __future__ import print_function <EOL> import numpy as np <EOL> import warnings <EOL> import time , json <EOL> from collections import deque <EOL> from keras . callbacks import History <EOL> from plotting_utils import PlotGenerator <EOL> class Plotter ( History ) : <EOL> def __init__ ( self , <EOL> save_to_filepath = None , show_plot_window = True , <EOL> linestyles = None , linestyles_first_batch = None , <EOL> show_regressions = True , <EOL> poly_forward_perc = <NUM_LIT:0.1> , poly_backward_perc = <NUM_LIT> , <EOL> poly_n_forward_min = <NUM_LIT:5> , poly_n_backward_min = <NUM_LIT:10> , <EOL> poly_degree = <NUM_LIT:1> ) : <EOL> super ( Plotter , self ) . __init__ ( ) <EOL> pgen = PlotGenerator ( linestyles = linestyles , <EOL> linestyles_first_batch = linestyles_first_batch , <EOL> show_regressions = show_regressions , <EOL> poly_forward_perc = poly_forward_perc , <EOL> poly_backward_perc = poly_backward_perc , <EOL> poly_n_forward_min = poly_n_forward_min , <EOL> poly_n_backward_min = poly_n_backward_min , <EOL> poly_degree = poly_degree , <EOL> show_plot_window = show_plot_window , <EOL> save_to_filepath = save_to_filepath ) <EOL> self . plot_generator = pgen <EOL> self . losses = [ ] <EOL> self . accs = [ ] <EOL> self . old_batch = <NUM_LIT:0> <EOL> self . last_batch = <NUM_LIT:0> <EOL> def on_batch_end ( self , batch , logs = { } ) : <EOL> super ( Plotter , self ) . on_batch_end ( batch , logs ) <EOL> if batch == <NUM_LIT:0> and self . last_batch != <NUM_LIT:0> : <EOL> self . old_batch = self . last_batch <EOL> batch += self . old_batch <EOL> if batch + <NUM_LIT:1> == len ( self . accs ) : <EOL> return <EOL> self . last_batch = batch <EOL> train_loss = self . totals [ '<STR_LIT>' ] / self . seen <EOL> train_acc = self . totals [ '<STR_LIT>' ] / self . seen <EOL> self . losses . append ( train_loss ) <EOL> self . accs . append ( train_acc ) <EOL> self . plot_generator . update ( batch , self . losses , self . accs ) </s>
