def plot_lr(self, show_text=True, show_moms=True):
        """Plots the lr rate/momentum schedule"""
        phase_limits = [0]
        for nb_batch, phase in zip(self.nb_batches, self.phases):
            phase_limits.append(phase_limits[-1] + nb_batch * phase.epochs)
        if not in_ipynb():
            plt.switch_backend('agg')
        np_plts = 2 if show_moms else 1
        fig, axs = plt.subplots(1,np_plts,figsize=(6*np_plts,4))
        if not show_moms: axs = [axs]
        for i in range(np_plts): axs[i].set_xlabel('iterations')
        axs[0].set_ylabel('learning rate')
        axs[0].plot(self.iterations,self.lrs)
        if show_moms:
            axs[1].set_ylabel('momentum')
            axs[1].plot(self.iterations,self.momentums)
        if show_text:   
            for i, phase in enumerate(self.phases):
                text = phase.opt_fn.__name__
                if phase.wds is not None: text+='\nwds='+str(phase.wds)
                if phase.beta is not None: text+='\nbeta='+str(phase.beta)
                for k in range(np_plts):
                    if i < len(self.phases)-1:
                        draw_line(axs[k], phase_limits[i+1])
                    draw_text(axs[k], (phase_limits[i]+phase_limits[i+1])/2, text) 
        if not in_ipynb():
            plt.savefig(os.path.join(self.save_path, 'lr_plot.png'))
def plot_lr ( self , show_text = True , show_moms = True ) : phase_limits = [ 0 ] for nb_batch , phase in zip ( self . nb_batches , self . phases ) : phase_limits . append ( phase_limits [ - 1 ] + nb_batch * phase . epochs ) if not in_ipynb ( ) : plt . switch_backend ( 'agg' ) np_plts = 2 if show_moms else 1 fig , axs = plt . subplots ( 1 , np_plts , figsize = ( 6 * np_plts , 4 ) ) if not show_moms : axs = [ axs ] for i in range ( np_plts ) : axs [ i ] . set_xlabel ( 'iterations' ) axs [ 0 ] . set_ylabel ( 'learning rate' ) axs [ 0 ] . plot ( self . iterations , self . lrs ) if show_moms : axs [ 1 ] . set_ylabel ( 'momentum' ) axs [ 1 ] . plot ( self . iterations , self . momentums ) if show_text : for i , phase in enumerate ( self . phases ) : text = phase . opt_fn . __name__ if phase . wds is not None : text += '\nwds=' + str ( phase . wds ) if phase . beta is not None : text += '\nbeta=' + str ( phase . beta ) for k in range ( np_plts ) : if i < len ( self . phases ) - 1 : draw_line ( axs [ k ] , phase_limits [ i + 1 ] ) draw_text ( axs [ k ] , ( phase_limits [ i ] + phase_limits [ i + 1 ] ) / 2 , text ) if not in_ipynb ( ) : plt . savefig ( os . path . join ( self . save_path , 'lr_plot.png' ) )
Plots the lr rate/momentum schedule